sdRead fails to unblock after missing a packet
Posted: Thu Nov 06, 2014 8:37 pm
I'm working on a project which, among other things, uses XBee wireless modules for communication between nodes. The code runs on an STM32F103, and I'm using ChibiOS 2.6.6.
To talk to the modules, I'm using the standard chbios serial HAL, (sdRead and sdWrite). This works consistently and reliably most of the time, but if I pause the debugger and miss a packet I can get the firmware in a state where my serial recieve thread blocks -- there's serial data coming in, I can verify the underlying ISR is firing correctly, but nothing comes through to the thread itself. I wouldn't worry about this much, since it's produced by a debugging context, but it also reliably occurs when I attempt a transaction with a high-volume of serial data -- in this case, sending a firmware image to a bootloader.
I've found that this seems to only affect the call to sdRead which was blocking at the time that the interruption occurs -- adding a timeout allows me to fall back into normal communication. However, this still results in a dropped packet, which is not really acceptable in the bootloader context.
I was hoping I could get some insight as to possible solutions. I note one place where Giovanni says the UART driver rather than the serial driver should be used for high-speed, packet based communications. Could this be an acceptable alternative?
To talk to the modules, I'm using the standard chbios serial HAL, (sdRead and sdWrite). This works consistently and reliably most of the time, but if I pause the debugger and miss a packet I can get the firmware in a state where my serial recieve thread blocks -- there's serial data coming in, I can verify the underlying ISR is firing correctly, but nothing comes through to the thread itself. I wouldn't worry about this much, since it's produced by a debugging context, but it also reliably occurs when I attempt a transaction with a high-volume of serial data -- in this case, sending a firmware image to a bootloader.
I've found that this seems to only affect the call to sdRead which was blocking at the time that the interruption occurs -- adding a timeout allows me to fall back into normal communication. However, this still results in a dropped packet, which is not really acceptable in the bootloader context.
I was hoping I could get some insight as to possible solutions. I note one place where Giovanni says the UART driver rather than the serial driver should be used for high-speed, packet based communications. Could this be an acceptable alternative?