Date: Thu, 12 Jun 2003 01:52:04 -0500 From: Dan Nelson <dnelson@allantgroup.com> To: Bernard Dugas <bernard.dugas@is-production.com> Cc: freebsd-questions@freebsd.org Subject: Re: how to talk to the serial and parallel ports through a C Message-ID: <20030612065204.GA47108@dan.emsphone.com> In-Reply-To: <3EE79ED4.93DB9224@is-production.com> References: <20030609175804.043AA37B405@hub.freebsd.org> <3EE65F83.9A1890FA@is-production.com> <200306112123.47587.malcolm.kay@internode.on.net> <3EE79ED4.93DB9224@is-production.com>
next in thread | previous in thread | raw e-mail | index | archive | help
In the last episode (Jun 11), Bernard Dugas said: > Not sure, but i'm using the serial port only to read and write > electrical values, to command power relays. On mickey systems, serial > drivers are far to complicated for that. > > Did anybody write a simple kernel module doing just that ? > > #include <sys/io.h> > #include <stdio.h> > > void getComValues(int adr,unsigned char *p_TxdS3, > unsigned char *p_DtrS4,unsigned char *p_RtsS7, > unsigned char *p_CtsE8,unsigned char *p_DsrE6, > unsigned char *p_RiE9,unsigned char *p_DcdE1) > { > unsigned char val3,val4,val6; > > val3=inb(adr+3); > *p_TxdS3=(val3&64)>>6 ; //récupère le bit 6 > > val4=inb(adr+4); > *p_DtrS4=val4&1 ; //récupère le bit 0 > *p_RtsS7=(val4&2)>>1 ; //récupère le bit 1 > > val6=inb(adr+6); > *p_CtsE8=(val6&16)>>4 ; //récupère le bit 4 > *p_DsrE6=(val6&32)>>5 ; //récupère le bit 5 > *p_RiE9=(val6&64)>>6 ; //récupère le bit 6 > *p_DcdE1=(val6&128)>>7 ; //récupère le bit 7 Take a look at the tty(4) manpage; you should be able to open /dev/cuaa0 (aka COM1), then use the TIOCMGET and TIOCMSET ioctls to get and set the appropriate status bits, all from userland. The comms/sredird port uses this to provide remote virtual serial ports with perfect control. -- Dan Nelson dnelson@allantgroup.com
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?20030612065204.GA47108>