From owner-freebsd-questions@FreeBSD.ORG Sat Jul 3 23:15:09 2004 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 D533216A4CE for ; Sat, 3 Jul 2004 23:15:09 +0000 (GMT) Received: from smtp3.fuse.net (smtp3.fuse.net [216.68.8.173]) by mx1.FreeBSD.org (Postfix) with ESMTP id 4CDC643D2D for ; Sat, 3 Jul 2004 23:15:09 +0000 (GMT) (envelope-from ghormann@alumni.indiana.edu) Received: from hormann.tzo.cc ([216.68.209.41]) by smtp3.fuse.net (InterMail vM.6.01.03.02 201-2131-111-104-20040324) with ESMTP id <20040703231507.ELJF27242.smtp3.fuse.net@hormann.tzo.cc> for ; Sat, 3 Jul 2004 19:15:07 -0400 Received: from hormann.tzo.cc (localhost [127.0.0.1]) by hormann.tzo.cc (8.12.9/8.12.9) with ESMTP id i63NF8bZ037896 for ; Sat, 3 Jul 2004 19:15:08 -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 i63NF7XK037893 for ; Sat, 3 Jul 2004 19:15:08 -0400 (EDT) X-Authentication-Warning: hormann.tzo.cc: ghormann owned process doing -bs Date: Sat, 3 Jul 2004 19:15:07 -0400 (EDT) From: Greg Hormann X-X-Sender: ghormann@hormann.tzo.cc To: questions@freebsd.org Message-ID: <20040703190541.K37879@hormann.tzo.cc> MIME-Version: 1.0 Content-Type: TEXT/PLAIN; charset=US-ASCII Subject: Serial communications help. 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: Sat, 03 Jul 2004 23:15:10 -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);