C# serial communication with u-blox gps

前端 未结 9 1758
爱一瞬间的悲伤
爱一瞬间的悲伤 2021-01-06 11:12

I have a GPS from u-blox.com with a USB-connection and driver. The driver installs a virual COM port that pops up when you plug the USB in. Using a hyperterminal I can then

相关标签:
9条回答
  • 2021-01-06 11:38

    I have sucessfully used the SerialPort class in .Net 2 also with gps on a virtual comport. It seems your virtual comport driver is slightly off. If you can't locate a newer driver I would suggest you call the WinAPI functions for reading the serial port.

    Take a look at this code for instance: http://www.codeproject.com/KB/system/SerialPortComm.aspx

    0 讨论(0)
  • 2021-01-06 11:39

    Not sure if this is the same issue you are experiencing.

    I noticed that if the RX_FLAG is used with SetCommMask API, the GetOverlappedResult does not seems to returns after the first WaitCommEvent. It will appears that the API is waiting for something to happens until the com mask is reset (At least that is what I observed). However, there is still some data received if you go and read the port after which, the device does not respond any more. In this scenario, you would need to unplug and replug the device to get it to respond again.

    However, if the RX_CHAR is used instead, the GetOverLappedResult returns with the correct status and the device works as per normal.

    Hope this information helps.

    0 讨论(0)
  • 2021-01-06 11:41

    Got this from u-blox support.

    The following hex command will force a watchdog reset on the GPS module.

    B5 62 06 04 04 00 00 00 00 00 0E 64

    this a low level command for the ARM7 uP in the GPS It works with all u-blox GPS receiver.

    byte[] data = new byte[]{0xB5, 0x62, 0x06, 0x04, 0x04, 0x00,
                             0x00, 0x00, 0x00, 0x00, 0x0E, 0x64}; 
    sp.Write(data, 0, data.Length);
    

    It works for me.

    0 讨论(0)
  • The problem is that there is a bug in either the USB Serial port drivers or in Microsofts implementation of their SerialPort classes. I have had the exact same issues with USB to Serial adapters using chips made by Prolific (and hence drivers by Prolific).

    I have not been able to narrow down the issue exactly but now that the .NET Framework source-code is available I will be trying to step into SerialPort and see what the problem is exactly.

    A work around is to use a different Serial access class. Before .Net 2.0 I had written a SerialStream class and for some reason it seems to work fine with these same USB to Serial Adapters that the SerialPort class will not work with.

    You can grab my class at http://www.6bit.com/download/SerialStream.zip I've provided this same code to some fellow GPS programmers over the years and they have also had success with it.

    0 讨论(0)
  • 2021-01-06 11:43

    Got the same problem with a U-Blox GPS but managed to solve it by enabling the DTR and RTS properties. Now I can read the NMEA sentences just fine. One problem I found is that I still have to remove and replug my GPS to the USB port from time to time. Hope it helps.

    0 讨论(0)
  • 2021-01-06 11:48

    If you can communicate with the GPS using HyperTerminal then in principle there's no reason why you shouldn't be able to in C#. Are you sure you've configured the serial port correctly, particularly the baud rate, data bits, stop bits, parity, and flow control settings?

    You could use SysInternals PortMon tool to look at the low-level I/O and compare how HyperTerminal and your C# program each configure the serial port. Maybe this will provide some useful information.

    0 讨论(0)
提交回复
热议问题