ArduinoGeneral

DFPlayer module and checksum

userHead Account cancelled 2021-05-09 17:52:25 574 Views1 Replies
I'm trying to create my own functions to control the DFPlayer module, since I don't use an Arduino. On the following page:
https://wiki.dfrobot.com/DFPlayer_Mini_SKU_DFR0299

... I see the following:
Image
https://drive.google.com/file/d/13fcvZt ... sp=sharing

First of all, the 0x7E is a startbyte, not a startbit, right?

Then there's the checksum. What does accumulation and verification refer to? Reading the source code, it appears that the checksum is a 16 bit unsigned, constructed by adding the bytes from Version byte to the last byte before the checksum:
Code: Select all
  uint16_t DFRobotDFPlayerMini::calculateCheckSum(uint8_t *buffer){
  uint16_t sum = 0;
  for (int i=Stack_Version; i<Stack_CheckSum; i++) {
    sum += buffer[i];
  }
  return -sum;
}
And you negate the sum. This is not mentioned in the page I linked to.

Ok. The example gives this string: 7E FF 06 09 00 00 04 FF DD EF
So the bytes that form the checksum are FF 06 09 00 00 04.
To me, the sum would be 0112. And that value negated would be FEEE! Not FFDD as the checksum is in the example.

Sorry, but the mixing of bits and bytes and missing to mention how the checksum actually is composed and instead using words like "ackumulation and verification" leaves me doubting everything on the page. Is the checksum in the example just some arbitrary bytes and not the correct ones for that particular example? Hor have I missed something crucial in how I calculated the checksum?
2021-05-11 14:26:27 The calculation method of the checksum is run by the following code.
uint16_t DFRobotDFPlayerMini::calculateCheckSum(uint8_t *buffer){
uint16_t sum = 0;
for (int i=Stack_Version; i<Stack_CheckSum; i++) {
sum += buffer;
}
return -sum;
}
There may be an error in the wiki, and we will revise it in time.
userHeadPic 347945801