Having recently finished playing with Xcode and AppleScript I decided to write the comm program this way, too. Eventually this application will be evolved to gather telemetry data and send remote commands.
Incidentally, serial communications isn't native to AppleScript so I chose Serialport X to extend AppleScript for serial communications.
The AppleScript application interface consists of a pulldown menu to select a serial device to use, a button to connect to (and disconnect from) the serial device, a status indicator, a text field for data received, and a text field and send button to send data. The GUI enforces basic, state-driven behavior by enabling and disabling objects on the interface based on the connection state.
Connecting to BlueSMiRF serial port
So in other words, you can't connect until you've selected a device. Once you are connected, you can't pick a new device. If you're disconnected the button is labeled "Connect" and clicking it connects to the selected device. If you're connected the button is renamed "Disconnect" and clicking it disconnects. Likewise, the send button and text fields are controlled by connection state. Here's a state diagram that covers the device selection and connect/disconnect button.
State Diagram of Serial Comm App
With the first incarnation of the AppleScript app, I was able to successfully connect to the BlueSMiRF through the MacBook bluetooth transciever, receive, and display data from the BS2. The second incarnation permitted two-way communications.
Here's the version of the source code as of this writing: GUITest1.applescript.zip
So with the Mac and BS2 communicating back and forth, it was time to get the ATmega168 on the Orangutan LV168 controller board talking through the BlueSMiRF to the Mac serial program I wrote.
To be Continued...
Hi Michael, I have been searching the web to find a easy way to send simple text based commands to a serial device using applescript. I found your page and tried your GUITest but could not get it to work. Here is the error:
ReplyDeletehttp://www.imber.com/tmp/GUITest_Error.png
Any ideas on your GUI or a simple way to send text down a serial connection?
Thanks,
Lee
ljimber [at} gmail {dot} com
hi, the download link doesn't work
ReplyDeletecan you update it
thanks