reading the color values
This commit is contained in:
@@ -4,7 +4,7 @@
|
||||
|
||||
char tcp_buffer[1024];
|
||||
|
||||
#define MAX_REG 100
|
||||
#define MAX_REG 250
|
||||
|
||||
char registers[MAX_REG];
|
||||
|
||||
@@ -12,6 +12,12 @@ static err_t modbus_incomming_data(void *arg, struct tcp_pcb *pcb, struct pbuf *
|
||||
int i;
|
||||
int len;
|
||||
char *pc;
|
||||
uint8_t bg_red = 0;
|
||||
uint8_t bg_green = 0;
|
||||
uint8_t bg_blue = 0;
|
||||
uint8_t txt_red = 0;
|
||||
uint8_t txt_green = 0;
|
||||
uint8_t txt_blue = 0;
|
||||
|
||||
if (p != NULL){
|
||||
printf("data not null\n");
|
||||
@@ -28,6 +34,14 @@ static err_t modbus_incomming_data(void *arg, struct tcp_pcb *pcb, struct pbuf *
|
||||
if(registers[7] == 0x10){// Check if it's a Modbus Write Multiple Registers request (0x10)
|
||||
printf("in writing multiple register mode\n");
|
||||
}
|
||||
//putting the values from the array in their variable
|
||||
bg_red = (uint8_t)(registers[14]);
|
||||
bg_green = (uint8_t)(registers[16]);
|
||||
bg_blue = (uint8_t)(registers[18]);
|
||||
txt_red = (uint8_t)(registers[20]);
|
||||
txt_green = (uint8_t)(registers[22]);
|
||||
txt_blue = (uint8_t)(registers[24]);
|
||||
printf("%d, %d, %d,%d, %d, %d\n",bg_red,bg_green,bg_blue,txt_red,txt_green,txt_blue);
|
||||
} else if (err == ERR_OK){
|
||||
tcp_close(pcb);//when everithing was ok close the tcpconnection
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user