I have a function that makes a request and waits for a response. For the request I use the uartSendFullTimeout() function and for the response I use the uartReceiveTimeout()function. In some cases, it is not necessary to wait for a response.
This function sends commands to a device connected to the serial port. The first time, he sent a request but I'm not waiting for a response. The second time, the function waits for a response. In this case, when I try to make the request I get a stack overflow.
The stack is:
Code: Select all
GDB Hardware Debugger (25/9/19 16:22) (Suspended)
Thread [1] (Suspended: Signal 'SIGINT' received. Description: Interrupt.)
13 chSysHalt() chsys.c:206 0x08002570
12 chSchGoSleepS() chschd.c:313 0x08002570
11 chSchGoSleepTimeoutS() chschd.c:383 0x080025da
10 chThdSuspendTimeoutS() chthreads.c:776 0x08002e94
9 osalThreadSuspendTimeoutS() osal.h:760 0x08002e94
8 uartSendFullTimeout() hal_uart.c:430 0x08002e94
7 serial_port_send() serial_port.c:76 0x08002e94
6 prime_serial_port_send() prime_serial_port.c:130 0x08002e94
5 prime_send_packet_.part.4() prime.c:229 0x08002e94
4 prime_send_packet_() prime.c:239 0x08002f34
3 prime_set_acq_params_() prime.c:325 0x08002fa2
2 prime_prologue() prime.c:430 0x08003f6c
1 main() main.c:231 0x08003f6c
It stops at line 385 of the uartReceiveTimeout() function:
Code: Select all
/* Waiting for result.*/
msg = osalThreadSuspendTimeoutS(&uartp->threadtx, timeout);
if (msg != MSG_OK) {
*np -= uartStopSendI(uartp);
}
osalSysUnlock();
This is the function that invokes it:
Code: Select all
msg_t serial_port_send(serial_port_datatype_t *sp, size_t *np,
const void *txbuf, sysinterval_t timeout,
bool physically) {
if ((sp == NULL) || (sp->sdp == NULL) || (!sp->is_initialize)) {
return MSG_RESET ;
}
msg_t result;
if (!physically) {
result = uartSendTimeout(sp->sdp, np, txbuf, timeout);
}
else {
result = uartSendFullTimeout(sp->sdp, np, txbuf, timeout);
}
return result;
}
I don't see what's missing. Can someone help me?
Thank you