mirror of
https://github.com/arendst/Tasmota.git
synced 2025-08-03 07:57:43 +00:00
parent
ffd36e0b2d
commit
d0502c1af8
@ -1,6 +1,7 @@
|
|||||||
/* 6.5.0.14 20190602
|
/* 6.5.0.14 20190602
|
||||||
* Change webserver HTML input, button, textarea, and select name based on id
|
* Change webserver HTML input, button, textarea, and select name based on id
|
||||||
* Fix webserver multiple Javascript window.onload functionality
|
* Fix webserver multiple Javascript window.onload functionality
|
||||||
|
* Fix PZem startup issue (#5875)
|
||||||
*
|
*
|
||||||
* 6.5.0.13 20190527
|
* 6.5.0.13 20190527
|
||||||
* Add command SetOption38 6..255 to set IRReceive protocol detection sensitivity mimizing UNKNOWN protocols (#5853)
|
* Add command SetOption38 6..255 to set IRReceive protocol detection sensitivity mimizing UNKNOWN protocols (#5853)
|
||||||
|
@ -36,6 +36,24 @@
|
|||||||
#include <TasmotaModbus.h>
|
#include <TasmotaModbus.h>
|
||||||
TasmotaModbus *PzemAcModbus;
|
TasmotaModbus *PzemAcModbus;
|
||||||
|
|
||||||
|
/*
|
||||||
|
uint16_t PzemCalculateCRC(uint8_t *buffer, uint8_t num)
|
||||||
|
{
|
||||||
|
uint16_t crc = 0xFFFF;
|
||||||
|
for (uint8_t i = 0; i < num; i++) {
|
||||||
|
crc ^= buffer[i];
|
||||||
|
for (uint8_t j = 8; j; j--) {
|
||||||
|
if ((crc & 0x0001) != 0) { // If the LSB is set
|
||||||
|
crc >>= 1; // Shift right and XOR 0xA001
|
||||||
|
crc ^= 0xA001;
|
||||||
|
} else { // Else LSB is not set
|
||||||
|
crc >>= 1; // Just shift right
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return crc;
|
||||||
|
}
|
||||||
|
*/
|
||||||
void PzemAcEverySecond(void)
|
void PzemAcEverySecond(void)
|
||||||
{
|
{
|
||||||
static uint8_t send_retry = 0;
|
static uint8_t send_retry = 0;
|
||||||
@ -51,6 +69,7 @@ void PzemAcEverySecond(void)
|
|||||||
if (error) {
|
if (error) {
|
||||||
AddLog_P2(LOG_LEVEL_DEBUG, PSTR(D_LOG_DEBUG "PzemAc response error %d"), error);
|
AddLog_P2(LOG_LEVEL_DEBUG, PSTR(D_LOG_DEBUG "PzemAc response error %d"), error);
|
||||||
} else {
|
} else {
|
||||||
|
// if ((PzemCalculateCRC(buffer, 23)) == ((buffer[24] << 8) | buffer[23])) {
|
||||||
energy_data_valid = 0;
|
energy_data_valid = 0;
|
||||||
|
|
||||||
// 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24
|
// 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24
|
||||||
@ -69,6 +88,7 @@ void PzemAcEverySecond(void)
|
|||||||
energy_start = energy;
|
energy_start = energy;
|
||||||
}
|
}
|
||||||
EnergyUpdateToday();
|
EnergyUpdateToday();
|
||||||
|
// }
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -118,7 +138,7 @@ int Xnrg05(uint8_t function)
|
|||||||
PzemAcSnsInit();
|
PzemAcSnsInit();
|
||||||
break;
|
break;
|
||||||
case FUNC_ENERGY_EVERY_SECOND:
|
case FUNC_ENERGY_EVERY_SECOND:
|
||||||
PzemAcEverySecond();
|
if (uptime > 4) { PzemAcEverySecond(); } // Fix start up issue #5875
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -117,7 +117,7 @@ int Xnrg06(uint8_t function)
|
|||||||
PzemDcSnsInit();
|
PzemDcSnsInit();
|
||||||
break;
|
break;
|
||||||
case FUNC_ENERGY_EVERY_SECOND:
|
case FUNC_ENERGY_EVERY_SECOND:
|
||||||
PzemDcEverySecond();
|
if (uptime > 4) { PzemDcEverySecond(); } // Fix start up issue #5875
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user