15,467
社区成员
发帖
与我相关
我的任务
分享
int EncoderData(CStringArray Src,CStringArray OutArray)
{
int counts = Src.GetCount();
if (counts == 0)
{
return -1;
}
else
{
for (int i=0;i<counts-2;i++)
{
if (i>4)
{
//没有获取到信息
if (Src[i]=="88")
{
return 1;
}
else
{
if (Src[i]=="81")
{
continue;
}
else
{
if (Src[i]=="7f")
{
//数量
CString temp = Src[i+1];
//数值
CString dataSrc = Src[i+2];
int x=0;
sscanf_s(temp,"%x",&x);
for (int m=0;m<x;m++)
{
OutArray.Add(dataSrc);
}
//跳过后面的两个
i+=2;
}
else
{
OutArray.Add(Src[i]);
}
}
}
}
}
}
return 0;
}
//////////////////////////////////////////////////////////////////////////
//拼接转换(未完成)
//
//////////////////////////////////////////////////////////////////////////
int GetValue(CStringArray Src,CStringArray OutData)
{
if (Src.GetCount() == 0)
{
return -1;
}
else
{
int m=0;
unsigned long x;
for (int i=0;i<Src.GetCount();i++)
{
char Nums[100]="";
m++;
if (i%4 == 0)
{
char temp[20]="";
strcat_s(temp,(LPSTR)(LPCTSTR)Src[m-3]);
strcat_s(temp,(LPSTR)(LPCTSTR)Src[m-2]);
strcat_s(temp,(LPSTR)(LPCTSTR)Src[m-1]);
strcat_s(temp,(LPSTR)(LPCTSTR)Src[m]);
sscanf_s(temp, "%x", &x);
//转换成温度
}
}
}
return 0;
}