problem with differernt baudrates

Feb 7, 2011 at 9:33 AM

I have tried this implementation on my WinCE device, but it seems to correctly work only on baudrate set to 9600.

Any other rate and I receive only mess. Does anyone else have this problem? Have you tested different speeds, or

is it something else (possibly with my device).

 

Thanks

 

Roman

Feb 7, 2011 at 1:57 PM

After some more testing and oscilloscop measuring I have found out that the baudrate is always set to 9600 no matter what I try to set.

Feb 7, 2011 at 2:16 PM

One more update:

command

m_CommAPI.SetCommState(hPort, dcb);

is returning false so I have done some more checking and Marschal.GetLastWin32Error is returning 87, which is

ERROR_INVALID_PARAMETER
87 (0x57)

The parameter is incorrect.

Coordinator
Feb 8, 2011 at 11:02 AM

I'm usingthe library at 115200 without any problems.  Are you certain your driver properly runs other than 9600?

Feb 8, 2011 at 11:12 AM

Yes, until today I have been using microsoft implementation and that one was able to set different speeds without any problem (it had some other problems but thats for another discussion).

And also if I write native application I can set different speeds. So I guess than it will be something with the windows ce..

Jan 24, 2012 at 2:59 PM

 

Hi every one first post here so here goes......

I have the same issue and looked at the configuration within OpenNETCF and notice that the dcb variable was not being retrieved from the serial port before being set.  It is good practice to fully populate dcb variable first and then do your required changes as this accounts for any driver differences that you may not have noticed.

I added in the following code to the port config in the OpenNETCF.IO.Serial.Port class function Open()

 

//make sure all setting are populated with initial values 

m_CommAPI.GetCommState(hPort, dcb);

Just before setting of the dcb structure to the user requirements.

This fixed the issue of baud rate staying at 9600 on my Windows CE 6.0 SOM enviroment.  Hope this helps everyone!

Please could Chris change the Open() function source code.

 

Regards

Rick

Jun 14, 2013 at 7:13 AM
Thanks tricky(Rick) for the solution of adding 'm_CommAPI.GetCommState(hPort, dcb);' before the code:
"dcb.BaudRate = (uint)portSettings.BasicSettings.BaudRate;
dcb.ByteSize = ........................".
. Now baudrates other than 9600(tested 19200) works fine on my Windows CE 6.0 R3 device.

Strangely the 'm_CommAPI.SetCommState(hPort, dcb);' call still returns 87 as error-code!

Vijay.