Data type of struct commands.s_type changed from integer to char[2]
This commit is contained in:
+5
-2
@@ -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);
|
||||
|
||||
+15
-5
@@ -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, ";");
|
||||
|
||||
+4
-3
@@ -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);
|
||||
|
||||
|
||||
+24
-21
@@ -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};
|
||||
|
||||
|
||||
Reference in New Issue
Block a user