changing_20the_20serial_20buffer_20size
Differences
This shows you the differences between two versions of the page.
Next revision | Previous revision | ||
changing_20the_20serial_20buffer_20size [2018/03/31 13:19] – external edit 127.0.0.1 | changing_20the_20serial_20buffer_20size [2024/01/05 00:22] (current) – external edit 127.0.0.1 | ||
---|---|---|---|
Line 2: | Line 2: | ||
//by Richard Russell, December 2012//\\ \\ When you open a serial port for input, a buffer (queue) is automatically created to hold incoming data until it is read by your program. This buffer is typically 4096 bytes in size (although that may vary according to the version of Windows, serial port driver etc.).\\ \\ A 4096-byte buffer will be sufficient in almost all situations. At the highest standard baud rate (115200 baud) it corresponds to more than 1/3 of a second of storage, so as long as your program services the serial port at least three times a second no data should be lost. Typically a program will check the serial port much more often than that - if it doesn' | //by Richard Russell, December 2012//\\ \\ When you open a serial port for input, a buffer (queue) is automatically created to hold incoming data until it is read by your program. This buffer is typically 4096 bytes in size (although that may vary according to the version of Windows, serial port driver etc.).\\ \\ A 4096-byte buffer will be sufficient in almost all situations. At the highest standard baud rate (115200 baud) it corresponds to more than 1/3 of a second of storage, so as long as your program services the serial port at least three times a second no data should be lost. Typically a program will check the serial port much more often than that - if it doesn' | ||
+ | <code bb4w> | ||
chan% = OPENUP(" | chan% = OPENUP(" | ||
IF chan%=0 ERROR 100, " | IF chan%=0 ERROR 100, " | ||
SYS " | SYS " | ||
+ | </ | ||
Here **rxqueue%** is the requested buffer size in bytes; the serial port parameters shown are of course only an example. It is important to call **SetupComm** immediately after the serial port has been opened, and before any data transfer takes place.\\ \\ If you need to know whether the request to change the buffer size has been successful, you can discover the current size using the **GetCommProperties** API: | Here **rxqueue%** is the requested buffer size in bytes; the serial port parameters shown are of course only an example. It is important to call **SetupComm** immediately after the serial port has been opened, and before any data transfer takes place.\\ \\ If you need to know whether the request to change the buffer size has been successful, you can discover the current size using the **GetCommProperties** API: | ||
+ | <code bb4w> | ||
DIM commprop{wPacketLength{l&, | DIM commprop{wPacketLength{l&, | ||
\ dwReserved1%, | \ dwReserved1%, | ||
Line 15: | Line 18: | ||
SYS " | SYS " | ||
+ | </ | ||
The buffer size is returned in the **commprop.dwCurrentRxQueue%** member. | The buffer size is returned in the **commprop.dwCurrentRxQueue%** member. |
changing_20the_20serial_20buffer_20size.1522502348.txt.gz · Last modified: 2024/01/05 00:18 (external edit)