strange error line 22

This commit is contained in:
Obe Van Lierde
2023-11-07 17:51:09 +01:00
parent 325fe60276
commit 87117ad602

View File

@@ -5,64 +5,29 @@
char tcp_buffer[1024];
struct Data_Modbus {//registers to hold the data of the modbus
uint16_t reg_00;//
uint16_t reg_01;//
uint16_t reg_03;//
};
#define MAX_REG 25
struct Data_Modbus datamodbus;
/*
static err_t echo_recv( void *arg, struct tcp_pcb *pcb, struct pbuf *p, err_t err )
{
int i;
int len;
char *pc;
if ( err == ERR_OK && p != NULL )
{
tcp_recved( pcb, p->tot_len );
pc = (char *)p->payload;
len =p->tot_len;
for( i=0; i<len; i++ )
{
tcp_buffer[i] = pc[i];
}
if( tcp_buffer[0] == 'X' )
echo_close( pcb );
pbuf_free( p );
if( len > tcp_sndbuf( pcb ) )
len= tcp_sndbuf( pcb );
tcp_write( pcb, tcp_buffer, len, 0 );
tcp_sent( pcb, NULL );
}
else
{
pbuf_free( p );
}
if( err == ERR_OK && p == NULL )
{
echo_close( pcb );
}
return ERR_OK;
}
*/
uint16_t registers[MAX_REG];
static err_t modbus_incomming_data(void *arg, struct tcp_pcb *pcb, struct pbuf *p, err_t err){
int i;
int len;
char *pc;
printf("data incomming\n");
u16_t len;
if (p != NULL){
printf("data not null\n");
//here im going to procces the modbusdata
len = p->tot_len;
//putting the bufer in the register array
for(int i=0; i<len; i++ ) {
registers[i] = p->payload[i];//getting the error "void value not ignored as it ought to be" on this line
}
if(registers[7] == 0x10){// Check if it's a Modbus Write Multiple Registers request (0x10)
printf("in writing multiple register mode\n");
}
} else if (err == ERR_OK){
tcp_close(pcb);//when everithing was ok close the tcpconnection
}
return ERR_OK;
}