Hi, Nathan can probably answer this better than I can, but I will try... I use HSERIAL on several robots with XBees and the DIY remote control that I converted to XBees (details up on Lynxmotion forums) Note: I use hserial2 on Arc32
You have a couple of choices here. When you enable HSERIAL, it installs it's own interrupt handlers for the hardware serial port. It automatically does buffer your input and output into queues. As it uses hardware serial interrupts, your program can not set and use them at the same time...
There are several tricks you can do here. What I do in my main processing when it is convenient for me is to check to see if I have any data waiting for me. If so I go and process it. There are a few different ways to doing this.
a) hserstat command - For some reason I have had problems with this in the past.
b) Roll my own, with assembly language.
Code:
bHSerinHasData var byte
mov.b @_HSERINSTART, r0l
mov.b @_HSERINEND, r0h
sub.b r0h, r0l
mov.b r0l, @BHSERINHASDATA
if (not bHSerinHasData) then
return 0
Note The variables for hserial2 looks like _HSERIN2START...
c) You do an HSerin of 1 byte with a zero timeout. Obviously you will probably need to set it up such that you can process that byte..
Or if you really do want to do everything in the background, then you will need to write your own equivalent of the HSERIAL subsystem. That is you don't define that you are using HSERIAL. You define your own handlers and then you need to write your own init code that enables those interrupts, sets the appropriate baud rates and other like options and enable the transmitter and receiver... (I would not recommend).
Good Luck
Kurt