Unofficial update by Zhironkin

This commit is contained in:
Pavel Volkov
2022-05-25 00:00:06 +03:00
parent e226faa454
commit fe0b46c130
8 changed files with 86 additions and 46 deletions

View File

@@ -12,6 +12,9 @@
volatile uint8_t recv_buffer[BUFFERS_SIZE];
volatile uint8_t send_buffer[BUFFERS_SIZE];
extern uint16_t uart_rx_counter;
extern uint16_t uart_rx_len;
uint16_t bytes_to_send = 0;
uint16_t last_rx_time = 0xFFFF;
enum recv_state cmd_receiving = RECV_IDLE;
@@ -30,7 +33,16 @@ void UART_RxCpltCallback(void)
// Check destination address
if (recv_buffer[5] != BOARD_ADRESS)
{
cmd_receiving = RECV_ERROR;
// if(recv_buffer[5]==BOARD_ADRESS_Panel || recv_buffer[5]==BOARD_ADRESS_DAC )
// {
// memset(&recv_buffer[0],0,BUFFERS_SIZE);
last_rx_time =0;
// }
cmd_receiving = RECV_ERROR;
return;
}
@@ -76,14 +88,15 @@ void modbus_loop_iterate()
{
if (cmd_receiving == RECV_ERROR)
{
//delay_ms(30); // poor man's way to synchronize packets
// HAL_Delay(10); // poor man's way to synchronize packets
if(last_rx_time>=BUS_IDLE_TIME)
{
{
cmd_receiving = RECV_IDLE;
// memset(&recv_buffer[0],0,BUFFERS_SIZE);
//TXEN_485 = 1;
//delay_us(10);
//TXEN_485 = 0;
}
}
}
if (cmd_receiving == RECV_IDLE)
{