mirror of https://github.com/arendst/Tasmota.git
Merge pull request #10709 from lonmi/development
Fix PMS3003 sensor message lenght and CRC chk
This commit is contained in:
commit
5b9a7d6c58
|
@ -98,7 +98,7 @@ bool PmsReadData(void)
|
||||||
PmsSerial->read();
|
PmsSerial->read();
|
||||||
}
|
}
|
||||||
#ifdef PMS_MODEL_PMS3003
|
#ifdef PMS_MODEL_PMS3003
|
||||||
if (PmsSerial->available() < 22) {
|
if (PmsSerial->available() < 24) {
|
||||||
#else
|
#else
|
||||||
if (PmsSerial->available() < 32) {
|
if (PmsSerial->available() < 32) {
|
||||||
#endif // PMS_MODEL_PMS3003
|
#endif // PMS_MODEL_PMS3003
|
||||||
|
@ -106,8 +106,8 @@ bool PmsReadData(void)
|
||||||
}
|
}
|
||||||
|
|
||||||
#ifdef PMS_MODEL_PMS3003
|
#ifdef PMS_MODEL_PMS3003
|
||||||
uint8_t buffer[22];
|
uint8_t buffer[24];
|
||||||
PmsSerial->readBytes(buffer, 22);
|
PmsSerial->readBytes(buffer, 24);
|
||||||
#else
|
#else
|
||||||
uint8_t buffer[32];
|
uint8_t buffer[32];
|
||||||
PmsSerial->readBytes(buffer, 32);
|
PmsSerial->readBytes(buffer, 32);
|
||||||
|
@ -116,14 +116,14 @@ bool PmsReadData(void)
|
||||||
PmsSerial->flush(); // Make room for another burst
|
PmsSerial->flush(); // Make room for another burst
|
||||||
|
|
||||||
#ifdef PMS_MODEL_PMS3003
|
#ifdef PMS_MODEL_PMS3003
|
||||||
AddLogBuffer(LOG_LEVEL_DEBUG_MORE, buffer, 22);
|
AddLogBuffer(LOG_LEVEL_DEBUG_MORE, buffer, 24);
|
||||||
#else
|
#else
|
||||||
AddLogBuffer(LOG_LEVEL_DEBUG_MORE, buffer, 32);
|
AddLogBuffer(LOG_LEVEL_DEBUG_MORE, buffer, 32);
|
||||||
#endif // PMS_MODEL_PMS3003
|
#endif // PMS_MODEL_PMS3003
|
||||||
|
|
||||||
// get checksum ready
|
// get checksum ready
|
||||||
#ifdef PMS_MODEL_PMS3003
|
#ifdef PMS_MODEL_PMS3003
|
||||||
for (uint32_t i = 0; i < 20; i++) {
|
for (uint32_t i = 0; i < 22; i++) {
|
||||||
#else
|
#else
|
||||||
for (uint32_t i = 0; i < 30; i++) {
|
for (uint32_t i = 0; i < 30; i++) {
|
||||||
#endif // PMS_MODEL_PMS3003
|
#endif // PMS_MODEL_PMS3003
|
||||||
|
@ -131,8 +131,8 @@ bool PmsReadData(void)
|
||||||
}
|
}
|
||||||
// The data comes in endian'd, this solves it so it works on all platforms
|
// The data comes in endian'd, this solves it so it works on all platforms
|
||||||
#ifdef PMS_MODEL_PMS3003
|
#ifdef PMS_MODEL_PMS3003
|
||||||
uint16_t buffer_u16[10];
|
uint16_t buffer_u16[12];
|
||||||
for (uint32_t i = 0; i < 10; i++) {
|
for (uint32_t i = 0; i < 12; i++) {
|
||||||
#else
|
#else
|
||||||
uint16_t buffer_u16[15];
|
uint16_t buffer_u16[15];
|
||||||
for (uint32_t i = 0; i < 15; i++) {
|
for (uint32_t i = 0; i < 15; i++) {
|
||||||
|
@ -141,7 +141,7 @@ bool PmsReadData(void)
|
||||||
buffer_u16[i] += (buffer[2 + i*2] << 8);
|
buffer_u16[i] += (buffer[2 + i*2] << 8);
|
||||||
}
|
}
|
||||||
#ifdef PMS_MODEL_PMS3003
|
#ifdef PMS_MODEL_PMS3003
|
||||||
if (sum != buffer_u16[9]) {
|
if (sum != buffer_u16[10]) {
|
||||||
#else
|
#else
|
||||||
if (sum != buffer_u16[14]) {
|
if (sum != buffer_u16[14]) {
|
||||||
#endif // PMS_MODEL_PMS3003
|
#endif // PMS_MODEL_PMS3003
|
||||||
|
@ -150,7 +150,7 @@ bool PmsReadData(void)
|
||||||
}
|
}
|
||||||
|
|
||||||
#ifdef PMS_MODEL_PMS3003
|
#ifdef PMS_MODEL_PMS3003
|
||||||
memcpy((void *)&pms_data, (void *)buffer_u16, 20);
|
memcpy((void *)&pms_data, (void *)buffer_u16, 22);
|
||||||
#else
|
#else
|
||||||
memcpy((void *)&pms_data, (void *)buffer_u16, 30);
|
memcpy((void *)&pms_data, (void *)buffer_u16, 30);
|
||||||
#endif // PMS_MODEL_PMS3003
|
#endif // PMS_MODEL_PMS3003
|
||||||
|
|
Loading…
Reference in New Issue