strange error line 22
This commit is contained in:
@@ -5,64 +5,29 @@
|
|||||||
|
|
||||||
char tcp_buffer[1024];
|
char tcp_buffer[1024];
|
||||||
|
|
||||||
struct Data_Modbus {//registers to hold the data of the modbus
|
#define MAX_REG 25
|
||||||
uint16_t reg_00;//
|
|
||||||
uint16_t reg_01;//
|
|
||||||
uint16_t reg_03;//
|
|
||||||
};
|
|
||||||
|
|
||||||
struct Data_Modbus datamodbus;
|
uint16_t registers[MAX_REG];
|
||||||
|
|
||||||
/*
|
|
||||||
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;
|
|
||||||
}
|
|
||||||
*/
|
|
||||||
|
|
||||||
static err_t modbus_incomming_data(void *arg, struct tcp_pcb *pcb, struct pbuf *p, err_t err){
|
static err_t modbus_incomming_data(void *arg, struct tcp_pcb *pcb, struct pbuf *p, err_t err){
|
||||||
int i;
|
u16_t len;
|
||||||
int len;
|
|
||||||
char *pc;
|
|
||||||
printf("data incomming\n");
|
|
||||||
|
|
||||||
|
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;
|
return ERR_OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user