Catching Tags from an RFID Reader & Beating my Head Against a Wall

Hi There,

So I’m rather new to Applescripting but I recently decided to try using if for a project I’m trying to start up. Basically, I just want to read RFID tags using a Parallax RFID reader. I have both a USB reader and a serial reader attached to an Arduino Uno, which is coded correctly and passing the serial data along, as it should. I’ve also installed the FTDI driver and SerialPort X.

Here is what I have so far using the serial reader:

set dev to "/dev/cu.usbmodem1d161" serialport close dev set portRef to serialport open dev bps rate 2400 data bits 8 parity 0 stop bits 1 handshake 0 if portRef is equal to -1 then display dialog " could not open port " else set readPort to "" repeat until length of readPort is equal to 10 set readPort to serialport read portRef for 10 end repeat delay 2 display dialog readPort end if end
When I run the script and put a tag up to the reader, the LED on the reader switches from red to green, indicating that it sees the tag, but the script just keeps on running. Please let me know if what I’m doing wrong or if more information is needed.

Thanks in advance.

Disclaimer: I borrowed most of this code from a number of websites and would be happy to provide sources, if need be.

Hello.

Try this:

set dev to "/dev/cu.usbmodem1d161"
do shell script "serialport close " & dev
set portRef to do shell script "serialport open " & dev & " bps rate 2400 data bits 8 parity 0 stop bits 1 handshake 0
if portRef is equal to -1 then
display dialog " could not open port "
else
set readPort to ""
repeat until length of readPort is equal to 10
set readPort to serialport read portRef for 10
end repeat
delay 2
display dialog readPort
end if
end

Sorry, I should have specified - serialport is a scripting addition (SerialPort X), not a terminal command, so shell scripts using serialport just return ‘-bash: serialport: command not found’.