New To Mac-Forums?

Welcome to our community! Join the discussion today by registering your FREE account. If you have any problems with the registration process, please contact us!

Get your questions answered by community gurus Advice and insight from world-class Apple enthusiasts Exclusive access to members-only contests, giveaways and deals

Join today!

 
Start a Discussion
 

Mac-Forums Brief

Subscribe to Mac-Forums Brief to receive special offers from Mac-Forums partners and sponsors

Join the conversation RSS
OS X - Development and Darwin Discussion and questions about development for Mac OS X.

Applescript help with serial port access


Post Reply New Thread Subscribe

 
Thread Tools
ljimber

 
Member Since: Jun 24, 2011
Posts: 1
ljimber is on a distinguished road

ljimber is offline
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/Se...ols/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
QUOTE Thanks

Post Reply New Thread Subscribe


« new developer questions | reset time limit »
Thread Tools

Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts
BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off
Forum Jump

Similar Threads
Thread
Thread Starter
Forum
Replies
Last Post
Audio port problem. adam_21 Apple Notebooks 1 03-10-2011 01:45 PM
help needed to link up buttons on HUD Window to Applescript nick_harambee OS X - Development and Darwin 0 09-30-2010 08:26 AM
Port Foward/ Bridge mode/ Speed issue rc1980 Internet, Networking, and Wireless 0 06-08-2010 10:54 PM
Final Cut Studio serial number error mokoosh Movies and Video 3 01-15-2010 10:37 PM
Open, Unassigned Port andy_mx1 OS X - Operating System 0 12-31-2006 11:40 AM

All times are GMT -4. The time now is 04:58 AM.

Powered by vBulletin
Copyright ©2000 - 2014, Jelsoft Enterprises Ltd.
X

Welcome to Mac-Forums.com

Create your username to jump into the discussion!

New members like you have made this community the ultimate source for your Mac since 2003!


(4 digit year)

Already a member?