2022-12-20 01:34 AM
Hi,
I'm trying to control a LTE module (sim7600e) using an AEK-MCU-C4MLT1 with a serial protocol (UART). The goal is to transmit a simple AT COMMAND, by following these simple steps:
I have built a simple state machine in order to follow these simple steps, and I attach the code at the bottom.
I have done 3 tests to see if the code works properly:
Then I tried to connect the Chorus 4M to the LTE module, but the communication does not work. In particular the Chorus receives the PB DONE, but thein it fails at sending the AT command, even if it enters in the tx interrupt I am not able to see the AT command at the receiver, thus implies that the code does not enter in the state in which it reads the OK in response.
Do you ever had a similar problem?
Do you know how to fix this issue?
Thanks in advance,
Simone.
uint8_t typedChar[1] = " ";
char message[64];
char text[1000];
uint8_t u8State = 0;
uint32_t StartTime = 0;
uint32_t timeout = 2000;
uint8_t u8Tx_Cmplt = 0;
int main(void) {
/* Initialization of all the imported components in the order specified in
the application wizard. The function is generated automatically.*/
componentsInit();
/* Uncomment the below routine to Enable Interrupts. */
irqIsrEnable();
sd_lld_start(&SD6, &serial_config_custom_uart);
(void)sd_lld_read(&SD6, typedChar, 1);
/* Application main loop.*/
for ( ; ; ) { if(u8State == 0 )
{
if(strstr((char *)text,"PB DONE\r\n"))
{
memset(text,0,sizeof(text));
u8State++;
}
}
else if(u8State == 1 )
{
strncpy (message, "\r\nATE1\r\n", sizeof("\r\nATE1\r\n"));
(void)sd_lld_write(&SD6, (uint8_t *) message, (uint16_t) strlen(message)); u8State++;
}
else if(u8State == 2 )
{
if(u8Tx_Cmplt == 1)
{
u8Tx_Cmplt = 0;
u8State++;
}
StartTime = sysGetMilliseconds();
}
else if(u8State == 3 )
{ if(strstr((char *)text,"\r\nOK\r\n"))
{
memset(text,0,sizeof(text));
u8State++;
}
if (StartTime + timeout > sysGetMilliseconds())
{
u8State=1;
}
}
else if(u8State == 4 )
{
u8State++;
}
osalThreadDelayMilliseconds(1000);
}
}
void tx_callback(SerialDriver *sdp){
(void)sdp;
u8Tx_Cmplt = 1;
}
void rx_callback(SerialDriver *sdp){
(void)sdp;
strcat(text, (char *)typedChar);
}
Solved! Go to Solution.
2022-12-22 08:31 AM
Hello,
it works better on my side with this code:
int main(void) {
/* Initialization of all the imported components in the order specified in
the application wizard. The function is generated automatically.*/
componentsInit();
/* Enable Interrupts */
irqIsrEnable();
sd_lld_start(&SD5, &serial_config_custom_uart);
/* Application main loop.*/
for (;;) {
(void) sd_lld_read(&SD5, typedChar, 1);
if (u8State == 0) {
if (strstr((char*) text, "PB DONE\r")) {
memset(text, 0, sizeof(text));
u8State++;
}
} else if (u8State == 1) {
u8Tx_Cmplt = 0;
strncpy((void*)message, "\r\nATE1\r\n", sizeof("\r\nATE1\r\n"));
(void) sd_lld_write(&SD5, (uint8_t*) message,
(uint16_t) strlen((void*)message));
u8State++;
} else if (u8State == 2) {
if (u8Tx_Cmplt > 0) {
u8Tx_Cmplt = 0;
u8State++;
}
StartTime = sysGetMilliseconds();
} else if (u8State == 3) {
if (strstr((char*) text, "OK\r")) {
memset(text, 0, sizeof(text));
u8State++;
}
else if (StartTime + timeout > sysGetMilliseconds()) {
//memset(text, 0, sizeof(text));
u8State = 1;
}
} else if (u8State == 4) {
strncpy((void*)message, "\r\nEND\r\n", sizeof("\r\nEND\r\n"));
(void) sd_lld_write(&SD5, (uint8_t*) message,
(uint16_t) strlen((void*)message));
memset(text, 0, sizeof(text));
u8State = 0;
}
osalThreadDelayMilliseconds(50);
}
}
Buon Natale !
2022-12-22 08:31 AM
Hello,
it works better on my side with this code:
int main(void) {
/* Initialization of all the imported components in the order specified in
the application wizard. The function is generated automatically.*/
componentsInit();
/* Enable Interrupts */
irqIsrEnable();
sd_lld_start(&SD5, &serial_config_custom_uart);
/* Application main loop.*/
for (;;) {
(void) sd_lld_read(&SD5, typedChar, 1);
if (u8State == 0) {
if (strstr((char*) text, "PB DONE\r")) {
memset(text, 0, sizeof(text));
u8State++;
}
} else if (u8State == 1) {
u8Tx_Cmplt = 0;
strncpy((void*)message, "\r\nATE1\r\n", sizeof("\r\nATE1\r\n"));
(void) sd_lld_write(&SD5, (uint8_t*) message,
(uint16_t) strlen((void*)message));
u8State++;
} else if (u8State == 2) {
if (u8Tx_Cmplt > 0) {
u8Tx_Cmplt = 0;
u8State++;
}
StartTime = sysGetMilliseconds();
} else if (u8State == 3) {
if (strstr((char*) text, "OK\r")) {
memset(text, 0, sizeof(text));
u8State++;
}
else if (StartTime + timeout > sysGetMilliseconds()) {
//memset(text, 0, sizeof(text));
u8State = 1;
}
} else if (u8State == 4) {
strncpy((void*)message, "\r\nEND\r\n", sizeof("\r\nEND\r\n"));
(void) sd_lld_write(&SD5, (uint8_t*) message,
(uint16_t) strlen((void*)message));
memset(text, 0, sizeof(text));
u8State = 0;
}
osalThreadDelayMilliseconds(50);
}
}
Buon Natale !
2023-01-09 02:21 AM
Thank you very much!