I use STM32L151CB I have function, which get data on ttl it uint8_t rxb[32]
, then I want it array convert to hex uint8_t AppDate[0] = rxb[0]
, AppDate
must be a hex (0x13
). I have two file uart_board.c the code below, but AppDate
in file main.c. How I must use return in my function
uart_board.c
:
int32_t resDateLidar(void){
uint8_t rxb[32];
uint8_t* lidar[10];
char* str;
char hex_num[3] = {0};
//HAL_UART_Receive_IT( &UartContext[uartId].UartHandle, &UartContext[uartId].RxData, 1 );
if(HAL_UART_Receive(&UartContext[UART_1].UartHandle, &rxb, 32, 300) == HAL_OK){
DelayMs(100);
for (int i = 0; i < 32; i++)
{
if((rxb[i] == 89) && (rxb[i+1] == 89)){
lidar[0] = rxb[i];
lidar[1] = rxb[i + 1];
lidar[2] = rxb[i + 2];
lidar[3] = rxb[i + 3];
lidar[4] = rxb[i + 4];
lidar[5] = rxb[i + 5];
lidar[6] = rxb[i + 6];
lidar[7] = rxb[i + 7];
lidar[8] = rxb[i + 8];
lidar[9] = rxb[i + 9];
lidar[10] = rxb[i + 10];
//str = (char*)lidar;
}
}
//HAL_UART_Transmit(&UartContext[UART_1].UartHandle, &rxb, 32, 300);
//HAL_UART_Transmit(&UartContext[UART_1].UartHandle, &lidar, 10, 300);
DelayMs(1000);
}
return lidar;
}
I have sensor LIDAR, lidar send 9 byte, I can HAL_UART_Transmit
data, on ttl.
loop for to filter my data and only send 9 bytes of information instead of 32.
I want to assign AppDate[0] = lidar[0],AppDate[1] = lidar[1],AppDate[2] = lidar[2]
.
(for example lidar send on my stm 89 89 194 0 13 134 13 160 55)