Click here to Skip to main content
15,887,867 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
I've been updated my a VxWorks application. The target's RS-232 is connected to touch panel. For some reason, I must know its baud rate. I consulted the web and found only the way to set baud rate:
ioctl (fPipe, FIOBAUDRATE, 19200);

In the file (ioLib.h) containing FIOBAUDRATE, I can't find any command which looks like getting baud rate.

I found two definitions at sioLib.h: SIO_BAUD_GET & SIO_BAUD_SET, but SIO_BAUD_GET seems not working at get baud rate.

How can I do to get baud rate of my current RS-232 setting?

What I have tried:

I tried to run the ways as stated above and searched at my header files, found nothing able to answer my question.
I googled this problem but in vain.
Posted
Updated 16-May-17 0:04am
v2
Comments
Richard MacCutchan 16-May-17 5:56am    
As far as a recall there is no way to get a baud rate on a serial channel. The usual method of working with unknown rates is to try different settings and echo some data to see if the return value is valid.
Stan Huang 16-May-17 5:59am    
It's my idea too. I'm very pleased to get kind of approval here.

1 solution

There seems to be no general documented method. It might be supported for specific serial drivers. So you have to check the documentation of the used driver / interface. Alternatively try using the SIO_BAUD_GET ioctl call. The result should indicate if it is supported by the driver.

As last resort you can try to access the serial interface hardware directly at port level and read out the settings. But that requires reading the data sheet of the interface (e.g. external chip or SoC).

But why do you need the current setting?
For proper communication you have to set it anyway if it is not matching. So just set it to the required rate. And once you have set the rate successfully you know the current setting.
 
Share this answer
 
Comments
Stan Huang 16-May-17 20:30pm    
1. About referring driver/interface doc.: I searched the file containing FIOBAUDRATE and no commands look like getting baud rate.
2. About SIO_BAUD_GET: I did it and found error was returned, which means it's not supported.
3. About reading h/w register: it could be a solution.
4. About the reason why to read the setting: the codes from others are too messy. It'll take long time to find the original setting point. Besides, I just would like to double confirm it. I was assigned to update the old codes for new touch panel which baud rate is well known, but the old panel's baud rate must be explored for the data was lost. Reading baud rate directly could save time if it's possible.
Jochen Arndt 17-May-17 2:44am    
To find it in old code you can search the source files for FIOBAUDRATE. Linux has the grep command for such searches. It also available for Windows when installing the UnxUtils (unxutils.sourceforge.net).

To explore the old baud rate you can use a logic analyser or an oscilloscope (e.g. one that can hold samples in memory) connected to a serial line.
Stan Huang 17-May-17 5:03am    
1. About searching FIOBAUDRATE: Sounds a good idea, but unfortunately I can't find any occurrence of it at the source codes. I can't find the original designer to explain it either. I only found its occurrence at source codes of serial driver (case FIOBAUDRATE). It's obvious that it's code to serve baud rate setting.
2. Measure it with analyzer or oscilloscope: I'll have the HW engineer to do it.
Jochen Arndt 17-May-17 5:07am    
Have you also searched for SIO_BAUD_SET or checked if there is an ioctl call that sets multiple parameters using a struct?
Stan Huang 17-May-17 21:41pm    
1. About SIO_BAUD_SET: I can't find codes in the application program calling ioctl using SIO_BAUD_SET command except the one which I added but found error return and another which is for a serial port other than the one I am interested in. I wonder the difference between SIO_BAUD_SET & FIOBAUDRATE. I browsed lots of articles about either one but no explanation about their difference.
2. I found some code snippet calling ioctl with command SIO_BAUD_SET in folder of driver (wind/target/src/...). I need some time to explore it. I am not sure it's run at my target image. This is area I am not familiar with. Update it later.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900