On Tuesday 21 March 2006 07.39, Lanslott Gish wrote:
> On 3/17/06, Lanslott Gish <[EMAIL PROTECTED]> wrote:
> > On 3/16/06, Daniel Ritz <[EMAIL PROTECTED]> wrote:
> > that just can't be right. you probably mean
> > +       *y = pkt[3] | ((pkt[4] & 0x0F) << 8);
> >
> > otherwise you mask out bits 4-7. but you want to limit it to 12 bits...
> > (btw. no need for the & 0xFF mask since *pkt is char)
> >
> >
> > you are right, sorry for my fault. the truely way is
> >
> > +       *x = (pkt[1] & 0xFF) | ((pkt[2] & 0x0F) << 8);
> > +       *y = (pkt[3] & 0xFF) | ((pkt[4] & 0x0F) << 8);
> >
> > still need 12 bits( 0x0FFF) and the masks to avoid get negative.
> >

ok, ok, there is a bug. but the mask is still not needed. the
real bug is that pkt is of type char instead of unsigned char.
so a simple cast would be enough:
         +       *x = (unsigned char) pkt[1] | ((pkt[2] & 0x0F) << 8);

but i changed the whole thing to unsigned char all over the place.
it's better anyway.

rgds
-daniel


-------------------------------------------------------
This SF.Net email is sponsored by xPML, a groundbreaking scripting language
that extends applications into web and mobile media. Attend the live webcast
and join the prime developer group breaking into this new coding territory!
http://sel.as-us.falkag.net/sel?cmd=lnk&kid=110944&bid=241720&dat=121642
_______________________________________________
linux-usb-devel@lists.sourceforge.net
To unsubscribe, use the last form field at:
https://lists.sourceforge.net/lists/listinfo/linux-usb-devel

Reply via email to