用于校验GPS报文指令的有效性
public static bool Verify(string gpsInfo)
{
if (gpsInfo == null || "".Equals(gpsInfo))
return false;
char p = gpsInfo[0];
char c = (char)0;
int i = 1;
for (; i < gpsInfo.Length; i++)
{
p = gpsInfo[i];
if (p == '*')
break;
c ^= p;
}
if (p != '*')
return false;
return gpsInfo.Substring(++i).Equals(string.Format("{0:X}", (int) c));
}
---------------------------------------------------------
专注移动开发
Android, Windows Mobile, iPhone, J2ME, BlackBerry, Symbian
posted on 2010-05-01 10:26
TiGERTiAN 阅读(1941)
评论(0) 编辑 收藏 所属分类:
DotNet