LinuxQuestions.org
Register a domain and help support LQ
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - General
User Name
Password
Linux - General This Linux forum is for general Linux questions and discussion.
If it is Linux Related and doesn't seem to fit in any other forum then this is the place.

Notices

Reply
 
Search this Thread
Old 09-14-2008, 09:55 PM   #1
kev717
Member
 
Registered: May 2008
Distribution: Arch, Sabayon, Fedora, Ubuntu
Posts: 76

Rep: Reputation: 16
what is a good program for handling input and executing programs?


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
-kev
 
Old 09-15-2008, 12:25 AM   #2
stomfi
Member
 
Registered: Aug 2002
Location: Brisbane, Australia
Distribution: Ubuntu
Posts: 35

Rep: Reputation: 15
Quote:
Originally Posted by kev717 View Post
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
-kev
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:
#/bin/bash
while true
do
read LINE < /dev/tty0S
echo $LINE
done
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.
 
Old 09-15-2008, 03:09 PM   #3
kev717
Member
 
Registered: May 2008
Distribution: Arch, Sabayon, Fedora, Ubuntu
Posts: 76

Original Poster
Rep: Reputation: 16
so would this repeat itself, or if it goes off once then the program just exits?

Also, what command would I do to get the data off of a USB port?
-kev

Last edited by kev717; 09-15-2008 at 03:43 PM.
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Segmentation Fault when executing Program that prints out a number input didier2309 Programming 1 02-23-2006 05:55 PM
executing programs?!? cmargiol Linux - General 8 10-29-2003 03:38 PM
Executing X-Programs remotely frankieboy Linux - General 3 10-08-2003 03:31 AM
executing programs with arguments ? shaneblyth Mandriva 10 09-27-2003 09:01 PM
Executing Perl Programs 1huskerfan Programming 3 01-06-2002 08:39 PM


All times are GMT -5. The time now is 10:14 PM.

Main Menu
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
identi.ca: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration