Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Logic error in reporting connected media #63

Open
SaturdayScience opened this issue Oct 11, 2024 · 0 comments
Open

Logic error in reporting connected media #63

SaturdayScience opened this issue Oct 11, 2024 · 0 comments

Comments

@SaturdayScience
Copy link

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant