Skip to content

Commit

Permalink
Merge pull request #3 from fredlcore/v0.7
Browse files Browse the repository at this point in the history
Add files via upload
  • Loading branch information
fredlcore authored Dec 19, 2016
2 parents 04dc87f + e6e61ff commit 5662fcd
Show file tree
Hide file tree
Showing 4 changed files with 76 additions and 29 deletions.
40 changes: 35 additions & 5 deletions BSB_lan/BSB_lan/BSB_lan.ino
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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.
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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<br>"));
}else{
client.println(F("verbose mode deactivated<br>"));
}
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<br>"));
}else{
client.println(F("monitor deactivated<br>"));
}
client.println(F("only serial output is affected"));
webPrintFooter();
break;
}
Expand Down Expand Up @@ -4108,6 +4137,7 @@ void webPrintSite() {
client.print(F(" <tr><td>/Ex</td> <td>list enum values for line x</td></tr>"));
client.print(F(" <tr><td>/Rx</td> <td>query reset value for line x</td></tr>"));
client.print(F(" <tr><td>/Vn</td> <td>set verbosity level for serial output</td></tr>"));
client.print(F(" <tr><td>/Mn</td> <td>activate/deactivate monitor functionality (n=0 disable, n=1 enable)</td></tr>"));
client.print(F(" </table>"));
client.print(F(" multiple queries are possible, e.g. /K0/710/8000-8999</p>"));
webPrintFooter();
Expand Down
30 changes: 6 additions & 24 deletions BSB_lan/BSB_lan/README
Original file line number Diff line number Diff line change
Expand Up @@ -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://<ip-of-server>/M<n>
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.
Expand All @@ -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
34 changes: 34 additions & 0 deletions BSB_lan/libraries/BSB/bsb.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
1 change: 1 addition & 0 deletions BSB_lan/libraries/BSB/bsb.h
Original file line number Diff line number Diff line change
Expand Up @@ -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);

Expand Down

0 comments on commit 5662fcd

Please sign in to comment.