modbus_tcp
Change registers from char to uint8_t
This commit is contained in:
@@ -27,10 +27,10 @@
|
||||
#define REG_07 26
|
||||
|
||||
// Global variables
|
||||
char registers[MAX_REG];
|
||||
static char* TAG = "Modbus_TCP"; // Tag used in logs
|
||||
|
||||
static struct tcp_pcb* modbus_pcb;
|
||||
uint8_t registers[MAX_REG];
|
||||
|
||||
// Functions
|
||||
static err_t modbus_incoming_data(void* arg, struct tcp_pcb* pcb, struct pbuf* p, err_t err);
|
||||
@@ -67,15 +67,16 @@ static err_t modbus_incoming_data(void* arg, struct tcp_pcb* pcb, struct pbuf* p
|
||||
registers[i] = ((uint*)p->payload)[i];
|
||||
}
|
||||
|
||||
if (registers[MODBUS_MODE] == MULTIPLE_REG) { // Check if it's a Modbus Write Multiple Registers request (0x10)
|
||||
if (registers[MODBUS_MODE] == MULTIPLE_REG) {
|
||||
// Check if it's a Modbus Write Multiple Registers request (0x10)
|
||||
LOG_INFO(TAG, "in writing multiple register mode\n");
|
||||
background_red = (uint8_t)(registers[REG_01]); // 01
|
||||
background_green = (uint8_t)(registers[REG_02]); // 02
|
||||
background_blue = (uint8_t)(registers[REG_03]); // 03
|
||||
text_color_red = (uint8_t)(registers[REG_04]); // 04
|
||||
text_color_green = (uint8_t)(registers[REG_05]); // 05
|
||||
text_color_blue = (uint8_t)(registers[REG_06]); // 06
|
||||
nr_img = (uint8_t)(registers[REG_07]); // 07
|
||||
background_red = registers[REG_01]; // 01
|
||||
background_green = registers[REG_02]; // 02
|
||||
background_blue = registers[REG_03]; // 03
|
||||
text_color_red = registers[REG_04]; // 04
|
||||
text_color_green = registers[REG_05]; // 05
|
||||
text_color_blue = registers[REG_06]; // 06
|
||||
nr_img = registers[REG_07]; // 07
|
||||
|
||||
LOG_INFO(TAG, "%d %d %d %d %d %d %d", background_red, background_green, background_blue, text_color_red,
|
||||
text_color_green, text_color_blue, nr_img);
|
||||
|
||||
Reference in New Issue
Block a user