-
Notifications
You must be signed in to change notification settings - Fork 143
Description
When acknowledge enabled some modules may send only response and no acknowledge.
For example "MH2024K-24SS". Library behaves badly in this and similar situations.
The problem code is here:
case 0x4F:
_isAvailable = true;
// _handleType=TimeOut-1; // placeholder
break;
Here _handleType will have previous (uninitialized) value, in case the previous value was TimeOut then the timeout will be received. Problem is generated here:
bool DFRobotDFPlayerMini::waitAvailable(){
_isSending = true;
while (!available()){
delay(0);
}
return _handleType != TimeOut;
}
By forcing the standard example to run myDFPlayer.readFileCountsInFolder(1); the code here will return TimeOut two times:
if (myDFPlayer.available()) {
printDetail(myDFPlayer.readType(), myDFPlayer.read()); //Print the detail message from DFPlayer to handle different errors and states.
}
Result of myDFPlayer.readFileCountsInFolder(1); will be -1.
Correct answer should be number and one TimeOut value.
Here goes the command denoted as "<" and response from MH2024K-24SS denoted as ">" and response from YX5200-24SS denoted as "="
Query number of files in folder 1 (with acknowledge):
< 0x7E 0xFF 0x06 0x4E 0x01 0x00 0x01 0xFE 0xAB 0xEF
> 0x7E 0xFF 0x06 0x4E 0x00 0x00 0x05 0xFE 0xA8 0xEF
= 0x7E 0xFF 0x06 0x41 0x00 0x00 0x00 0xFE 0xBA 0xEF 0x7E 0xFF 0x06 0x4E 0x00 0x00 0x05 0xFE 0xA8 0xEF
The code inside void DFRobotDFPlayerMini::parseStack() should be reanalyzed and rewritten to avoid usage of uninitialized variables. My _handleType=TimeOut-1; is just a placeholder.