ProgrammingThis forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.
Welcome to LinuxQuestions.org, a friendly and active Linux Community.
You are currently viewing LQ as a guest. By joining our community you will have the ability to post topics, receive our newsletter, use the advanced search, subscribe to threads and access many other special features. Registration is quick, simple and absolutely free. Join our community today!
Note that registered members see fewer ads, and ContentLink is completely disabled once you log in.
If you have any problems with the registration process or your account login, please contact us. If you need to reset your password, click here.
Having a problem logging in? Please visit this page to clear all LQ-related cookies.
Introduction to Linux - A Hands on Guide
This guide was created as an overview of the Linux Operating System, geared toward new users as an exploration tour and getting started guide, with exercises at the end of each chapter.
For more advanced trainees it can be a desktop reference, and a collection of the base knowledge needed to proceed with system and network administration. This book contains many real life examples derived from the author's experience as a Linux system and network administrator, trainer and consultant. They hope these examples will help you to get a better understanding of the Linux system and that you feel encouraged to try out things on your own.
Click Here to receive this Complete Guide absolutely free.
I am looking to hook my security system into my linux server so that when the security system triggers a relay or drops a voltage, it can be detected by the server so that it can do a command/run a script.
I have been reading about how to make your own circuit to interface with either serial/parallel/or game port however I don't really want to design this if I don't have to. I am doing this for a company so money is not really an object. I was wondering if anybody premade these type of interfaces? I would also like some direction on software to use or code examples that can trigger the commands. If I have to design the interface myself, how complex is it and can you possibly give me a parts list?
Distribution: Debian Wheezy/Jessie/Sid, Linux Mint DE
If this is a professional application, I can recommend you to buy a simple I/O card. Use it either directly or with a relay interface to the outside world.
Cyberresearch.com stocks every conceivable I/O you might need.
Then (and this is the answer to your question) use the Comedi library to interface to the hardware. I don't know the URL, but google for it, and you'll find it. Extremely versatile, portable and reliable. I have used it in various projects.
Thank you for your answers guys/gals! However, I only need 1 input and not multiple which it looks like Cyberresearch.com has. Also, it requires a lot to make the stuff work. All I need is a simple interface to drop a votage on a pin so a program can run a command. Anybody else have any ideas?
If you wanted something quick and dirty like that you can use a serial port and have your script watch for the ring line on the RS-232 connection to go high. I think you have to pull it high with like 5 or 12 volts (can't remember off the top of my head) to get the script to see it, but it is easy to do and does not require much in the way of hardware. At one point i had a script around here that ran in the back ground and just watched for the ring line on the port 1 to go high and then it ran a program or what not.
I don't recommend using RS-232 inputs, since the voltage levels output by your transducer is unlikely to be compatible with RS-232. RS-232 uses bipolar voltages levels, +/- 12V, and -3V to +3V at an input pin is considered to be invalid, and results in undefined behavior.
If you have a relay contact closure to work with, you can drive a TTL input on a parallel port with it. Connect 2 or more of the output data port pins together, drive them all to a high (nominal +5V) level, and couple that back through the relay contact closure to one of the parallel port inputs pins. Place a high value resistor, say 1Megohm, between the input pin and ground. The whole business can be wired inside the hood of the parallel port connector. You may need to guard against contact bounce using this method. While a relay seems to make and break cleanly, in reality each closure is a series of rapid make-break events that a fast computer will be able to detect discretely.
If you have a TTL level output from your transducer, just drive an input pin on the parllel port with it. Don't forget to wire the ground connection between the transducer and the PC.
THere is plenty of online information on programming the PC parallel port, both in generic terms, and Linux-specificly.
I'm glad you guys/gals understand chip circuitry (ie. transducers) and such.
For the programming aspect of it, there are two methods to take:
This will undoubetly prove to be the most time-consuming, and archaic method of programming a chip. However, it is also the most supported due to the fact that you can completely control the flow. If this is the direction you want to head in, check out MPLAB (Microchip IDE). This requires a hefty knowledge of ASM (assembler) and C, and is made with highest support for the Microchip PIC processors.
This is an easier, slightly more elegant, but less-powerful method of serial port-interfacing. The previous suggestion was for programming chips, and I realize that, but a chip that interfaces with a serial port may be your solution. Using Gambas is very much akin to learning BASIC-based electronics/robotics programming. I know for a fact that Gambas has, not only support, but detailed tutorials on how to interface with a serial port. I, personally use Gambas for everything under the sun - what I lack in C/C++ knowledge, I make up for in BASIC knowledge.
While the other people in this discussion can offer valuable insight towards the hardware and circuitry, I can offer a helping hand in the software and interfacing.
A couple of years ago I was asked to set up a data logging system (temperature recording and alarm) for the cold stores of a subsidiary.
I found a neat little data logging system which was in fact overkill but very convenient. This thing has modules for recording all sorts of things into RAM and can then download the data to a PC via a serial port.
For this project you'd use the door microswitch module and poll the logger every few seconds.
I forget even the name of the logger - it's that good that I haven't been called out for several months.
OK you're talking about, say Ä500-600 but you could "justify" it by doing more with it. You can even control an aquarium with it. I can give you sample code (VB, sorry) which you could adapt to whatever language you want to use.
If interested post a reply & I'll dig out the details tomorrow at work.