Skip site navigation (1)Skip section navigation (2)
Date:      Thu, 04 Dec 2003 12:06:17 +0900
From:      Rob Lahaye <lahaye@snu.ac.kr>
To:        francois@montefiore.ulg.ac.be, freebsd-questions@freebsd.org
Subject:   Re: serial port programming
Message-ID:  <3FCEA4A9.4010205@snu.ac.kr>
In-Reply-To: <3FC23FE2.5010101@run.montefiore.ulg.ac.be>
References:  <3FC23FE2.5010101@run.montefiore.ulg.ac.be>

next in thread | previous in thread | raw e-mail | index | archive | help
Jean-Marc Francois wrote:
> Sir,
> 
> 
> I've posted this question on a newsgroup, but got no response.
> Is there a cuaa-guru out there ? :-)

Sorry, but I cannot answer your questions, since I am stuck in a much
earlier stage of serial programming in FreeBSD/Unix.

I'm in a Windows-environment only. A Windowns machine can communicate
via the serial port with one of our data acquisition equipement (it's
a chemistry lab here). The serial data exchange is well documented in
the equipement manuals; e.g. 9600 baud, 8 bits, no stop bit etc. in
duplex mode receiving and sending data/commands.
The Windows C-program is directly manipulating the registers on the
16550A RS232 port, it's interrupt driven and works like a charm.

I want to this data acquisition using a FreeBSD OS. Strange enough, all
documentation I can find is related to terminal or console serial setups.
Is nobody using FreeBSD/Unix for data acquisition in research environment?

So where do I start? I'd thought a good starting point to learn how things
work, would be at first implementing:

int main()
{
  int fd = <????>;
  struct termios t;
  speed_t s1, s2;

  tcgetattr(fd, &t);
  s1 = cfgetispeed(&t);
  s2 = cfgetospeed(&t);
}

But what is fd in this context of serial port communication?

----

And eh, is this actually the right way to go for data acquisition?

Thanks,

Rob Lahaye
Seoul National University - Korea

> 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
> also).
> 
> 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 :-) ),
> JM



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?3FCEA4A9.4010205>