34 lines
884 B
C
34 lines
884 B
C
|
|
#include "FreeRTOS.h"
|
|
#include "task.h"
|
|
#include "stdio.h"
|
|
#include "modbus.h"
|
|
#include "usart.h"
|
|
|
|
static void scom_485_send(UART_HandleTypeDef *huart, char *str)
|
|
{
|
|
RS485_RW(RS485_WR);
|
|
vTaskDelay(10);
|
|
printf("\r\n");
|
|
usart_printf(huart, "rs485 receive:[%s]\r\n", str);
|
|
printf("printf test_data:[%s]\r\n", str);
|
|
RS485_RW(RS485_RD);
|
|
}
|
|
|
|
void parse_scom_485(st_scom *scom)
|
|
{
|
|
if ((scom == &scom2_rs485) && (scom->rx_flag == TRUE))
|
|
{
|
|
scom->rx_flag = FALSE;
|
|
if ((scom->rx_buff[0] == 0xff) && (scom->rx_buff[1] == 0xff) && (scom->rx_buff[scom->rx_len - 1] == 0xaa))
|
|
{
|
|
// scom_485_send(&huart2, scom->rx_buff);
|
|
RS485_RW(RS485_WR);
|
|
vTaskDelay(10);
|
|
HAL_UART_Transmit(&huart2, scom->rx_buff, scom->rx_len, 0xFFFF);
|
|
RS485_RW(RS485_RD);
|
|
}
|
|
scom->rx_len = 0;
|
|
}
|
|
}
|