Alarm contact detect

Jul 27, 2004 1 Replies

Hi All,



In short version: Does anyone know any freely available C source code (Linux/POSIX) for detecting whether the magnetic alarm contact is opened or closed ?



In long version: I have an SBC running Linux with Digital IO, these IO can be source/sink and swing between 3.5 V and ground (0V). I want to use these Digital IO as inputs from the magnetic alarm contacts (those that you stick at the door) and read the inputs. I just wonder if any C source code does this and freely available.



All help an pointer are appreciated in advance.


Regards,


K. P.


Bear with me as there are may ways to do this but if you know the IO address of the device you might just use inb (don't ask why I man'd outb):

OUTB(2) Linux Programmer's Manual OUTB(2) NAME outb, outw, outl, outsb, outsw, outsl - port output inb, inw, inl, insb, insw, insl - port input outb_p, outw_p, outl_p, inb_p, inw_p, inl_p - paused I/O DESCRIPTION This family of functions is used to do low level port input and output. They are primarily designed for internal kernel use, but can be used from user space. You compile with -O or -O2 or similar. The functions are defined as inline macros, and will not be substituted in without optimization enabled, causing unresolved references at link time. You use ioperm(2) or alternatively iopl(2) to tell the kernel to allow the user space application to access the I/O ports in question. Failure to do this will cause the application to receive a segmentation fault. CONFORMING TO outb and friends are hardware specific. The port and value arguments are in the opposite order to most DOS implementations. SEE ALSO ioperm(2), iopl(2)

Linux Home Automation Neil Cherry ncherry@comcast.net http://home.comcast.net/~ncherry/ (Text only) http://linuxha.sourceforge.net/ (SourceForge) http://hcs.sourceforge.net/ (HCS II)

Join the Discussion

Have something to add? Share your thoughts — no account required.

Didn't find your answer?

Ask the community — no account required