reading the whole modbusframe

This commit is contained in:
Obe Van Lierde
2023-11-09 16:22:05 +01:00
parent af1bfd8f09
commit 1ec10c0bf4

View File

@@ -18,6 +18,11 @@ static err_t modbus_incomming_data(void *arg, struct tcp_pcb *pcb, struct pbuf *
uint8_t txt_red = 0;
uint8_t txt_green = 0;
uint8_t txt_blue = 0;
uint8_t nr_img = 0;
char text[200];
for(i = 0; i < 100;i++){
text[i] = 95; // _
}
if (p != NULL){
printf("data not null\n");
@@ -35,13 +40,31 @@ static err_t modbus_incomming_data(void *arg, struct tcp_pcb *pcb, struct pbuf *
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);
bg_red = (uint8_t)(registers[14]);//01
bg_green = (uint8_t)(registers[16]);//02
bg_blue = (uint8_t)(registers[18]);//03
txt_red = (uint8_t)(registers[20]);//04
txt_green = (uint8_t)(registers[22]);//05
txt_blue = (uint8_t)(registers[24]);//06
nr_img = (uint8_t)(registers[26]);//07
//registers[428] //208
printf("%d %d %d %d %d %d %d ",bg_red,bg_green,bg_blue,txt_red,txt_green,txt_blue,nr_img);
int j = 0;
for(i = 28;i < 428;i++){
if(i % 2 == 0){
text[j]=registers[i];
j++;
}
}
for(i = 0; i < 100;i++){
printf("%c ",text[i]);
}
printf("\n");
} else if (err == ERR_OK){
tcp_close(pcb);//when everithing was ok close the tcpconnection
}