如何在Windows CE 6.0应用程序中通过串口读取GPS数据? [英] How to read GPS data through Serial port in Windows CE 6.0 application?

查看:133
本文介绍了如何在Windows CE 6.0应用程序中通过串口读取GPS数据?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如何通过Windows CE 6.0应用程序中的串口读取GPS数据?

How to read GPS data through Serial port in Windows CE 6.0 application?

推荐答案

您好,



首先创建一个gps处理程序,如下所示



Hi there,

Create a gps handler first, as follows

int GpsHandler = CreateFile("COM8:", GENERIC_READ | GENERIC_WRITE, 0, 0, OPEN_EXISTING, 0, 0);





其中,COM8:=你的设备gps端口(会有所不同)



1.然后将gps端口超时值设置为ReadIntervalTimeout。

2.然后为gps端口设置波特率,停止位,奇偶校验和字节大小。



最后按需要的间隔你需要从gps端口读取数据:



where, COM8: = your devices gps port(will be different)

1.Then set the gps port timeouts value like ReadIntervalTimeout.
2.Then set the Baud rate,stop bits,parity and bytesize, for the gps port.

At last as desired interval you need to read the data from the gps port:

static byte[] ByteArray= new byte[1024];







ReadFile(GpsHandler, ByteArray, 1024, ref RedItems, 0);



这个红色数据将是一个字节值,将其更改为这样的字符串




this red data will be a byte value ,change it to a string like this

string gpsdata = System.Text.Encoding.ASCII.GetString(ByteArray, 0, RedItems);





结果:gpsdata将包含你的gps相关数据



Result: gpsdata will have your gps related data


这篇关于如何在Windows CE 6.0应用程序中通过串口读取GPS数据?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆