Skip to content

Play Finished messages can be misinterpreted as responses to read requests (e.g. readFileCountsInFolder) #69

@steveisme

Description

@steveisme

See second part of this discussion for details: https://forum.arduino.cc/t/continued-problems-with-dfplayer-readfilecountsinfolder-method/1420745/7

In summary, after a play the DFPlayer will send a DFPlayerPlayFinished command back to the serial port (actually, it is sending two of them - not sure why). If the user calls a read function (e.g. readFileCounts, readCurrentFileNumber, readFileountsInFolder, etc.) after the play completes and this message is sent without first clearing out these Play Finished messages then these messages are misinterpreted by the library as the data messages sent in response to the read command. To clear these messages, the use has to wait for the messages to come in with the Available() call and then call either readType() or read() so the library knows. Since there are two messages, this has to be done twice.

Since play files may be of different lengths, there is no way to know when these play finished messages will come in unless the user waits for them and then clears them. Calling any read functions after a play is therefore risky. If the user uses the hardware Busy pin to determine when play is complete, then they still need to wait and clear the Play Finished messages.

Note that this is an issue with the current DFRobot player and at least some clone players.

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