Page 1 of 1
Directly referencing console/COM1 queues
Posted: 27 September 2018, 14:44 PM
by sparxfly
I would like to use the generic queue functions to parse the console in queue, but can't see how to reference the queue.
Can this be done, and if so, how?
Or do I need to turn off the console (option console none) and create COM1 and its queues programatically.
Re: Directly referencing console/COM1 queues
Posted: 27 September 2018, 15:58 PM
by dkinzer
sparxfly wrote:I would like to use the generic queue functions [...]. Can this be done, and if so, how?
Register.RxQueue and Register.TxQueue return the address of the receive queue and transmit queue, respectively. The value of each of these registers is an integral value so it needs to be passed through the CByteArray() function to render it usable as a queue.
Code: Select all
If (GetQueueCount(CByteArray(Register.RxQueue)) > 0) Then
' do something
End If
Those two register values are documented here:
www.zbasic.net/doc/ZBasicRef.php?page=81
Also, there is additional information on the system queues and how to set up replacement queues here:
http://www.zbasic.net/doc/ZBasicRef.php?page=74
Re: Directly referencing console/COM1 queues
Posted: 27 September 2018, 16:31 PM
by sparxfly
Thanks for the quick reply Don- I had just logged on to say 'found it' when I saw your reply.
I had meanwhile elected to disable the console (option console none) and define COM1 and its queues programmatically, simply for symmetry with the code I am using to define a second software UART- it feels more in control (?).
Is there any downside in terms of code/memory space in doing so over using the console- ie does 'console none' remove all console stuff?
Re: Directly referencing console/COM1 queues
Posted: 27 September 2018, 17:44 PM
by dkinzer
sparxfly wrote:does 'console none' remove all console stuff?
Option Console None removes everything related to Com1 - interrupt handlers, driver code, rx and tx queues, etc. any of which (except for the queues) will be added back if an
OpenCom() call exists in the application that refers to Com1.
This can be beneficial for a minimal application that doesn't use the console (to reduce code size and RAM use). Also, using
Option Console None is preferred over closing Com1 and re-opening it with explicitly defined queues because the latter practice will leave the pre-defined queues in the code, essentially wasting that RAM.