BrianPeek / WiimoteLib

A library for using a Nintendo Wii Remote (Wiimote) from .NET.
MIT License
101 stars 32 forks source link

System.ArgumentException in version 1.7.0 and 1.8.0 #3

Closed jhintringer closed 6 years ago

jhintringer commented 6 years ago

I got an Exception while using Wii Balance Walker and trying to connect to the Wii Balance Board.

Additional Informations:

The destination array is not big enough. Check destIndex, length and lower bound of the array. (freely translated from german)

OS: Win 10 64bit App: Wii Balance Walker v0.4 DLL: WiimoteLib v1.8.0 (resp. v1.7.0)

jhintringer commented 6 years ago

The Exception occurs in the method "ParseReadData()" in Wiimote.cs: Line 911: Array.Copy(buff, 6, mReadBuff, offset - mAddress, size);

At runtime these values are:( buff[22] , 6 , mReadBuff[7] , offset=22 - mAddress=22 , size=16 );

jhintringer commented 6 years ago

Solved this issue by using 16 as buffer size for the Wiimote Calibration:

Line 935: Wiimote.cs

private void ReadWiimoteCalibration()
{
    // this appears to change the report type to 0x31
    byte[] buff = ReadData(0x0016, 16); //  <--- change this from 7 to 16

FYI : I am using a rebranded version of the BalanceBoard from bigben.