Arduino + Applescript: serialport read

Hello, this is my first post because i could not find anything for my solution anywhere else, so i recur to direct helpline :)

My problem is that I can not manage to get the information from a tilt sensor an my Arduino into Applescript. Applescript compiles the script with no errors but then the whole program crashes. I have downloaded and installed SerialPort X correctly.

I think the problem is either in the Applescript script:

set portRef to serialport open "/dev/tty.usbmodem411" bps rate 9600 data bits 8 parity 0 stop bits 1 handshake 0
if portRef is equal to -1 then
    display dialog "Could not open serial port" buttons {"Cancel"} default button 1
else
    serialport read portRef
end if

OR I must tell that i have used Processing to interpret information from the same setup I currently working with without any issues. The only small detail is that processing reads in Bites, so the information from Arduino is set to be sent sent as BYTE :

Serial.print(2, BYTE);

So the Precessing console wrote 2 when the tilt sensor was HIGH.

Could this be the a possible problem?

Thank you very much! R

Found a temporary solution and posting it here in case some one is interested.

The issue was that in the Arduino code, the processed data must be output in DEC or HEX:

Serial.print(x, DEC); //where x is processed data by Arduino, in my case its an int

In Applescript, this working code will display the input:

set use_port to item 1 of (get serialport list)
set myPort to serialport open use_port bps rate 9600 data bits 8 parity 0 stop bits 1 handshake 0
display alert "Serial port opened, set to 9600, 8N1"
if ((serialport bytes available myPort) ? 0) then
	set x to serialport read myPort
	beep
	display dialog (x)
end if
-- close the serial port handle
serialport close myPort

Now i want to display the information in the Applescript console instead of dialogue window, any ideas?

I realize this is several years after the post, would you have a copy of the serialport X applescript plugin? This seems to have gone away from the original sources like https://www.macupdate.com/app/mac/20440/serialport-x and https://www.macupdate.com/download/20440/SerialPort_X2.zip

thanks:)