Data type of struct commands.s_type changed from integer to char[2]

This commit is contained in:
Roland Jax
2013-11-19 17:47:53 +01:00
parent f78b909353
commit 91b8671141
9 changed files with 69 additions and 43 deletions
+6
View File
@@ -1,6 +1,12 @@
ebus Daemon (ebusd) - ChangeLog 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: 2013-11-06:
* Specific vaillant data type "ulg" (unsigned long) added. * Specific vaillant data type "ulg" (unsigned long) added.
+3
View File
@@ -1,6 +1,9 @@
ebus Daemon (ebusd) - NEWS ebus Daemon (ebusd) - NEWS
========================== ==========================
2013-11-19:
* Data type of struct commands.s_type changed from integer to char[2].
2013-11-14: 2013-11-14:
* Initial commit on github. * Initial commit on github.
+4 -4
View File
@@ -8,10 +8,10 @@ Features:
========= =========
* ebus - send and receive ebus commands * ebus - send and receive ebus commands
- send Broadcast (BC), Master-Master (MM) and Master-Slave (MS) messages - Send Broadcast (BC), Master-Master (MM) and Master-Slave (MS) messages
- calculate CRC for sending data and check CRC of received data - Calculate CRC for sent and received data
- not allowed byte sequences inside data will be escaped and unescaped - Escaped and unescaped not allowed byte sequences
- it saved data from specified cycle messages - Saved data of specified cycle messages
* telnet - multi telnet session (listen on TCP port 8888) * telnet - multi telnet session (listen on TCP port 8888)
The available commands are different of each heating system and provider. The available commands are different of each heating system and provider.
+8 -8
View File
@@ -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 # 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;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;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;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;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;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;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;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;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 ;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;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;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;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;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;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; 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;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
1 # type class cmd comment msg type: 1=BROAD, 2=MM, 3=MS 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
2 cyc broad date_time Datum, Uhrzeit und Aussentempertur 1 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
3 cyc betrd regler Betriebsdaten des Reglers an den Feuerungsautomaten 2 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
4 cyc betrd feuerung Betriebsdaten des Feuerungsautomaten an den Regler 1 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 Außentemperatur
5 cyc sollw regler Sollwertübertragung des Reglers an andere Regler 2 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
6 cyc solar ertraege Solardaten Erträge 2 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
7 cyc solar temp Solardaten Temperaturen 2 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
8 cyc solar regler Solardaten Regler 2 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
Binary file not shown.
+5 -2
View File
@@ -901,7 +901,10 @@ eb_execute(int id, char *data, char *buf, int *buflen)
memset(msg, '\0', sizeof(msg)); memset(msg, '\0', sizeof(msg));
msglen = 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; cycdata = NO;
ret = -1; 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); id = eb_cmd_search_com_cyc(&buf[1], buflen - 1);
if (id >= 0) { if (id >= 0) {
msgtype = eb_cmd_get_s_type(id); msgtype = eb_cmd_get_s_type(id);
err_ret_if(msgtype < 0, -1);
/* unescape */ /* unescape */
memcpy(msg, buf, buflen); memcpy(msg, buf, buflen);
+15 -5
View File
@@ -69,7 +69,16 @@ eb_cmd_check_type(int id, const char *type)
int int
eb_cmd_get_s_type(int id) 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++) { for (i = 0; i < cyclen; i++) {
if (memcmp(hlp, cyc[i].msg, strlen((const char *) cyc[i].msg)) == 0) { 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); cyc[i].msg, com[cyc[i].id].s_type, cyc[i].id);
return 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) && (strncasecmp(cmd, com[i].cmd, strlen(com[i].cmd)) == 0)
&& strlen(cmd) == strlen(com[i].cmd)) { && 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_zz, com[i].s_cmd, com[i].s_len,
com[i].s_msg, com[i].s_type, i); com[i].s_msg, com[i].s_type, i);
return 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) { 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", " %s%s%-10s (len: %d) [%d] ==> %s",
com[i].id, com[i].id,
com[i].type, com[i].type,
@@ -735,7 +744,8 @@ eb_cmd_fill(const char *tok)
/* s_type */ /* s_type */
tok = strtok(NULL, ";"); 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 */ /* s_zz */
tok = strtok(NULL, ";"); tok = strtok(NULL, ";");
+4 -3
View File
@@ -40,8 +40,9 @@
#define CMD_SIZE_TYPE 3 #define CMD_SIZE_TYPE 3
#define CMD_SIZE_CLASS 20 #define CMD_SIZE_CLASS 20
#define CMD_SIZE_CMD 30 #define CMD_SIZE_CMD 40
#define CMD_SIZE_COM 256 #define CMD_SIZE_COM 256
#define CMD_SIZE_S_TYPE 2
#define CMD_SIZE_S_ZZ 2 #define CMD_SIZE_S_ZZ 2
#define CMD_SIZE_S_CMD 4 #define CMD_SIZE_S_CMD 4
#define CMD_SIZE_S_MSG 32 #define CMD_SIZE_S_MSG 32
@@ -80,7 +81,7 @@ struct commands {
char class[CMD_SIZE_CLASS + 1]; /**< ci */ char class[CMD_SIZE_CLASS + 1]; /**< ci */
char cmd[CMD_SIZE_CMD + 1]; /**< hydraulic */ char cmd[CMD_SIZE_CMD + 1]; /**< hydraulic */
char com[CMD_SIZE_COM + 1]; /**< just a comment */ 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_zz[CMD_SIZE_S_ZZ + 1]; /**< zz */
char s_cmd[CMD_SIZE_S_CMD + 1]; /**< pb sb */ char s_cmd[CMD_SIZE_S_CMD + 1]; /**< pb sb */
int s_len; /**< number of send bytes */ 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 * @brief returns s_type of given id
* @param [in] id is index in command array * @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); int eb_cmd_get_s_type(int id);
+24 -21
View File
@@ -30,33 +30,36 @@
#define EBUS_SYN 0xAA #define EBUS_SYN 0xAA
#define EBUS_SYN_ESC_A9 0xA9 #define EBUS_SYN_ESC_A9 0xA9
#define EBUS_SYN_ESC_01 0x01 #define EBUS_SYN_ESC_01 0x01
#define EBUS_SYN_ESC_00 0x00 #define EBUS_SYN_ESC_00 0x00
#define EBUS_ACK 0x00 #define EBUS_ACK 0x00
#define EBUS_NAK 0xFF #define EBUS_NAK 0xFF
#define EBUS_QQ 0xFF #define EBUS_QQ 0xFF
#define EBUS_GET_RETRY 3 #define EBUS_GET_RETRY 3
#define EBUS_GET_RETRY_MAX 10 #define EBUS_GET_RETRY_MAX 10
#define EBUS_SKIP_ACK 1 #define EBUS_SKIP_ACK 1
#define EBUS_MAX_WAIT 4000 #define EBUS_MAX_WAIT 4000
#define EBUS_SEND_RETRY 2 #define EBUS_SEND_RETRY 2
#define EBUS_SEND_RETRY_MAX 10 #define EBUS_SEND_RETRY_MAX 10
#define EBUS_PRINT_SIZE 30 #define EBUS_PRINT_SIZE 30
#define EBUS_MSG_BROADCAST 1 #define EBUS_MSG_BROADCAST_TXT "BR"
#define EBUS_MSG_MASTER_MASTER 2 #define EBUS_MSG_BROADCAST 1
#define EBUS_MSG_MASTER_SLAVE 3 #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_DEVICE "/dev/ttyUSB0"
#define SERIAL_BAUDRATE B2400 #define SERIAL_BAUDRATE B2400
#define SERIAL_BUFSIZE 100 #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}; enum enum_bool {UNSET = -1, NO, YES};