Page 1 of 1
Fighting against Buffer Overruns
Posted: Tue Jul 12, 2016 5:46 pm
by Tabulous
Curently i have a setup of this
SD1 = GSM modom
SD2 = GPS Receiver
#if !defined(SERIAL_BUFFERS_SIZE) || defined(__DOXYGEN__)
#define SERIAL_BUFFERS_SIZE 512
#endif
/*
* SERIAL driver system settings.
*/
#define STM32_SERIAL_USE_USART1 TRUE
#define STM32_SERIAL_USE_USART2 TRUE//FALSE
#define STM32_SERIAL_USE_USART3 FALSE
#define STM32_SERIAL_USART1_PRIORITY 7//12
#define STM32_SERIAL_USART2_PRIORITY 7//12
#define STM32_SERIAL_USART3_PRIORITY 12
But still i hit buffer overrun with GPS.
GPS will be sending, NMEA strings 4/5 of them every second.......
Re: Fighting against Buffer Overruns
Posted: Tue Jul 12, 2016 6:38 pm
by Giovanni
Hi,
What is the port speed?
Giovanni
Re: Fighting against Buffer Overruns
Posted: Wed Jul 13, 2016 8:29 am
by Tabulous
GPS is @ 9600 Baud
GSM is at 115200, but the comms to it are small (AT commands) and sporadic
also here is my receiving thread for ref.
Code: Select all
static THD_FUNCTION(ThreadGPS, arg)
{
msg_t c;
eventflags_t flags;
event_listener_t elGPSdata;
(void)arg;
chRegSetThreadName("gpsd");
chEvtRegisterMask(chnGetEventSource(&SD2),
&elGPSdata,
EVENT_MASK(1));
while( TRUE )
{
flags = chEvtGetAndClearFlags(&elGPSdata);
if(flags & SD_OVERRUN_ERROR)
{
TGL_DEBUG(DBG_MASK_GPS, "Overrun GPS !\r\n"); // keep hitting this !!!!
}
if(flags & CHN_INPUT_AVAILABLE)
{
do
{
c = chnGetTimeout(&SD2, TIME_IMMEDIATE);
if ( c != Q_TIMEOUT )
{
decodeNMEAstateMachine( (char)c );
}
}
while (c != Q_TIMEOUT);
}
chEvtWaitOneTimeout(EVENT_MASK(1), MS2ST(10));
}
}
Re: Fighting against Buffer Overruns
Posted: Wed Jul 13, 2016 9:17 am
by Giovanni
hi,
The overflow can be caused by two possible problems:
1) When the driver is not able to serve USART interrupts quickly enough so there is an HW overflow condition.
2) When the application is not able to empty the queue fast enough, the ISR is not able to write in the queue the received byte. This can mitigated by increasing the queue size in halconf.h.
By placing breakpoints in the driver ISR you could try to understand what kind of overflow you are getting.
Giovanni
Re: Fighting against Buffer Overruns
Posted: Wed Jul 13, 2016 9:20 am
by Giovanni
Note that there is a discussion ongoing about use of the UART driver (with DMA) in this specific scenario:
viewtopic.php?f=25&t=3441Giovanni
Re: Fighting against Buffer Overruns
Posted: Wed Jul 13, 2016 10:03 am
by Tabulous
Giovanni wrote:Note that there is a discussion ongoing about use of the UART driver (with DMA) in this specific scenario:
viewtopic.php?f=25&t=3441Giovanni
Think this is a different propersition to me, as there baud rates are very high, i'm only at 9600 so i should not really been having issues.
I'll have alook at the Interrupts and see what i can dig up.