Home > Back-end >  Do excuse me the AT command communication module data sending and parse the bosses
Do excuse me the AT command communication module data sending and parse the bosses

Time:04-26

To move far BC20 for example

Hello now encountered a problem with the way is the serial port of STM32V6 HAL library receive indefinite length byte data method two - timer count - http://www.armbbs.cn/forum.php? data reception mode Mod=viewthread& Tid=101391

Such as there is a the AT command

[20:59:24. 685] -> AT 00 + MIPLOPEN=0864

[20:59:24. 692] please receive AT 00 + MIPLOPEN=0864
OK

[20:59:24. 939] please receive
+ MIPLEVENT: 0, 4

[20:59:26. 368] please receive
+ MIPLEVENT: 0, 6

Only received the last message + MIPLEVENT: 0, 6 to prove landing successful judgment conditions is if (STRSTR ((const char *) g_tBspUart pRxBuf, (const char *) "0, 6")!=NULL)

If using conventional reception mode such as serial port interrupt free (note that time because time reason may be divided into three frames

Finish from sent to receive finally a packet of data for a total of nearly 2 s is 2000 ms of time but I can't just for the sake of this article the receiving data timeout setting right especially long

And then there is the AT command programming such as MCU send module, an instruction
HAL_UART_Transmit (& amp; Huart3 close_command_echo, sizeof (close_command_echo), 0 XFFFF);
Delay_ms (1500);
In order to ensure that can receive the message I will add a delay_ms delay

Then made judgment function STRSTR received something right but sometimes I don't know you the problem of time delay to print to a serial port 1 message will be missing

Then send the whole of the AT command and judgment are done with the switch case instruction is done with such basic code repeat

HAL_UART_Transmit (& amp; Huart3 request_signal_quality, strlen (request_signal_quality), 0 XFFFF);
Delay_ms (1500);
If (STRSTR ((const char *) g_tBspUart pRxBuf, (const char *) "OK").=NULL)
{
S the scanf (g_tBspUart pRxBuf, "\ r \ n + CESQ: % [^,], [^,] %, %, ^, %, ^, %, ^, % s \ r \ n \ r \ nOK", & amp; Signal_value_t. Signal_quality \
& Signal_value_t bit_error_rate, & amp; Signal_value_t RSCP, & amp; Signal_value_t. Ec_No \
& Signal_value_t RSRQ, & amp; Signal_value_t. RSRP);
//to structure the information in the array print sometimes lost is blank I don't know has a problem because when receiving?

Clear_buffer ();

Sprintf (return_signal_quality \
"[BC20] the Extend signal_quality: % s \ r \ n bit error rate: % s \ r \ n RSCP: % s \ r \ n Ec_No: % s \ r \ n RSRQ: % s \ r \ n RSRP: % s \ r \ n", \
& Signal_value_t signal_quality, & amp; Signal_value_t. Bit_error_rate \
& Signal_value_t RSCP, & amp; Signal_value_t Ec_No, & amp; Signal_value_t RSRQ, & amp; Signal_value_t. RSRP);

HAL_UART_Transmit (& amp; Huart1 return_signal_quality, strlen (return_signal_quality), 0 XFFFF); //some time printed content is blank that sscanf to format data storage structure in the array isn't occasionally the problems don't know why is it now with time delay
If there is a relationship should be how to deal with the

Memset (return_signal_quality, 0, sizeof (return_signal_quality));

A=3;
G_tBspUart. RxFlag=0;
break;
}
}
  • Related