问题描述
我有一个来自 u-blox.com 的 GPS,带有 USB 连接和驱动程序.驱动程序会安装一个虚拟 COM 端口,当您插入 USB 时会弹出该端口.使用超级终端,我可以观察来自 GPS 的数据流.
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 watch the flow of data from the GPS.
那我要我程序里的数据,没那么容易……
Then I want the data in my program, not so easy...
我已经实现了一些使用 serialPort 类从 GPS 读取的方法,但没有成功.我之前用 C# 编写了几个串行设备读写器,但是这个让我停止了.
I have implemented some methods using the serialPort class to read from the GPS, but am unsuccessful. I have programmed several serial device readers and writers before in C#, but this one stops me.
例如,simpleSerial 中的简单代码不会给您任何东西,除非您拔下并重新插入USB.
As an example, the simple code in simpleSerial will not give you anything unless you unplug and replug the USB.
已尝试使用 matlab 读取它,效果很好,但由于需要 GPS 数据的程序的其余部分在 c# 中,这并不能完全解决问题.
Have tried reading it with matlab, which works great, but as the rest of my program that needs the GPS data is in c#, that doesn't quite fix the problem.
serialPort 类中是否有一些我可以规避的高级 C# 事情?或者在读取 USB 串行端口时是否存在任何已知问题,我认为它就像我的 GPS 一样工作?
Is there some high level C# things going on in the serialPort class that I can circumvent? Or is there any known problems reading USB-serialports, which I assume works like my GPS?
推荐答案
从 u-blox 支持中得到这个.
Got this from u-blox support.
以下十六进制命令将强制在 GPS 模块上重置看门狗.
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
B5 62 06 04 04 00 00 00 00 00 0E 64
这是 GPS 中 ARM7 uP 的低级命令它适用于所有 u-blox GPS 接收器.
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);
它对我有用.
这篇关于与 u-blox gps 的 C# 串行通信的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!