UNIX Socket FAQ

A forum for questions and answers about network programming on Linux and all other Unix-like systems

You are not logged in.

#1 2007-02-08 10:46 PM

palexo
Member
Registered: 2007-02-08
Posts: 5

Re: Using non standard baudrate 28800 with rs232

Hi,
can somebody help me with this one?
I have to configure rs232 write/read inside a C program.
I'm using the termios.h (POSIX)
The problem is that the only baudrate that works for me is 28800 and
it is not supported any more from this driver. 
So I can't write :

cfsetispeed(&options, B28800);
cfsetospeed(&options, B28800);

At least for the version of termios.h that I have on my SuSe Linux 10.1
I would really appreciate any help.
Thanks!

Offline

#2 2007-02-09 02:43 PM

RobSeace
Administrator
From: Boston, MA
Registered: 2002-06-12
Posts: 3,826
Website

Re: Using non standard baudrate 28800 with rs232

What exactly is connected to this serial port?  Are you sure the port must actually
be driven at this exact baud rate?  Have you tried others?

Offline

#3 2007-02-09 02:51 PM

palexo
Member
Registered: 2007-02-08
Posts: 5

Re: Using non standard baudrate 28800 with rs232

Oh there is a card connected there which is commanding a robot by a wireless connection. Yes I am sure. I've tried all speeds defined in the termios.h, then I read somewhere in the documentation that the stupid robot is not receiving the command if the speed is other than 28800. 
It is working perfectly under Windows. The porblem is that I have to make it also work under linux.

Offline

#4 2007-02-09 03:14 PM

RobSeace
Administrator
From: Boston, MA
Registered: 2002-06-12
Posts: 3,826
Website

Re: Using non standard baudrate 28800 with rs232

Well, maybe playing around with "setserial" and the "spd_cust", "baud_base", and
"divisor" settings might get you somewhere (in combination with a B38400 from
your app)...  I'm not sure, though...

Offline

#5 2007-02-10 07:41 PM

palexo
Member
Registered: 2007-02-08
Posts: 5

Re: Using non standard baudrate 28800 with rs232

Well I've never thought about this. This is really an interesting idea. I've never used the setserial but I've just googled around and it seems to be a possible solution. At least I have something to try.
Thank you for this tip!

Offline

#6 2007-02-11 02:00 AM

palexo
Member
Registered: 2007-02-08
Posts: 5

Re: Using non standard baudrate 28800 with rs232

So I'm adding this single line to my Program:

system("/bin/setserial /dev/ttyS1 spd_cust baud_base 115200 divisor 4");

prior to opening the port
and setting the speed like:

cfsetispeed(&options, B38400);
cfsetospeed(&options, B38400);

It's giving me the hope it will work :smile:
Although I won't be able to test it till Tuesday...

Offline

#7 2007-02-11 05:34 PM

RobSeace
Administrator
From: Boston, MA
Registered: 2002-06-12
Posts: 3,826
Website

Re: Using non standard baudrate 28800 with rs232

If this works, you might want to grab the source for "setserial" so you can simply
do what it does in your own code, rather than have to use system() to call it, which
is a bit of a kluge...  I'm pretty sure it just uses ioctl(TIOC[GS]SERIAL)...

Offline

#8 2007-02-20 10:20 PM

palexo
Member
Registered: 2007-02-08
Posts: 5

Re: Using non standard baudrate 28800 with rs232

I've tested it a couple of times and it really worked.
RobSeace one more time thank you very much for your suggestion
it really made my day.
I know it is not so exquisite using the "system" but it is not so clear to me how to make it else and I don't think I'll take the path of using this as an internal command, because I'm already fed up with that project and can't wait to finish it :smile:

Offline

Board footer

Powered by FluxBB