Serial port on embedded

Hello,

I have an application which receives data from serial port. It works fine when I start the PC with the CD installation, or booting directly from the CD. But when I boot it with the image I created, it doesn’t work fine. It goes right at 19200 baud, but not at 115200, or other speeds higher than 19200. It looses bytes. My image uses the same driver as the other installations (devc-ser8250), so I cannot understand what happens. Thanks.

Grillo Solitario

Hi,

Check your devc-ser8250 options. You need to supply -b19200. The default baudrate is set to 57600.

Freddy

What I use to do is to change the serial port configuration in my embedded system using the stty command in the .profile file of the user.

I have had some problems to change the baudrate directly in the image file (it must be possible), but doing in this way is easier and if you want to change the baudrate or to use a different baudrate or configuration for another user, you dont need to recompile the image again.

Also test the parameters of your serial port with stty (specially flow control options).

I hope it helps. Saludos.

Hi again,

The problem is not the baud rate. My application changes it its own, and I know it does it right.

This morning I’ve been testing with the QNX installed from the CD, and I got surprised. The program worked fine when I str¡arted it from a photon terminal, but failed when I tried to run directly from the command line.

I mean, I boot the PC (nophoton start), I run the application, and it fails. I type ‘ph’, Photon starts, I open a shell, I run the program, and it works! Obviously if I logout from photon it fails again. I cannot understand why it happens this way…

Thank you. Gracias.

Hello,

I have new data about my problems with serial ports. I have measured the average loss of input characters: if run within the graphical interface it is very low, perhaps 1 out of 500. However, if run from the console, I loose about 3% of input characters.I have also tried to run my application using a hard disk instead of a CompactFlash, and I have obtained the same results. If the same disk is used with a desktop PC, I cannot reproduce the problem, so it seems somewhat related to the specific hardware I am using: A PCM-3350F PC-104 CPU board from Advantech. Oddly enough, the processor in the desktop seems to be of equal or lower performance.

       It seems absurd that the application looses much more characters without the graphical interface. Does anyone know of a reason for this to happen?

      Thank you.

Are you using the serial port 2 of the PCM-3350?
I needed to change to serial port 1 because I have got many problems in the reception of data with serial port 2 in this card.

The electrical levels of serial port 2 (RS232, RS485) of PCM-3350 are selected in the BIOS. In my cards (the reception of serial port 2 is deconfigured) and I need to enter in the BIOS (without changing anything) to be able to receive data again (Really strange).

I havent investigated too much because after changing to serial port 1 I havent got any problem.

I dont know if someone have got also these kind of problems in this card.
It can also help me.

I hope it helps.

Hello,

I’ve used both ser1 and ser2, and they work the same. I’ve dond ethe same as you with the bios, but the system doesn’t care. I even have changed the threads priority, but it solves nothing…

Anyway it’s good to know that the PCM-3350 doesn’t have the best serial ports in the world…

I cannot understand why the serial port of an embedded system goes wrong with an specific OS. Serial is not a new port, and it’s used in many applications.

Thank you again. Gracias :- >>

I tested the above-mentioned problem on receiving in COM2 and find no problems. Wrote a small software to receive serail ASCII data from a Windows based terminal (pc_comm: available from www.moxa.com). Sent 1000 sets of ascii data (with pattern “$TEST”) at both 9600 and 115200 . My QNX software is able to receive on COM2 and log all 1000 sets of data without any loss.

Having said this, the software architecture to check adn receive serial data is very important, that’s where all the header and checksums will come into play when doing protocol design. It would be dangerous and wishful thinking to want to design a critical real-time system on the assumption that all data sent from an external system will be 100% received by the system and acted upon. ERROR handling and recovery mechanism must be built into the architecture for robustness.

Serial data is based upon a fixed baud rate and henceforth, it is not difficult to calculate how much data u can send and receive through the RS232 channel before data integrity becomes questionable.

Adding on to the above. I realised that I did the followingin my script file to ensure that the serial por tis in RAW mode.

stty +raw < /dev/ser2

and I guess that is why it works seamlessly for me. I tested out the PCM-3350 by removing the above, i.e. to default of EDIT mode, and the receive problem is evident. FYI. Conclusion: Force the port to RAW mode before doing any receiving on /dev/ser2.

I set RAW mode as you said, when I read your comment. But I’m afraid it’s still the same.

I’ve made sure that my application doesn’t fail when receiving wrong data. And I’m quite sure that the 97% of messages it receives are enough for it to work properly. Anyway, nobody likes loosing information :- >>

Thank you :- >>

falcon_sg, grillosolitario:

Could you please tell me the BIOS version you are using and the date??
It is provided in the sequence boot-up. I would like to be sure if your BIOS version is the same one that I have. It would be a help to me.

This problem with serial port 2 has happened to me after some time using the card and I think also not in all the cards. The manufacturer told me that it was possible that the BIOS version could have a bug or the cards could have a failure (There are two BIOS version that can be downloaded in the Advantech webpage).

Are you using RS232 or RS485 for serial port 2??

Thank you very much.

Hello. There it goes.

BIOS VERSION: 1.13
RS232 serial port.

Please, let us know if you solve something (and how :- >> )

Bye. Cuidese.

forgot the date: 02/18/2004 :- >>

version 1.12

downloaded from this link:

advantech.com.tw/support/sr_ … =1%2DB5BX5

I tried using my own software and it’s working. Similarly, i tried using qtalk and it works fine too… As a matter of fact, it is Qtalk that gave me the inspiration to set to +raw using stty. cos’ i noticed that my default is +edit whilst when i use qtalk, the mode is “automatically” switched to +raw by the Qtalk software. I can;t provide u with the software as I wrote it for customer and includes some other codes…

Just to add… I use RS232 and use the pc-comm emulator software hosted in windows. U can download pccomm from this link:

moxa.com/drivers/pcommlite/win2k/PComm2k.zip