From owner-freebsd-questions@FreeBSD.ORG Wed Jun 11 23:52:06 2003 Return-Path: Delivered-To: freebsd-questions@freebsd.org Received: from mx1.FreeBSD.org (mx1.freebsd.org [216.136.204.125]) by hub.freebsd.org (Postfix) with ESMTP id 39B2B37B401 for ; Wed, 11 Jun 2003 23:52:06 -0700 (PDT) Received: from dan.emsphone.com (dan.emsphone.com [199.67.51.101]) by mx1.FreeBSD.org (Postfix) with ESMTP id 88A6A43F3F for ; Wed, 11 Jun 2003 23:52:05 -0700 (PDT) (envelope-from dan@dan.emsphone.com) Received: (from dan@localhost) by dan.emsphone.com (8.12.9/8.12.9) id h5C6q4BR032351; Thu, 12 Jun 2003 01:52:04 -0500 (CDT) (envelope-from dan) Date: Thu, 12 Jun 2003 01:52:04 -0500 From: Dan Nelson To: Bernard Dugas Message-ID: <20030612065204.GA47108@dan.emsphone.com> References: <20030609175804.043AA37B405@hub.freebsd.org> <3EE65F83.9A1890FA@is-production.com> <200306112123.47587.malcolm.kay@internode.on.net> <3EE79ED4.93DB9224@is-production.com> Mime-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: <3EE79ED4.93DB9224@is-production.com> X-OS: FreeBSD 5.1-CURRENT X-message-flag: Outlook Error User-Agent: Mutt/1.5.4i cc: freebsd-questions@freebsd.org Subject: Re: how to talk to the serial and parallel ports through a C X-BeenThere: freebsd-questions@freebsd.org X-Mailman-Version: 2.1.1 Precedence: list List-Id: User questions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 12 Jun 2003 06:52:06 -0000 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 > #include > > 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