Date: Sat, 3 Jul 2004 19:15:07 -0400 (EDT) From: Greg Hormann <ghormann@alumni.indiana.edu> To: questions@freebsd.org Subject: Serial communications help. Message-ID: <20040703190541.K37879@hormann.tzo.cc>
next in thread | raw e-mail | index | archive | help
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);
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?20040703190541.K37879>
