.txbuffrq Method
Function: |
For the selected serial port (selection is made through ser.num), pre-requests numpages number of buffer pages (1 page = 256 bytes) for the TX buffer of the serial port. |
Syntax: |
ser.txbuffrq(numpages as {byte | word}) as {byte | word} |
Returns: |
Actual number of pages that can be allocated. |
See Also: |
Part |
Description |
numpages |
Requested numbers of buffer pages to allocate. |
Details
Returns the actual number of pages that can be allocated. The actual allocation happens when the sys.buffalloc method is used. The serial port is unable to TX data if its TX buffer has 0 capacity. The actual current buffer capacity can be checked through the ser.txbuffsize read-only property, which returns the buffer capacity in bytes.
The relationship between the two is as follows: ser.txbuffsize = num_pages * 256 - X (or = 0 when num_pages = 0), where "num_pages" is the number of buffer pages GRANTED through ser.txbuffrq. The "- X" is because a number of bytes is needed for internal buffer variables. X = 17 bytes on 16-bit platforms and 33 bytes on 32-bit platforms. Platform type is specified in your platform documentation.
Buffer allocation will not work if the serial port to which this buffer belongs is opened (ser.enabled = 1 — YES) at the time when sys.buffalloc executes. You can only change buffer sizes of ports that are closed.
Older devices had smaller RAM sizes, so the numpages argument and the value returned by the method were of the byte type. The maximum possible number of pages, therefore, could not exceed 255. On newer devices with larger RAM capacities, this method takes and returns word values. Inspect the method's declaration on the platform you are using to make sure you know the data type it employs.