From owner-freebsd-hackers@FreeBSD.ORG Wed Jul 7 02:53:26 2004 Return-Path: Delivered-To: freebsd-hackers@freebsd.org Received: from mx1.FreeBSD.org (mx1.freebsd.org [216.136.204.125]) by hub.freebsd.org (Postfix) with ESMTP id 169E116A4CE for ; Wed, 7 Jul 2004 02:53:26 +0000 (GMT) Received: from smtp1.fuse.net (smtp1.fuse.net [216.68.8.171]) by mx1.FreeBSD.org (Postfix) with ESMTP id 63F4643D39 for ; Wed, 7 Jul 2004 02:53:25 +0000 (GMT) (envelope-from ghormann@alumni.indiana.edu) Received: from hormann.tzo.cc ([216.68.209.41]) by smtp1.fuse.net (InterMail vM.6.01.03.02 201-2131-111-104-20040324) with ESMTP id <20040707025322.KRLJ3746.smtp1.fuse.net@hormann.tzo.cc> for ; Tue, 6 Jul 2004 22:53:22 -0400 Received: from hormann.tzo.cc (localhost [127.0.0.1]) by hormann.tzo.cc (8.12.9/8.12.9) with ESMTP id i672rObZ032412 for ; Tue, 6 Jul 2004 22:53:24 -0400 (EDT) (envelope-from ghormann@alumni.indiana.edu) Received: from localhost (ghormann@localhost) by hormann.tzo.cc (8.12.9/8.12.9/Submit) with ESMTP id i672rO6T032409 for ; Tue, 6 Jul 2004 22:53:24 -0400 (EDT) X-Authentication-Warning: hormann.tzo.cc: ghormann owned process doing -bs Date: Tue, 6 Jul 2004 22:53:23 -0400 (EDT) From: Greg Hormann X-X-Sender: ghormann@hormann.tzo.cc To: hackers@freebsd.org Message-ID: <20040706225135.V32380@hormann.tzo.cc> MIME-Version: 1.0 Content-Type: TEXT/PLAIN; charset=US-ASCII X-Mailman-Approved-At: Wed, 07 Jul 2004 11:59:55 +0000 Subject: Controlling the Serial port X-BeenThere: freebsd-hackers@freebsd.org X-Mailman-Version: 2.1.1 Precedence: list List-Id: Technical Discussions relating to FreeBSD List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 07 Jul 2004 02:53:26 -0000 I'm working to develop a communications program to control a piece of vendor supplied hardware. (They only provide a control program for Windows.) I think I'm close. The device uses a RS-232 -> RS-485 convert which I belive is powered by either the RTS or DTR line of the serial port. How can I force these two lines to say powered in FreeBSD inside a C program thus providing power to the converter? I only need to write to the device. Here is what I have so far. This is my first serial port programming task, so I probably have a few mistakes. Thanks, Greg. if ((device = open("/dev/cuaa0", O_RDWR | O_NOCTTY |O_NDELAY)) == -1) { printf("Error opening port"); exit(1); } tcgetattr(device, &term); /* get current port settings */ cfsetspeed(&term, B19200); term.c_iflag |= IGNPAR; /* ignore incoming parity */ term.c_iflag &= ~(IXON|IXOFF); /* turn OFF Xon/Xoff */ term.c_cflag &= ~CSIZE; /* clear previous character size */ term.c_cflag |= CS8; /* 8 data bits */ term.c_cflag &= ~(CSTOPB|PARENB|CLOCAL); /* 1 stop bit, no output parity, enable modem ctrl */ term.c_cflag |= CRTSCTS|CRTS_IFLOW; /* RTS/CTS ctrl on */ term.c_cc[VMIN]=0; /* no min characters/read */ term.c_cc[VTIME]=0; /* no read timeout */ term.c_lflag &= ~ICANON; /* noncanonical mode */ tcsetattr(device, TCSANOW, &term);