|
-
February 24th, 2010, 10:48 AM
#13
Re: getting binary output from a magnetic writer
is there a diffrence between
/*
* Print a buffer as reasonably formatted raw bits.
*/
void dump_buffer(const unsigned char *buffer)
{
int i;
for (i=0; i<MAX_CARD_LEN; i++)
{
print_bits(*(buffer +i));
printw(" ");
if ((i + 1) % BYTES_PER_LINE == 0)
{
printw("\n");
}
else if ((i + 1) % 4 == 0)
{
printw(" ");
}
}
}
/*
* Print a byte as a string of eight bits.
*/
void print_bits(unsigned char c)
{
int i;
for (i = 0; i<8; i++)
{
printw("%c", (c&0x80)?'1':'0');
c <<= 1;
}
}
/*
* Print the header.
*/
and
int
dumpbits (uint8_t * buf, int len)
{
int bytes, i;
for (bytes = 0; bytes < len; bytes++) {
/* for (i = 0; i < 8; i++) { */
for (i = 7; i > -1; i--) {
if (buf[bytes] & (1 << i))
printf("1");
else
printf("0");
}
}
printf ("\n");
return (0);
}
Tags for this Thread
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|