1wire error handling

This commit is contained in:
2020-04-27 02:25:43 +03:00
parent ff6816b2e1
commit 08f251bc63
2 changed files with 24 additions and 7 deletions

View File

@@ -1825,7 +1825,7 @@ int Item::SendStatus(int sendFlags) {
}
//publish to MQTT - OpenHab Legacy style to myhome/s_out/item flat values
setTopic(addrstr,sizeof(addrstr),T_OUT);
strncat(addrstr, itemArr->name, sizeof(addrstr));
strncat(addrstr, itemArr->name, sizeof(addrstr)-1);
if (mqttClient.connected() && !ethernetIdleCount)
{
@@ -1855,7 +1855,7 @@ int Item::SendStatus(int sendFlags) {
if (sendFlags & SEND_PARAMETERS)
{
setTopic(addrstr,sizeof(addrstr),T_OUT);
strncat(addrstr, itemArr->name, sizeof(addrstr));
strncat(addrstr, itemArr->name, sizeof(addrstr)-1);
strncat(addrstr, "/", sizeof(addrstr));
strncat_P(addrstr, SET_P, sizeof(addrstr));
@@ -1893,7 +1893,7 @@ int Item::SendStatus(int sendFlags) {
}
setTopic(addrstr,sizeof(addrstr),T_OUT);
strncat(addrstr, itemArr->name, sizeof(addrstr));
strncat(addrstr, itemArr->name, sizeof(addrstr)-1);
strncat(addrstr, "/", sizeof(addrstr));
strncat_P(addrstr, CMD_P, sizeof(addrstr));

View File

@@ -42,9 +42,13 @@ owChangedType owChanged;
int owUpdate() {
#ifndef OWIRE_DISABLE
unsigned long finish = millis() + OW_UPDATE_INTERVAL;
short sr;
/*
if (oneWire->getError() == DS2482_ERROR_SHORT)
{
debugSerial<<F("1-wire shorted.")<<endl;
return false;
}
*/
Serial.println(F("Searching"));
if (oneWire) oneWire->reset_search();
for (short i = 0; i < t_count; i++) wstat[i] &= ~SW_FIND; //absent
@@ -78,6 +82,7 @@ int owUpdate() {
debugSerial<<F("1-wire count: ")<<t_count<<endl;
#endif
return true;
}
@@ -119,6 +124,12 @@ int owSetup(owChangedType owCh) {
if (oneWire->wireReset())
debugSerial.println(F("\tReset done"));
if (oneWire->getError() == DS2482_ERROR_SHORT)
{
debugSerial<<F("1-wire shorted.")<<endl;
return false;
}
sensors->begin();
owChanged = owCh;
//owUpdate();
@@ -141,7 +152,13 @@ int owSetup(owChangedType owCh) {
int sensors_loop(void) {
if (!sensors) return -1;
if (!sensors) return 100000;
if (oneWire->getError() == DS2482_ERROR_SHORT)
{
debugSerial<<F("1-wire disabled (shorted)")<<endl;
return 100000;
}
if (si >= t_count) {
owUpdate(); //every check circle - scan for new devices
si = 0;