2014-05-07 12:13:24 +02:00
|
|
|
/*@!Encoding:1252*/
|
2014-05-08 16:44:01 +02:00
|
|
|
|
2014-05-07 12:13:24 +02:00
|
|
|
void bin_to_strhex(byte bin[], char result[])
|
|
|
|
{
|
2014-05-15 14:43:52 +02:00
|
|
|
char hex_str[17] = "0123456789ABCDEF";
|
2014-05-07 12:13:24 +02:00
|
|
|
word i;
|
|
|
|
word binsz;
|
|
|
|
|
|
|
|
binsz = elCount(bin);
|
|
|
|
if (binsz > 20)
|
|
|
|
binsz = 20;
|
|
|
|
|
|
|
|
for (i = 0; i < binsz; i++)
|
|
|
|
{
|
|
|
|
result[i * 3 + 0] = hex_str[bin[i] >> 4 ];
|
|
|
|
result[i * 3 + 1] = hex_str[bin[i] & 0x0F];
|
|
|
|
result[i * 3 + 2] = ' ';
|
|
|
|
}
|
|
|
|
|
2014-05-12 10:46:53 +02:00
|
|
|
if (elCount(bin) > 20) // trailing "..."
|
2014-05-07 12:13:24 +02:00
|
|
|
{
|
|
|
|
result[56] = '.';
|
|
|
|
result[57] = '.';
|
|
|
|
result[58] = '.';
|
|
|
|
}
|
|
|
|
result[binsz * 3 - 1] = 0;
|
2014-05-15 14:43:52 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
void hbin_to_strhex(byte bin[], char result[])
|
|
|
|
{
|
|
|
|
char hex_str[17] = "0123456789ABCDEF";
|
|
|
|
word i;
|
|
|
|
word binsz;
|
|
|
|
|
|
|
|
binsz = elCount(bin);
|
|
|
|
if (binsz > 20)
|
|
|
|
binsz = 20;
|
|
|
|
|
|
|
|
for (i = 0; i < binsz; i++)
|
|
|
|
{
|
|
|
|
result[i * 2 + 0] = hex_str[bin[i] & 0x0F];
|
|
|
|
result[i * 2 + 1] = ' ';
|
|
|
|
}
|
|
|
|
|
|
|
|
if (elCount(bin) > 20) // trailing "..."
|
|
|
|
{
|
|
|
|
result[36] = '.';
|
|
|
|
result[37] = '.';
|
|
|
|
result[38] = '.';
|
|
|
|
}
|
|
|
|
result[binsz * 2 - 1] = 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
void dbin_to_strhex(word bin[], char result[])
|
|
|
|
{
|
|
|
|
char hex_str[17] = "0123456789ABCDEF";
|
|
|
|
word i;
|
|
|
|
word binsz;
|
|
|
|
byte offset;
|
|
|
|
|
|
|
|
binsz = elCount(bin);
|
|
|
|
if (binsz > 20)
|
|
|
|
binsz = 20;
|
|
|
|
|
|
|
|
for (i = 0; i < binsz; i++)
|
|
|
|
{
|
|
|
|
result[i * 5 + 0] = hex_str[(bin[i] >> 12) & 0x0F];
|
|
|
|
result[i * 5 + 1] = hex_str[(bin[i] >> 8) & 0x0F];
|
|
|
|
result[i * 5 + 2] = hex_str[(bin[i] >> 4) & 0x0F];
|
|
|
|
result[i * 5 + 3] = hex_str[(bin[i] ) & 0x0F];
|
|
|
|
result[i * 5 + 4] = ' ';
|
|
|
|
}
|
|
|
|
|
|
|
|
if (elCount(bin) > 20) // trailing "..."
|
|
|
|
{
|
|
|
|
result[96] = '.';
|
|
|
|
result[97] = '.';
|
|
|
|
result[98] = '.';
|
|
|
|
}
|
|
|
|
result[(byte)(binsz * 2.5) - 1] = 0;
|
2014-05-07 12:13:24 +02:00
|
|
|
}
|