42 lines
1.3 KiB
C
42 lines
1.3 KiB
C
/*
|
|
* @Author: wujunchao wujunchao@wuxismart.com
|
|
* @Date: 2024-12-24 08:18:25
|
|
* @LastEditors: wujunchao wujunchao@wuxismart.com
|
|
* @LastEditTime: 2024-12-25 09:23:34
|
|
* @FilePath: \signal_generator\App\MODBUS\modbus.c
|
|
* @Description: 这是默认设置,请设置`customMade`, 打开koroFileHeader查看配置 进行设置: https://github.com/OBKoro1/koro1FileHeader/wiki/%E9%85%8D%E7%BD%AE
|
|
*/
|
|
|
|
#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;
|
|
}
|
|
}
|