Connectivity: Supercard to PC

Need help with a script? This is the place to discuss how to get your code running!

Connectivity: Supercard to PC

Postby jbliss » Mon Jul 10, 2017 11:17 am

Hi all, I have an interesting situation, but hopefully a straightforward question:

I am running Supercard 4.7 on a MacBook Air. The Mac is connected by serial connection (RS232) to a PC that is running COBI - an application for functional near-infrared spectroscopy (fNIRS).

COBI is able to listen to the PC's serial port for incoming data markers, which can trigger various events (record data, stop recording, etc.). The messages it is listening for should be in the form of byte data in the range of 0-100. So I'm having Supercard send byte data via LAN to the PC.

My script for doing this is pretty simple:

send "40" to program "servername:program" without reply

Question: does this appear to be the correct syntax for sending byte data, or should I be specifying it differently (for example, using chevrons instead of quotes)?

Thank you for any suggestions you have.

Jim
jbliss
 
Posts: 5
Joined: Mon Jul 10, 2017 7:21 am

Re: Connectivity: Supercard to PC

Postby Scott » Tue Jul 11, 2017 4:23 am

The short answer to your question is no. The send command uses Apple communication protocols that have nothing to do with serial i/o.

The long answer involves a lot of things, including the adaptor you're using, and its driver. SuperCard can communicate with other Mac apps as well as the shell, so you might want to research if there is a terminal command to do this or possibly a terminal emulator.
User avatar
Scott
Site Admin
 
Posts: 1213
Joined: Sat Jul 05, 2008 1:37 pm
Location: Northern Sierra Nevada

Re: Connectivity: Supercard to PC

Postby jbliss » Wed Jul 12, 2017 10:32 am

Hmm, OK. I had hoped to avoid that, but if I have to...

I will look at Terminal commands. If anyone can point me in the right scripting direction to send byte data from Terminal (initiated in Supercard) I would be grateful. Not ready to concede defeat yet.

Jim
jbliss
 
Posts: 5
Joined: Mon Jul 10, 2017 7:21 am

Re: Connectivity: Supercard to PC

Postby jbliss » Wed Jul 12, 2017 10:37 am

Sorry...hit submit before I wanted to...

My suspicion is to use the following linux commands with Terminal to send the data through the serial port:

stty -F /dev/ttyUSB0 9600 raw -echo -- to initiate parameters for serial port
echo "byte string" > /dev/ttyUSB0 -- to actually send the byte string across to the PC


However, being generally ignorant about networking, I may be completely off base here.

Thanks,

Jim
jbliss
 
Posts: 5
Joined: Mon Jul 10, 2017 7:21 am

Re: Connectivity: Supercard to PC - Almost there

Postby jbliss » Fri Jul 14, 2017 8:52 am

All, I am almost there...

- Mac is connected to PC with RS232 cable.
- CoolTerm recognizes serial port on Mac and successfully passes CR and LF to the COBI program

Now all I need to do is have SuperCard send a message to CoolTerm so it will pass the CR/LF. The script seems to be similar to this:

send ReturnKey to "CoolTerm" [with eventSpec] without reply

However, my syntax is not working. I'm not sure how to specify the eventSpec so that CoolTerm will execute it. Any ideas? Should I be inserting the AppleEvent class and ID for the return key?

Thank you,

Jim
jbliss
 
Posts: 5
Joined: Mon Jul 10, 2017 7:21 am

Re: Connectivity: Supercard to PC

Postby Scott » Fri Jul 14, 2017 9:18 am

Launch the AppleScript editor and check Coolterm's dictionary to see if it can be told to do what you want. Once you have it working from the AS editor, you can execute the same code from SuperCard using the script() function.
User avatar
Scott
Site Admin
 
Posts: 1213
Joined: Sat Jul 05, 2008 1:37 pm
Location: Northern Sierra Nevada

Re: Connectivity: Supercard to PC

Postby jbliss » Mon Jul 17, 2017 4:56 am

Scott,

Thanks very much for your help! The program is now working. I had my doubts (Mac to PC RS232 comm and all), but things are looking good.

Great to have the support on this end. Have a good day, all,

Jim
jbliss
 
Posts: 5
Joined: Mon Jul 10, 2017 7:21 am


Return to Scripting in SuperTalk

Who is online

Users browsing this forum: No registered users and 3 guests

cron