Setup Serial Communication

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

Hello

I'm trying to read data from the Serial Port on my Pocket PC. I open the Port using CreateFile() and the use ReadFile() to read the incoming data. So far so good. To make this work I need to set the Port Speed to 4800 Baud. So I use a DCB structure and SetCommState() to do so. But the settings do not stick. Everytime I use GetCommState() and check the Baudrate in the returned DCB it is back to 9600.

Any ideas

thank

Mike
 
Did you check SetCommState()'s result code ? Maybe you are setting one or
more of the DCB members to wrong values ?

Greetings, Christian
 
Great hint,

thanks it was right before my eyes. I overlooked that 0 means Failed and that you need to use GetLastWin32Error() to retrieve the failure code. I got it working now.

Thanks agai

Mike
 
Back
Top