Queues and Fifos

Discussion to talk about software related topics only.
Post Reply
tpannone
Posts: 69
Joined: Fri Feb 15, 2013 1:04 pm

Queues and Fifos

Post by tpannone »

I see in the uCOSLibrary documents the OSQInit and OSFifoInit functions for creating queues and fifos to pass messages between tasks. Are there any other queue or fifo functions within the NB runtime libraries for dealing with data?
User avatar
pbreed
Posts: 1080
Joined: Thu Apr 24, 2008 3:58 pm

Re: Queues and Fifos

Post by pbreed »

There is the fifo buffer....
But if your doing this for uarts, just leave the normal open serial uart handling alone and use that as is...

ir use read agains the openserial fd and be done with cooking your own...

If the buffer gets overrun and you loose charactors there are two things to do...

1)Make sure you have not long duration user written interrupts (convert these to high priority task turned on via semaphore)
and no long duration USER_ENTER_CRITICAL

2)You can increase the amount of space reserved for the serial receive buffer..
Several ways to do this...easiest
change the predef.h value of SERIAL_RX_BUFFERS each count of these buffers is good for ~1500 bytes of data buffer in the recieve system.
Rebuild EVERYTHING, system,platform and project after touching predef.h
tpannone
Posts: 69
Joined: Fri Feb 15, 2013 1:04 pm

Re: Queues and Fifos

Post by tpannone »

Thanks @pbreed. Regarding SERIAL_RX_BUFFERS, are you sure it's in predef.h? I'm looking at predef.h and there's not much in there. I also looked in serial.h and serinternal.h without finding it.
tpannone
Posts: 69
Joined: Fri Feb 15, 2013 1:04 pm

Re: Queues and Fifos

Post by tpannone »

Nevermind @pbreed. I found SERIAL_RX_BUFFERS in constants.h. It is currently set to 2 bytes.
User avatar
TomNB
Posts: 538
Joined: Tue May 10, 2016 8:22 am

Re: Queues and Fifos

Post by TomNB »

I think that is 2 buffers, not bytes. Each buffer is 1500 bytes
tpannone
Posts: 69
Joined: Fri Feb 15, 2013 1:04 pm

Re: Queues and Fifos

Post by tpannone »

Thanks @TomNB. So looking at the comments in constants.h, if I want to follow step #2 above and increase the size of of the SERIAL_RX_BUFFERS, I have to increase ETHER_BUFFER_SIZE.
User avatar
TomNB
Posts: 538
Joined: Tue May 10, 2016 8:22 am

Re: Queues and Fifos

Post by TomNB »

No, you don't want to change that. Just add more buffers by increasing SERIAL_RX_BUFFERS.
tpannone
Posts: 69
Joined: Fri Feb 15, 2013 1:04 pm

Re: Queues and Fifos

Post by tpannone »

Thanks for explaining that. I would not have guessed to increase the buffer size add more buffers.
User avatar
pbreed
Posts: 1080
Joined: Thu Apr 24, 2008 3:58 pm

Re: Queues and Fifos

Post by pbreed »

Depending on how things are in the buffer system...

The total storage space availible to the seriaal system varies from...

(SERIAL_RX_BUFFERS-1)*1550 to (SERIAL_RX_BUFFERS)*1500

For for the default of
N=2 its 1501 to 3000

N=10 =13501 to 15000

The other suggestion about not having long ISR's and USER_ENTER_CRITICAL'S is also important.

Also If you care at all about performance you must run a release build, not a debug build.


If these fixes to the basic serial; port don't do it, there is one more level of thing you can do, but its a bit tedious...
You can set up a circular buffer in SRAM and a level 7/Non maskable Uart receive interrupt.
What you can do in a non-maskable level 7 interrupt is EXTREMELY limited,
so to communicate form the L7/NMI back to the normal world you must set up an additional isr that the
L7/NMI can trigger to notify the RTOS that "You have mail" :-)
Post Reply