I am trying to determine the size of the serial buffer.
From other posts, it appears that the size of the serial buffer is defined in nburn/include/constants.h
where it is defined as SERIAL_TX_BUFFERS 2 and SERIAL_RX_BUFFERS 2
Is this correct? This does not seem possible as all my data would be lost at 115,200 baud between a system tick of 50mS.
can anyone tell me where the serial buffer is actually defined and what the values are?
Thanks
Lachlan
Size of serial buffer
Re: Size of serial buffer
The serial buffers are defined in number of Buffer Pool objects. Each buffer pool is about 1500 bytes.
The minor issue is that when you have 2 buffers you can hold 3000 bytes, when you have read 1499 bytes from the first buffer you
still have allocated 2 full buffers, so the buffer can only hole 1501 bytes.....
So given a buffer size of n the buffer holds a minimum of (n-1)*1500+1 bytes and a mximumum of n*1500.
So values less than 2 are problematic.
Your comments also seem to misunderstand the system tick interval.
The tick interval has ZERO impact on anything but timeouts, the blocking task switches and interrupts occur 100% independent of the system tick.
The system tick interval only controls the granularity of timedly and timeouts in blocking functions.
This also suffers from the n to n-1 issue.
A TimeDly(n) can wait from n-1 to n full tick intervals.
Hope that helps...
The minor issue is that when you have 2 buffers you can hold 3000 bytes, when you have read 1499 bytes from the first buffer you
still have allocated 2 full buffers, so the buffer can only hole 1501 bytes.....
So given a buffer size of n the buffer holds a minimum of (n-1)*1500+1 bytes and a mximumum of n*1500.
So values less than 2 are problematic.
Your comments also seem to misunderstand the system tick interval.
The tick interval has ZERO impact on anything but timeouts, the blocking task switches and interrupts occur 100% independent of the system tick.
The system tick interval only controls the granularity of timedly and timeouts in blocking functions.
This also suffers from the n to n-1 issue.
A TimeDly(n) can wait from n-1 to n full tick intervals.
Hope that helps...
Re: Size of serial buffer
Thanks for your response. that explains the serial buffer.
Regarding the timeout, I was referring to my main program having a delay of 1 tick between cycles for checking for serial input. At 115200 baud that means there could be up to 576 bytes accumulated in the serial buffer between each time my program checks.
I would be interested to know if there is anyway to attach a semaphore to the serial receive interrupt so that I can schedule a blocking task to respond immediately a byte is received. This would save having the overhead of a task switch every tick for an activity that needs quick response but is rarely used.
Regards
Lachlan
Regarding the timeout, I was referring to my main program having a delay of 1 tick between cycles for checking for serial input. At 115200 baud that means there could be up to 576 bytes accumulated in the serial buffer between each time my program checks.
I would be interested to know if there is anyway to attach a semaphore to the serial receive interrupt so that I can schedule a blocking task to respond immediately a byte is received. This would save having the overhead of a task switch every tick for an activity that needs quick response but is rarely used.
Regards
Lachlan
Re: Size of serial buffer
You can use a "select" call on your serial file descriptor to wait for incoming data. It uses a semaphore to block until data is available.
Re: Size of serial buffer
thanks. That solves my problem.
regards
Lachlan
regards
Lachlan