Ticket #93 (closed defect: fixed)

Opened 5 years ago

Last modified 5 years ago

Probable error in wiimotion message decoding

Reported by: BlaiseGassend Owned by: dsmith
Priority: major Milestone:
Component: libcwiid Version: 0.6.00
Keywords: Cc:

Description

I suspect that the wiimotion message decoding in libcwiid/process.c, lines 246 to 251, r200 is incorrect.

Indeed, it is anding the high byte with with 0xFA (11111010b) instead of 0xFC (11111100). 0xFC is also consistent with  http://randomhacksofboredom.blogspot.com/2009/06/wii-motion-plus-arduino-love.html

I suspect that because of this bug, only the top 5 bits are accurate.

I believe that the following code is more accurate:

                        motionplus_mesg->angle_rate[CWIID_PHI]   = ((uint16_t)data[5] & 0xFC)<<6 |
                                                                    (uint16_t)data[2];
                        motionplus_mesg->angle_rate[CWIID_THETA] = ((uint16_t)data[4] & 0xFC)<<6 |
                                                                    (uint16_t)data[1];
                        motionplus_mesg->angle_rate[CWIID_PSI]   = ((uint16_t)data[3] & 0xFC)<<6 |
                                                                    (uint16_t)data[0];

Change History

Changed 5 years ago by dsmith

  • status changed from new to closed
  • resolution set to fixed

Good call - that's what I get for manually calculating bitfields in hex. Fixed (r201).

Note: See TracTickets for help on using tickets.