From e6e61ff9354304a9f3ab4c509152e65243d0c6bc Mon Sep 17 00:00:00 2001 From: fredlcore Date: Tue, 20 Dec 2016 00:25:47 +0100 Subject: [PATCH] Add files via upload --- BSB_lan/BSB_lan/BSB_lan.ino | 40 ++++++++++++++++++++++++++++++----- BSB_lan/BSB_lan/README | 30 ++++++-------------------- BSB_lan/libraries/BSB/bsb.cpp | 34 +++++++++++++++++++++++++++++ BSB_lan/libraries/BSB/bsb.h | 1 + 4 files changed, 76 insertions(+), 29 deletions(-) diff --git a/BSB_lan/BSB_lan/BSB_lan.ino b/BSB_lan/BSB_lan/BSB_lan.ino index bf4aabca4..9e45e5ae0 100644 --- a/BSB_lan/BSB_lan/BSB_lan.ino +++ b/BSB_lan/BSB_lan/BSB_lan.ino @@ -13,8 +13,11 @@ * 0.1 - 21.01.2015 - initial version * 0.5 - 02.02.2015 * 0.6 - 02.02.2015 + * 0.7 - 06.02.2015 * * Changelog: + * version 0.7 + * - added bus monitor functionality * version 0.6 * - renamed SoftwareSerial to BSBSoftwareSerial * - changed folder structure to enable simple build with arduino sdk @@ -44,6 +47,7 @@ // if set to 1, all messages on the bus are printed to the serial interface byte verbose = 0; +byte monitor = 0; // if enabled the URL has to contain the defined passkey as first element // e.g. @@ -3206,9 +3210,14 @@ void loop() { char cLineBuffer[MaxArrayElement]; byte bPlaceInBuffer; - // listen for incoming messages - if(verbose){ - if (bus.GetMessage(msg)) printTelegram(msg); + // monitor bus + if(monitor){ + bus.Monitor(); + }else{ + // listen for incoming messages + if(verbose){ + if (bus.GetMessage(msg)) printTelegram(msg); + } } // listen for incoming clients @@ -3256,16 +3265,36 @@ void loop() { break; } // answer to unknown requests - if(!isdigit(p[1]) && strchr("KSIREV",p[1])==NULL){ + if(!isdigit(p[1]) && strchr("KSIREVM",p[1])==NULL){ webPrintHeader(); webPrintFooter(); break; } - // + // setting verbosity level if(p[1]=='V'){ p+=2; verbose=atoi(p); webPrintHeader(); + if(verbose>0){ + client.println(F("verbose mode activated
")); + }else{ + client.println(F("verbose mode deactivated
")); + } + client.println(F("only serial output is affected")); + webPrintFooter(); + break; + } + // switching monitor on/off + if(p[1]=='M'){ + p+=2; + monitor=atoi(p); + webPrintHeader(); + if(monitor>0){ + client.println(F("monitor activated
")); + }else{ + client.println(F("monitor deactivated
")); + } + client.println(F("only serial output is affected")); webPrintFooter(); break; } @@ -4108,6 +4137,7 @@ void webPrintSite() { client.print(F(" /Ex list enum values for line x")); client.print(F(" /Rx query reset value for line x")); client.print(F(" /Vn set verbosity level for serial output")); + client.print(F(" /Mn activate/deactivate monitor functionality (n=0 disable, n=1 enable)")); client.print(F(" ")); client.print(F(" multiple queries are possible, e.g. /K0/710/8000-8999

")); webPrintFooter(); diff --git a/BSB_lan/BSB_lan/README b/BSB_lan/BSB_lan/README index ff9084bcc..5f37e7c85 100644 --- a/BSB_lan/BSB_lan/README +++ b/BSB_lan/BSB_lan/README @@ -104,6 +104,12 @@ Interface: The default verbosity level is 0. When setting it to 1 the bus is monitored and all data is additionally printed in raw hex format. The verbose output only affects the serial console of the mega2560. The html output is kept unchanged. + activate bus monitor + http:///M + When setting it to 1 all bytes on the bus monitored. Telegrams are recognized by a character break condition. + Every Telegramm is printed in hex format to serial output with a timestamp in milliseconds. + The monitor output only affects the serial console of the mega2560. The html output is kept unchanged. + Open issues - Add more command ids to the table. Only the known command ids from the threads listed above and the testet boiler system (ELCO) are content of the table. @@ -125,27 +131,3 @@ Open issues - Decode DE telegrams. Maybe they contain some status information and we can use them without querying. - Add support of error messages send by the boiler system - - - -Extension: TODO - - Room temperature sensor simulation: - - affected parameters - - 710 - HK1 - Komfortsollwert - - 750 - HK1 - Raumeinfluss - - 700 - HK1 - Betriebsart (0=Schutzbetrieb, 1=Automatik, 2=Reduziert, 3=Komfort) - - INF 10000=Raumtemperatur - - 8740 Diagnose Verbraucher - Raumtemperatur 1 - - 8741 Diagnose Verbraucher - Raumsollwert 1 - - To simulate a room temperature sensor the temperature has to be sent in a regular interval (<10min). - Additionally the boiler can be switched off, when no heating is requested. - When using the PID20 module from fhem, we can try the following approach: - - loop over all PID20 devices - - skip all devices which are not the state processing - - skip all devices with an actuation less than 10 percent - - get the max desired temperature for all not skipped devices - - get the greatest difference from desired and measured temperature for all not skipped devices - - calculate a virtual min measured temperature using this difference diff --git a/BSB_lan/libraries/BSB/bsb.cpp b/BSB_lan/libraries/BSB/bsb.cpp index 3115ec4e1..580fc438d 100644 --- a/BSB_lan/libraries/BSB/bsb.cpp +++ b/BSB_lan/libraries/BSB/bsb.cpp @@ -35,6 +35,40 @@ void BSB::print(byte* msg) { // Receives a message and stores it to buffer +void BSB::Monitor() { + unsigned long int ts; + byte read; + + if (serial->available() > 0) { + // get timestamp + ts=millis(); + // output + Serial.print(ts); + Serial.print(" "); + while (serial->available() > 0) { + + // Read serial data... + read = serial->read() ^ 0xFF; + // output + if(read<16){ + Serial.print("0"); + } + Serial.print(read, HEX); + Serial.print(" "); + // if no inout available -> wait + if (serial->available() == 0) { + unsigned long timeout = millis() + 3;// > ((11/4800)*1000); + while (millis() < timeout) { + delayMicroseconds(15); + } + } + // if still no input available telegramm has finished + if (serial->available() == 0) break; + } + Serial.println(); + } +} + bool BSB::GetMessage(byte* msg) { byte i=0,timeout; byte read; diff --git a/BSB_lan/libraries/BSB/bsb.h b/BSB_lan/libraries/BSB/bsb.h index ee66f2172..3ddf4cb06 100644 --- a/BSB_lan/libraries/BSB/bsb.h +++ b/BSB_lan/libraries/BSB/bsb.h @@ -38,6 +38,7 @@ class BSB { public: BSB(uint8_t rx, uint8_t tx, uint8_t addr=0x06 ); + void Monitor(); bool GetMessage(byte* msg); void print(byte* msg);