Menu

#1 swap_nibbles() function is incorrect

v1.0_(example)
open
nobody
None
5
2004-01-10
2004-01-10
No

The function int swap_nibbles(unsigned char byte) in the
source file smsc_at2.c will never return correctly
swapped nibbles.

The existing code is :
return( ( byte & 15 ) * 10 ) + ( byte >> 4 );

and should actually be
return( ( byte & 15 ) * 0x10 ) + ( byte >> 4 );

This is probably a typo, and will take very little doing to
fix it. I dont know how this would affect the rest of the
code - I havent tested it as yet.

I am surprised at how the code did work in spite of this
mistake tho'! Or perhaps it didnt work correctly, but
being suffeciently fault tolerant, it performed at least
part of its basic function...

Discussion


Log in to post a comment.