Directly referencing console/COM1 queues

Discussion about the ZBasic language including the System Library. If you're not sure where to post your message, do it here. However, do not make test posts here; that's the purpose of the Sandbox.
Post Reply
sparxfly
Posts: 21
Joined: 18 December 2005, 20:58 PM
Location: New Zealand
Contact:

Directly referencing console/COM1 queues

Post 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.
Stuart Parker
www.sparxfly.co.nz
dkinzer
Site Admin
Posts: 3120
Joined: 03 September 2005, 13:53 PM
Location: Portland, OR

Re: Directly referencing console/COM1 queues

Post 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
- Don Kinzer
sparxfly
Posts: 21
Joined: 18 December 2005, 20:58 PM
Location: New Zealand
Contact:

Re: Directly referencing console/COM1 queues

Post by sparxfly »

dkinzer wrote: 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
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?
Stuart Parker
www.sparxfly.co.nz
dkinzer
Site Admin
Posts: 3120
Joined: 03 September 2005, 13:53 PM
Location: Portland, OR

Re: Directly referencing console/COM1 queues

Post 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.
- Don Kinzer
Post Reply