I hve to Receive the serial data throught dock light but cant able to receive the proper data .
Hello Everyone.
I have one doubt.
Im Try to receive the serial data frame from dock light but .I cant able to receive serially.
my Frame HEX Formate :81 03 00 01
This my code:
#include "main.h"
#define LABEL 0x81
#define SSM 0x03
#define SDI 0x00
#define PARITY 0x01
uint16_t Rx_data[5];
uint16_t Read[1];
uint16_t msg[5];
uint16_t *Receive;
uint16_t RX[5];
int main(void)
{
HAL_Init();
SystemClock_Config();
MX_GPIO_Init();
MX_USART1_UART_Init();
while(1)
{
Receive=Transmit();
for(int j=0;j<4;j++)
{
HAL_UART_Transmit(&huart1, (uint8_t*)msg, 5, 10);
sprintf(msg,"%d ",Receive[j]);
}
if(Receive[0]==LABEL)
{
if(Receive[1]==SSM)
{
if(Receive[2]==SDI)
{
if(Receive[3]==PARITY)
{
HAL_UART_Transmit(&huart1, (uint8_t*)msg, 5, 10);
sprintf(msg,"%d ",Receive[0]);
}
}
}
}
}
}
int *Transmit()
{
uint8_t Read[5];
uint8_t RX[5];
for(int i=0;i<4;i++)
{
Read[i]=HAL_UART_Receive (&huart1, Rx_data, 4, 100);
}
return Read;
}
Please give the solution.
Output:Docklight
[TX]=81 03 00 01
[RX]=08 40 50 00
this my Experted output:
[TX]=81 03 00 01
[RX]=81 03 00 01