2019-12-22 04:20 PM
#define MAX_DATA_LENGTH 50
#define STX 0X02
#define ETX 0X03
u8 g_u8Rs232TxBuffer[105] = {0};
u16 g_u16Rs232Tick = 0;
extern UART_HandleTypeDef huart1;
//(0X02, 0X03 0X30 , 0X11~ 0X18) OFF
//(0X02, 0X03 0X31 , 0X11~ 0X18) ON
u8 Rs232_DataReceived(u8 u8RxData[], u8 u8RxDataLength)
{
u8 u8Rdvalue = 0; //ReceiveDataValue
u8 i=0;
u16 u16Temp =0;
if (u8RxData[0] )
u8Rdvalue = u8RxData[0];
}
void Fun_Uart1_RxReceived(u8 u8RxData)
{
static BOOL s_bDbgRxStartFlag = FALSE;
static u8 s_u8DbgBuffer[64] = {0};
static u8 s_u8DbgCount = 0;
int g_u8Dbg_RxBuffer[64] ={0};
if(s_bDbgRxStartFlag == TRUE)
{
s_u8DbgBuffer[s_u8DbgCount] = (u8)u8RxData;
s_u8DbgCount ++;
if(s_u8DbgCount >= 64)
{
s_u8DbgCount = 0;
s_bDbgRxStartFlag = FALSE;
}
else
{
if(u8RxData == 0x31)
{
s_bDbgRxStartFlag = FALSE;
}
}
}
else
{
if(u8RxData == 0x30)
{
s_bDbgRxStartFlag = TRUE;
s_u8DbgCount = 0;
}
}
}
void Rs232_SendData_(u8 Data)
{
huart1.Instance->DR = Data;
while(__HAL_UART_GET_FLAG(&huart1, UART_FLAG_TXE) == RESET);
}
2019-12-22 04:21 PM
I made a separate c file
2019-12-22 04:24 PM
0x02 0x30 0x03
receive
Confirm and is true
Send
2019-12-22 04:35 PM
also 0x02 0x31 0x03 equal
2019-12-22 04:40 PM
Sorry, we don't even know what the question is.
You're rambling incoherently.
Perhaps you could start from the beginning?
You'd want to wait on TXE before sending data, not after.
You want to read some pattern/sequence and then respond?
2019-12-22 05:08 PM
Receive (0x02 ,0x30 ,0x03)the data, check (0x02 ,0x30 ,0x03)the data and send it again if correct
2019-12-22 05:42 PM
Can you successfully receive any characters currently?
Probably the best approach would be to make a state-machine that progresses as you receive each successive character.
The USART IRQ Handler can fire for each character received.
2019-12-22 06:16 PM
no recieve;..
2019-12-22 06:16 PM
to communicate with rs232
When 0x02,0x30,0x03, check the data value and if this data value is correct, send this value again and ask the program to display off.
stm32f103 and using cubemax.