Friday, January 19, 2007

Reading the GPS port on the HTC P3300

So how do you read a COM port? After a few years of practice I got the impression that using WaitCommEvent on a thread was an assured way of catching all the characters sent by the serial port. As a matter of fact I have used the same code over and over again with the same reliable results, whether I was reading a real serial port or an emulated one over a Bluetooth connection.

Recently I had to tackle the built-in GPS serial port of the HTC P3300 and got a big surprise: my code wouldn't work! In fact, no characters were being buffered by the thread code meaning that the consuming application was receiving no data... After a close examination of what was going on in the thread code, I realised that no events were being generated by the serial port, namely the EV_RXCHAR that is used to signal that the serial port has characters to deliver. Interestingly, if you use the ReadFile API with a reasonable set ot timeouts you will be able to read data.

It is baffling to se how unreliably hardware support for common stuff like serial ports can be implemented. I'm still trying to figure out why HTC implemented it this way...

4 comments:

Unknown said...

Hi,

Thanks for mentioning this! I also have problems with the GPS for this device.

Should the default settings for the device remain unchanged? (gps program port 4, gps hardware port none, auto handling of gps).

Im using C# and the System.IO.Ports.SerialPort and got GPS working fine for other devices (WM5, PPC2003).

I dont know exactly what to change right now.. Do I have to use PInvoke and so on?

Thanks,

Best regards //Daniel

Unknown said...

I am desperately trying to obtain the API for the P3300 to programmatically adjust the screen brightness. Please could you post details of how you obtain it. Thanking you in advance.

Unknown said...
This comment has been removed by the author.
epyblast said...

Hi,

can you show us some code in order to use the GPS port of the P3300 using C#?

Thanks in advance