unsigned char Buf[15]={0x3A,0x00,0x18,0x5A,0x54,0x5A,0x46,0x31,0x30,0x30,0x30,0xFE,0xBA,0x1B};
unsigned char tmp;
unsigned i;
String s;
s = "";
Buf[14]= Crc8Gen_smbus(Buf,14);
for(i=0;i<15;i++) //判断I-条件-加1
{
i==0?(s += "0x"):(s += ", 0x"); //用于判断是否在首位加入","
tmp = (Buf[i] & 0xf0)>>4;
if(tmp<10) //处理高位
s += String(char('0'+tmp));
else
s += String(char('A'+tmp-10));
tmp = Buf[i] & 0x0f;
if(tmp<10) //处理低位
s += String(char('0'+tmp));
else
s += String(char('A'+tmp-10));
}
Form1->Edit1->Text= s //C++ builder 6.0 实现
unsigned char tmp;
unsigned i;
String s;
s = "";
Buf[14]= Crc8Gen_smbus(Buf,14);
for(i=0;i<15;i++) //判断I-条件-加1
{
i==0?(s += "0x"):(s += ", 0x"); //用于判断是否在首位加入","
tmp = (Buf[i] & 0xf0)>>4;
if(tmp<10) //处理高位
s += String(char('0'+tmp));
else
s += String(char('A'+tmp-10));
tmp = Buf[i] & 0x0f;
if(tmp<10) //处理低位
s += String(char('0'+tmp));
else
s += String(char('A'+tmp-10));
}
Form1->Edit1->Text= s //C++ builder 6.0 实现