Question

I am attempting to read the contents of an RFID card with a bash script using a RFID reader I got from sparkfun, however the most promising piece of code I have found for it is:

#!/bin/sh
while :
do
  rfid=`screen /dev/cu.usbserial-A600JNHR 9600`  
  echo "RFID #: $rfid"  
  sleep 1  
done

which does what it is supposed to, only it never exits screen, so the variable cannot be checked against a known tag to perform an action.

My question: what do I need to do to get the tag in a variable so that I can use it to check and perform an action? Is this piece of code going about it all wrong, or do I just need to add an extra line or two to process the data?

Was it helpful?

Solution

This may work for you

#!/bin/bash
while read -r rfid; do
  echo "RFID #: $rfid"  
  sleep 1  
done < /dev/cu.usbserial-A600JNHR

OTHER TIPS

I got it thank you SiegeX I double checked and had used tty instead of cu for the code, here I had given the default that I had found and when I changed it I grabbed the tty.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top