GPS数据包如何循环解析
求大神帮忙看下如何实现遍历所有编辑框的中数据,实现循环解析GPS的数据!以下代码仅能实现一行数据的解析!数据源:
$GPRMC,014254.70,A,2603.613111,N,11910.693806,E,0.364,273.16,230719,,,A*69
$GPGGA,014254.70,2603.613111,N,11910.693806,E,1,12,1.13,4.50,M,9.90,M,,*64
$GPRMC,014254.80,A,2603.613113,N,11910.693794,E,0.370,272.77,230719,,,A*63
$GPGGA,014254.80,2603.613113,N,11910.693794,E,1,12,1.13,4.50,M,9.90,M,,*6D
$GPRMC,014254.90,A,2603.613115,N,11910.693792,E,0.368,271.60,230719,,,A*6E
$GPGGA,014254.90,2603.613115,N,11910.693792,E,1,12,1.13,4.60,M,9.90,M,,*6F
$GPRMC,014255.00,A,2603.613123,N,11910.693764,E,0.365,273.78,230719,,,A*6C
$GPGGA,014255.00,2603.613123,N,11910.693764,E,1,12,1.13,4.60,M,9.90,M,,*6B
//GPS数据解析
split split;//切分函数类
CString buffString;
int nlinecout1 = (m_EditRev.GetLineCount() - 1);//获取行数
for (int i = 0; i < nlinecout1; i++)
{
int len = m_EditRev.LineLength(m_EditRev.LineIndex(i));
buffString = m_strReceive;//编辑框值变量,原始数据保存在该变量
split.SetSplitFlag(_T(","));//切分标志
split.SetSequenceAsOne(TRUE);
split.SetData(buffString);
CStringArray array;
split.GetSplitStrArray(array);//将切分的数据存入数组中
//判断读取的GPS信息的类型
if (array = "$GPRMC")
{
m_strJD = array.Left(2) + "." + array.Mid(2, 2) + array.Right(6) ;
m_strWD = array.Left(3) + "." + array.Mid(3, 2) + array.Right(6) ;
}
UpdateData(false);
}
之前尝试用GetLine()循坏获取EDIT控件中的每一行的内容,但是每一行的正确数据后面总带有乱码!
请大神在代码上指点一下! 看上去像北斗的。 mqcake 发表于 2019-7-24 15:38
看上去像北斗的。
您知道这方面怎么循环解析吗? 你不是有个for循环吗?获取不到总的行数吗? mqcake 发表于 2019-7-24 16:14
你不是有个for循环吗?获取不到总的行数吗?
不行,有问题,只能获取到第一行的数据
页:
[1]