Skip to content

Logic error in reporting connected media #63

Description

@SaturdayScience

In void DFRobotDFPlayerMini::parseStack() the media online reporting code is
case 0x3F: if (_handleParameter & 0x01) { handleMessage(DFPlayerUSBOnline, _handleParameter); } else if (_handleParameter & 0x02) { handleMessage(DFPlayerCardOnline, _handleParameter); } else if (_handleParameter & 0x03) { handleMessage(DFPlayerCardUSBOnline, _handleParameter); } break;

If a USB and SD are both online the last else if is unreachable because of the bitwise & testing. Currently it would only report the USB as online.

I think each test should be if (_handleParameter == 0x0?) where ? is 1, 2 or 3.

I thought about reversing the order of tests, putting if (_handleParameter == 0x03) first. But that would return non zero i.e. true if either or both USB and/or SD were online.

I leave the matter for your review; I suspect very few users employ both USB and SD so the library has worked for us.
Thanks.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions