Tuesday, 15 April 2008

Reading from and sending data to the COM port in Bash

To read data that is coming from your COM port you need to know what the correct device is. Usually this is in /dev and is called something like /dev/ttyS0. To send data to the COM port simply redirect the output of an echo to the device:
echo "ping 192.168.1.1" > /dev/ttyS0
This will send the command ping 192.168.1.1 across the COM port to the device.

If you want to read from the COM port you need to concatenate the device:
cat /dev/ttyS0
This command will hand and any data will be printed to your console

No comments:

Post a Comment