Originally Posted by kev717
My question may seem vague, but basically what I need is a program that will accept input from say a parallel or serial port and executing a command. Mostly I need this for my alarm system for my Lab. I'm going to hook up the device to close a switch (on a parallel or serial port) and cause my computer to execute a command to take a picture, or play an audio file of a gun being cocked.
Any suggestions would be greatly appreciated.
thanks in advance
Reading from a serial or parallel port can be done in a couple of ways.
1. You can read from the buffer and echo the result to another script or command thus:
read LINE < /dev/tty0S
Or instead of the echo command you can insert more processing commands.
2. You can use dd to process the raw input. See info coreutils for everything dd can do. Remember that /dev/ttySO is a file.
If you know how many bytes to expect you can even do this in a script.
dd if=/dev/ttyS0 count=1 bs=8
Add the option of=filename to put the output into a file or add a pipe (|) to pipe the output of dd to other commands.
There are probably some pages on the web for using dd. It used to be quite prevalent in the old Unix world for processing telemetry data received from a modem connection back in the pre www days, so you may have to dig and delve in the written world.