Applescript help with serial port access

Joined
Jun 24, 2011
Messages
1
Reaction score
0
Points
1
Greet,

New to development, I seek help with an applescript to access a USB->Serial adapater to allow me to send a simple text string command down the wire to the device on the other end.

I have installed the serialport x applescript extension.
MacSoft

Here is my applescript:
Code:
--Send a simple mode command to the K3
set the lsb to "md1;"

set thePorts to serialport list
set port_name to choose from list thePorts

try
	set usbserial to serialport open port_name bps rate 9600
on error theErr number errNum
	if usbserial is -1 then
		display dialog "serial port is in use " & usbserial
		return "ERROR: " & theErr & " --- " & errNum
	end if
end try


serialport write "lsb"

delay 0.25


serialport close usbserial

Here is the output:

Code:
tell application "AppleScript Editor"
	serialport list
		--> {"/dev/cu.usbserial-A70062jT", "/dev/cu.KeySerial1", "/dev/cu.USA19Hfa22P1.1", "/dev/cu.Bluetooth-PDA-Sync", "/dev/cu.Bluetooth-Modem"}
	choose from list {"/dev/cu.usbserial-A70062jT", "/dev/cu.KeySerial1", "/dev/cu.USA19Hfa22P1.1", "/dev/cu.Bluetooth-PDA-Sync", "/dev/cu.Bluetooth-Modem"}
		--> {"/dev/cu.KeySerial1"}
	serialport open {"/dev/cu.KeySerial1"} bps rate 9600
		--> -1
	serialport write "lsb"
	serialport close -1
end tell

Nothing happens, the script seems to run and close the port but the command never makes it to the other end (radio). If I use a serialport test program like this one:
http://homepage.mac.com/chen/w7ay/Serial Tools/index.html
everthing works, I connect to the port, and type md1; in the window and the mode changes on the radio. So it seems the only issue is getting applescript to send the serialport write command correctly?

Thanks,

Lee
 

Shop Amazon


Shop for your Apple, Mac, iPhone and other computer products on Amazon.
We are a participant in the Amazon Services LLC Associates Program, an affiliate program designed to provide a means for us to earn fees by linking to Amazon and affiliated sites.
Top