diff --git a/ChangeLog b/ChangeLog index 04f972db..e3db988d 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,6 +1,12 @@ ebus Daemon (ebusd) - ChangeLog =============================== +2013-11-19: +* Data type of struct commands.s_type changed from integer to char[2]. Possible + data types are: BR, MM, MS. (BroadCast, MasterMaster, MasterSlave) +* Wolf configuration files converted to new version. +* README fixed. + 2013-11-06: * Specific vaillant data type "ulg" (unsigned long) added. diff --git a/NEWS b/NEWS index f371b8e6..34dcfbf1 100644 --- a/NEWS +++ b/NEWS @@ -1,6 +1,9 @@ ebus Daemon (ebusd) - NEWS ========================== +2013-11-19: +* Data type of struct commands.s_type changed from integer to char[2]. + 2013-11-14: * Initial commit on github. diff --git a/README b/README index d71e560a..235d875a 100644 --- a/README +++ b/README @@ -8,10 +8,10 @@ Features: ========= * ebus - send and receive ebus commands - - send Broadcast (BC), Master-Master (MM) and Master-Slave (MS) messages - - calculate CRC for sending data and check CRC of received data - - not allowed byte sequences inside data will be escaped and unescaped - - it saved data from specified cycle messages + - Send Broadcast (BC), Master-Master (MM) and Master-Slave (MS) messages + - Calculate CRC for sent and received data + - Escaped and unescaped not allowed byte sequences + - Saved data of specified cycle messages * telnet - multi telnet session (listen on TCP port 8888) The available commands are different of each heating system and provider. diff --git a/contrib/csv/wolf/wolf_cycle.csv b/contrib/csv/wolf/wolf_cycle.csv index 477fb99e..3092a165 100644 --- a/contrib/csv/wolf/wolf_cycle.csv +++ b/contrib/csv/wolf/wolf_cycle.csv @@ -1,8 +1,8 @@ -# type;class;cmd;comment;msg type: 1=BROAD, 2=MM, 3=MS;ZZ;PBSB;NN;D1D2D3;elements;sub;part;position;datatype;factor;unit;valid;comment;sub;part;position;datatype;factor;unit;valid;comment;sub;part;position;datatype;factor;unit;valid;comment;sub;part;position;datatype;factor;unit;valid;comment;sub;part;position;datatype;factor;unit;valid;comment;sub;part;position;datatype;factor;unit;valid;comment;sub;part;position;datatype;factor;unit;valid;comment;sub;part;position;datatype;factor;unit;valid;comment -cyc;broad;date_time;Datum, Uhrzeit und Aussentempertur;1;FE;0700;9;-;4;temp;md;1,2;d2b;1.0;°C;-;Aussentemperatur (Wolf Gastherme: Ersatzwert);day;md;8;bdy;-;-;-;Wochentag;date;md;6,7,9;bda;-;-;-;Datum (Wolf Gastherme Ersatzwert: FFFFFF);time;md;5,4,3;bti;-;-;-;Uhrzeit;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; -cyc;betrd;regler;Betriebsdaten des Reglers an den Feuerungsautomaten;2;03;0507;9;-;7;status;md;1;hex;-;-;-;Statuswärmeanforderung;aktion;md;2;hex;-;-;-;tbd;brauchwasser;md;3,4;d2c;1.0;°C;0-2000;Brauchwassersollwert;solldruck;md;5,6;d2b;1.0;bar;0-100;Kesselsollwertdruck ;stellgrad;md;7;d1c;1.0;%;0-100;Stellgradanforderung;kesselsolltemp;md;8;d1c;1.0;°C;0-100;Kesselsollwerttemperatur ;brennstoff;md;9;bcd;-;-;-;Brennstoffwahl;;;;;;;; -cyc;betrd;feuerung;Betriebsdaten des Feuerungsautomaten an den Regler;1;FE;0503;8;-;8;block;md;1;bcd;-;-;-;Block Nummer;status;md;bcd;hex;-;-;-;Feuerungsautomatstatus;zustand;md;3;hex;-;-;-;Feuerungsautomatzustand;stellgrad;md;4;hex;-;-;-;StellgradKesselleistung (Wolf Gastherme Ersatzwert: FF);kesseltemp;md;5;d1c;1.0;°C;-;Kesseltemperatur ;ruecklauftemp;md;6;d1b;1.0;°C;-;Rücklauftemperatur ;boilertemp;md;7;d1b;1.0;°C;-;Boilertemperatur ;aussentemp;md;8;d1b;1.0;°C;-;Außentemperatur -cyc;sollw;regler;Sollwertübertragung des Reglers an andere Regler;2;03;0800;8;-;5;kesselsolltemp;md;1,2;d2b;1.0;°C;-;Kesselsollwert;aussentemp;md;3,4;d2b;1.0;°C;-;Außentemperatur;leistungszwang;md;5;d1b;1.0;-;-;Leistungszwang;status;md;6;hex;-;-;-;Status;brauchwassersolltemp;md;7,8;d2b;1.0;°C;-;Brauchwassersollwert;;;;;;;;;;;;;;;;;;;;;;;; -cyc;solar;ertraege;Solardaten Erträge ;2;50;5018;0E;-;6;leistung;md;1,2;d2b;1.0;-;-;Solarleistung;ertraglow;md;3;d1c;1.0;-;-;ErtragTagLow;ertraghigh;md;4;d1c;1.0;-;-;ErtragTagHigh;ertragsummelow;md;5;d1c;1.0;-;-;SummeErtragLow;summertraghigh;md;6;d1c;1.0;-;-;SummeErtragHigh;ertragsumme;md;7;d1c;1.0;-;-;SummeErtragM;;;;;;;;;;;;;;;; -cyc;solar;temp;Solardaten Temperaturen;2;50;5017;10;-;3;pumpe;md;1;d1c;1.0;-;-;SolarPumpe;kollektortemp;md;3,4;d2c;1.0;-;-;KollektorTemp;wwsolartemp;md;5,6;d2c;1.0;-;-;WWSolarTemp;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; -cyc;solar;regler;Solardaten Regler;2;50;5014;7;-;4;status;md;1;d1c;1.0;-;-;StatusSolar;mischersolltemp;md;3,4;d2b;1.0;-;-;MischerSolltemperatur;raumtemp;md;5;d1c;1.0;-;-;Raumtemperatur;wwsolltemp;md;7;d1c;1.0;-;-;SollWarmwasser;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; +# type;class;cmd;comment;msg type;ZZ;PBSB;NN;D1D2D3;elements;sub;part;position;datatype;factor;unit;valid;comment;sub;part;position;datatype;factor;unit;valid;comment;sub;part;position;datatype;factor;unit;valid;comment;sub;part;position;datatype;factor;unit;valid;comment;sub;part;position;datatype;factor;unit;valid;comment;sub;part;position;datatype;factor;unit;valid;comment;sub;part;position;datatype;factor;unit;valid;comment;sub;part;position;datatype;factor;unit;valid;comment +cyc;broad;date_time;Datum, Uhrzeit und Aussentempertur;BR;FE;0700;9;-;4;temp;md;1,2;d2b;1.0;°C;-;Aussentemperatur (Wolf Gastherme: Ersatzwert);day;md;8;bdy;-;-;-;Wochentag;date;md;6,7,9;bda;-;-;-;Datum (Wolf Gastherme Ersatzwert: FFFFFF);time;md;5,4,3;bti;-;-;-;Uhrzeit;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; +cyc;betrd;regler;Betriebsdaten des Reglers an den Feuerungsautomaten;MM;03;0507;9;-;7;status;md;1;hex;-;-;-;Statuswärmeanforderung;aktion;md;2;hex;-;-;-;tbd;brauchwasser;md;3,4;d2c;1.0;°C;0-2000;Brauchwassersollwert;solldruck;md;5,6;d2b;1.0;bar;0-100;Kesselsollwertdruck ;stellgrad;md;7;d1c;1.0;%;0-100;Stellgradanforderung;kesselsolltemp;md;8;d1c;1.0;°C;0-100;Kesselsollwerttemperatur ;brennstoff;md;9;bcd;-;-;-;Brennstoffwahl;;;;;;;; +cyc;betrd;feuerung;Betriebsdaten des Feuerungsautomaten an den Regler;BR;FE;0503;8;-;8;block;md;1;bcd;-;-;-;Block Nummer;status;md;bcd;hex;-;-;-;Feuerungsautomatstatus;zustand;md;3;hex;-;-;-;Feuerungsautomatzustand;stellgrad;md;4;hex;-;-;-;StellgradKesselleistung (Wolf Gastherme Ersatzwert: FF);kesseltemp;md;5;d1c;1.0;°C;-;Kesseltemperatur ;ruecklauftemp;md;6;d1b;1.0;°C;-;Rücklauftemperatur ;boilertemp;md;7;d1b;1.0;°C;-;Boilertemperatur ;aussentemp;md;8;d1b;1.0;°C;-;Außentemperatur +cyc;sollw;regler;Sollwertübertragung des Reglers an andere Regler;MM;03;0800;8;-;5;kesselsolltemp;md;1,2;d2b;1.0;°C;-;Kesselsollwert;aussentemp;md;3,4;d2b;1.0;°C;-;Außentemperatur;leistungszwang;md;5;d1b;1.0;-;-;Leistungszwang;status;md;6;hex;-;-;-;Status;brauchwassersolltemp;md;7,8;d2b;1.0;°C;-;Brauchwassersollwert;;;;;;;;;;;;;;;;;;;;;;;; +cyc;solar;ertraege;Solardaten Erträge ;MM;50;5018;0E;-;6;leistung;md;1,2;d2b;1.0;-;-;Solarleistung;ertraglow;md;3;d1c;1.0;-;-;ErtragTagLow;ertraghigh;md;4;d1c;1.0;-;-;ErtragTagHigh;ertragsummelow;md;5;d1c;1.0;-;-;SummeErtragLow;summertraghigh;md;6;d1c;1.0;-;-;SummeErtragHigh;ertragsumme;md;7;d1c;1.0;-;-;SummeErtragM;;;;;;;;;;;;;;;; +cyc;solar;temp;Solardaten Temperaturen;MM;50;5017;10;-;3;pumpe;md;1;d1c;1.0;-;-;SolarPumpe;kollektortemp;md;3,4;d2c;1.0;-;-;KollektorTemp;wwsolartemp;md;5,6;d2c;1.0;-;-;WWSolarTemp;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; +cyc;solar;regler;Solardaten Regler;MM;50;5014;7;-;4;status;md;1;d1c;1.0;-;-;StatusSolar;mischersolltemp;md;3,4;d2b;1.0;-;-;MischerSolltemperatur;raumtemp;md;5;d1c;1.0;-;-;Raumtemperatur;wwsolltemp;md;7;d1c;1.0;-;-;SollWarmwasser;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; diff --git a/contrib/csv/wolf/wolf_cycle.ods b/contrib/csv/wolf/wolf_cycle.ods index b1c62c15..bb30a8a7 100644 Binary files a/contrib/csv/wolf/wolf_cycle.ods and b/contrib/csv/wolf/wolf_cycle.ods differ diff --git a/lib/ebus-bus.c b/lib/ebus-bus.c index 5b326514..f194faa0 100644 --- a/lib/ebus-bus.c +++ b/lib/ebus-bus.c @@ -901,7 +901,10 @@ eb_execute(int id, char *data, char *buf, int *buflen) memset(msg, '\0', sizeof(msg)); msglen = sizeof(msg); - msgtype = eb_cmd_get_s_type(id); + + msgtype = eb_cmd_get_s_type(id); + if (msgtype < 0) + return; cycdata = NO; ret = -1; @@ -1048,8 +1051,8 @@ eb_cyc_data_process(const unsigned char *buf, int buflen) id = eb_cmd_search_com_cyc(&buf[1], buflen - 1); if (id >= 0) { - msgtype = eb_cmd_get_s_type(id); + err_ret_if(msgtype < 0, -1); /* unescape */ memcpy(msg, buf, buflen); diff --git a/lib/ebus-cmd.c b/lib/ebus-cmd.c index 3e7ded24..44d15c50 100644 --- a/lib/ebus-cmd.c +++ b/lib/ebus-cmd.c @@ -69,7 +69,16 @@ eb_cmd_check_type(int id, const char *type) int eb_cmd_get_s_type(int id) { - return com[id].s_type; + if (strncasecmp(com[id].s_type, EBUS_MSG_BROADCAST_TXT, 2) == 0) { + return EBUS_MSG_BROADCAST; + } else if(strncasecmp(com[id].s_type, EBUS_MSG_MASTER_MASTER_TXT, 2) == 0) { + return EBUS_MSG_MASTER_MASTER; + } else if(strncasecmp(com[id].s_type, EBUS_MSG_MASTER_SLAVE_TXT, 2) == 0) { + return EBUS_MSG_MASTER_SLAVE; + } else { + log_print(L_ERR, "message type %s unkown", com[id].s_type); + return -1; + } } @@ -119,7 +128,7 @@ eb_cmd_search_com_cyc(const unsigned char *hex, int hexlen) for (i = 0; i < cyclen; i++) { if (memcmp(hlp, cyc[i].msg, strlen((const char *) cyc[i].msg)) == 0) { - log_print(L_NOT, " found: %s type: %d ==> id: %d", + log_print(L_NOT, " found: %s type: %s ==> id: %d", cyc[i].msg, com[cyc[i].id].s_type, cyc[i].id); return cyc[i].id; @@ -141,7 +150,7 @@ eb_cmd_search_com_id(const char *type, const char *class, const char *cmd) && (strncasecmp(cmd, com[i].cmd, strlen(com[i].cmd)) == 0) && strlen(cmd) == strlen(com[i].cmd)) { - log_print(L_NOT, " found: %s%s%02X%s type: %d ==> id: %d", + log_print(L_NOT, " found: %s%s%02X%s type: %s ==> id: %d", com[i].s_zz, com[i].s_cmd, com[i].s_len, com[i].s_msg, com[i].s_type, i); return i; @@ -664,7 +673,7 @@ eb_cmd_print(const char *type, int all, int detail) if (strncasecmp(com[i].type, type, 1) == 0 || all) { - log_print(L_INF, "[%03d] %s : %5s.%-32s\t(type: %d)" \ + log_print(L_INF, "[%03d] %s : %22s.%-42s\t(type: %s)" \ " %s%s%-10s (len: %d) [%d] ==> %s", com[i].id, com[i].type, @@ -735,7 +744,8 @@ eb_cmd_fill(const char *tok) /* s_type */ tok = strtok(NULL, ";"); - com[comlen].s_type = atoi(tok); + strncpy(com[comlen].s_type, tok, strlen(tok)); + eb_cmd_uppercase(com[comlen].s_type); /* s_zz */ tok = strtok(NULL, ";"); diff --git a/lib/ebus-cmd.h b/lib/ebus-cmd.h index 23e76172..f4ddb7cf 100644 --- a/lib/ebus-cmd.h +++ b/lib/ebus-cmd.h @@ -40,8 +40,9 @@ #define CMD_SIZE_TYPE 3 #define CMD_SIZE_CLASS 20 -#define CMD_SIZE_CMD 30 +#define CMD_SIZE_CMD 40 #define CMD_SIZE_COM 256 +#define CMD_SIZE_S_TYPE 2 #define CMD_SIZE_S_ZZ 2 #define CMD_SIZE_S_CMD 4 #define CMD_SIZE_S_MSG 32 @@ -80,7 +81,7 @@ struct commands { char class[CMD_SIZE_CLASS + 1]; /**< ci */ char cmd[CMD_SIZE_CMD + 1]; /**< hydraulic */ char com[CMD_SIZE_COM + 1]; /**< just a comment */ - int s_type; /**< message type */ + char s_type[CMD_SIZE_S_TYPE + 1]; /**< message type */ char s_zz[CMD_SIZE_S_ZZ + 1]; /**< zz */ char s_cmd[CMD_SIZE_S_CMD + 1]; /**< pb sb */ int s_len; /**< number of send bytes */ @@ -126,7 +127,7 @@ int eb_cmd_check_type(int id, const char *type); /** * @brief returns s_type of given id * @param [in] id is index in command array - * @return s_type of ebus command + * @return type of ebus command | -1 wrong message type */ int eb_cmd_get_s_type(int id); diff --git a/lib/ebus-common.h b/lib/ebus-common.h index 1fa6f4e6..73f1767f 100644 --- a/lib/ebus-common.h +++ b/lib/ebus-common.h @@ -30,33 +30,36 @@ -#define EBUS_SYN 0xAA -#define EBUS_SYN_ESC_A9 0xA9 -#define EBUS_SYN_ESC_01 0x01 -#define EBUS_SYN_ESC_00 0x00 +#define EBUS_SYN 0xAA +#define EBUS_SYN_ESC_A9 0xA9 +#define EBUS_SYN_ESC_01 0x01 +#define EBUS_SYN_ESC_00 0x00 -#define EBUS_ACK 0x00 -#define EBUS_NAK 0xFF +#define EBUS_ACK 0x00 +#define EBUS_NAK 0xFF -#define EBUS_QQ 0xFF +#define EBUS_QQ 0xFF -#define EBUS_GET_RETRY 3 -#define EBUS_GET_RETRY_MAX 10 -#define EBUS_SKIP_ACK 1 -#define EBUS_MAX_WAIT 4000 -#define EBUS_SEND_RETRY 2 -#define EBUS_SEND_RETRY_MAX 10 -#define EBUS_PRINT_SIZE 30 +#define EBUS_GET_RETRY 3 +#define EBUS_GET_RETRY_MAX 10 +#define EBUS_SKIP_ACK 1 +#define EBUS_MAX_WAIT 4000 +#define EBUS_SEND_RETRY 2 +#define EBUS_SEND_RETRY_MAX 10 +#define EBUS_PRINT_SIZE 30 -#define EBUS_MSG_BROADCAST 1 -#define EBUS_MSG_MASTER_MASTER 2 -#define EBUS_MSG_MASTER_SLAVE 3 +#define EBUS_MSG_BROADCAST_TXT "BR" +#define EBUS_MSG_BROADCAST 1 +#define EBUS_MSG_MASTER_MASTER_TXT "MM" +#define EBUS_MSG_MASTER_MASTER 2 +#define EBUS_MSG_MASTER_SLAVE_TXT "MS" +#define EBUS_MSG_MASTER_SLAVE 3 -#define SERIAL_DEVICE "/dev/ttyUSB0" -#define SERIAL_BAUDRATE B2400 -#define SERIAL_BUFSIZE 100 +#define SERIAL_DEVICE "/dev/ttyUSB0" +#define SERIAL_BAUDRATE B2400 +#define SERIAL_BUFSIZE 100 -#define CMD_DATA_SIZE 50 /* 5+16+3+16+2 = 42 || 256 */ +#define CMD_DATA_SIZE 50 /* 5+16+3+16+2 = 42 || 256 */ enum enum_bool {UNSET = -1, NO, YES};