serial port programming
wegster at mindcore.net
Wed Dec 3 20:15:42 PST 2003
This may not help much, but I've done some serial port development in
the past, across a fair number of *nix platforms. Regardless of 'what
should happen,' aside from Linux and Solaris, other variants were just
that- this unfortunately is from memory (from a WHILE back on this
project), but each OS(Solaris 2.5.1/6/7/8, Linux(RH6.3-7.X), HPUX
(10.20/11.X), Irix(agh!) etc all had specific settings, both in opening
the file descriptor for the port, as well as in the flags being set in
the termios structure. There's a generic Serial Programming FAQ, but
http://www.easysw.com/~mike/serial/ (a bit more up to date), but the
problems I ran into were generally similar to what you seem to be
describing- the port seeming to be in an incorrect or unknown state,
regardless of the 'standard' way of doing things. Ultimately, I wound
up comparing the initial open(), initialization strings via write(), and
the termios struct settings to known WORKING code on the problem
platforms, #def'fed the hell out of the code, and got most of it
working. In this case you should be OK grabbing the source to minicom
and doing the same....
I may be missing something obvious in my memory here, but after that one
I had no further desire to do serial port/modem coding for quite a while
;-) (And God help me, HP developer support was almost as bad as M$!)
Jean-Marc Francois wrote:
> I've posted this question on a newsgroup, but got no response.
> Is there a cuaa-guru out there ? :-)
> Thanks !
> Jean-Marc Francois
> Université de Liège
> I got a strange problem.
> I want to send a binary string to a small device I made via /dev/cuaa0.
> The port settings should be 19200, 8N1 (no RTS/CTS, no XON/XOFF).
> Looks simple.
> I've written a small program using the standard POSIX API : tcgetattr
> and the like.
> When I launch my program, it doesn't work (well, it works with Linux
> but not with FreeBSD).
> If I first launch minicom (and ask it to setup the serial port), let
> it in the
> background and launch my program, it works.
> The problem is that the dump of the 'stuct termios' my program is
> using with or without
> minicom is the same, so that's not the problem (stty -f /dev/cuaa0
> gives the same output
> I thought all the serial settings were in this structure; where am I
> wrong ?
> Thank if you can help (if you can't, thanks for reading anyway :-) ),
> #> stty -f /dev/cuaa0
> speed 19200 baud;
> lflags: -icanon -isig -iexten -echo
> iflags: -icrnl -ixon -ixany -imaxbel ignbrk -brkint
> oflags: -opost -onlcr -oxtabs
> cflags: cs8 -parenb clocal
> Dump of struct termios :
> c_iflag : 0x1
> c_oflag : 0x0
> c_cflag : 0xcb00
> c_lflag : 0x0
> c_cc : 0x4
> c_cc : 0xff
> c_cc : 0xff
> c_cc : 0x7f
> c_cc : 0x17
> c_cc : 0x15
> c_cc : 0x12
> c_cc : 0x8
> c_cc : 0x3
> c_cc : 0x1c
> c_cc : 0x1a
> c_cc : 0x19
> c_cc : 0x11
> c_cc : 0x13
> c_cc : 0x16
> c_cc : 0xf
> c_cc : 0x1
> c_cc : 0x5
> c_cc : 0x14
> c_cc : 0xff
> c_ispeed : 0x4b00
> c_ospeed : 0x4b00
> freebsd-questions at freebsd.org mailing list
> To unsubscribe, send any mail to
> "freebsd-questions-unsubscribe at freebsd.org"
More information about the freebsd-questions