69,336
社区成员
发帖
与我相关
我的任务
分享
void convert(byte *bcd,byte *asc, int asc_len )
{
unsigned char flag;
unsigned char is_high, by;
int j;
is_high = !(asc_len % 2);
flag = (asc_len % 2);
bcd[0] = 0x00;
for (j=0; j<asc_len; j++)
{
by = asc[j];
if (by==' ') by = 0;
if ( !(by&0x10) && by) by += 9;
if (is_high) bcd[(j+flag)/2] = by << 4;
else
{
by&=0x0f;
bcd[(j+flag)/2] |= by;
}
is_high = !is_high;
}
return ;/*BCDLen(j);*/
}
public void convert(byte []bcd,byte []asc, int asc_len )
{
byte by;
byte flag;
boolean is_high;
int j;
is_high = ((asc_len % 2) == 0);
flag = (byte) (asc_len % 2);
bcd[0] = 0x00;
for (j=0; j<asc_len; j++)
{
by = asc[j];
if (by==' ') by = 0;
if (((by&0x10) == 0) && (by != 0))
by += 9;
if (is_high) bcd[(j+flag)/2] = (byte) (by << 4);
else
{
by&=0x0f;
bcd[(j+flag)/2] |= by;
}
is_high = !is_high;
}
return ;/*BCDLen(j);*/
}