From email I received from Nathan:
AcidTech wrote:
HSERSTAT mode arguments now include the choice of uart 1 or uart 2.
modes 0 to 7 are the same as before but are specifically for uart1. Then 8 to 15 are the same modes but for uart 2.
From Some older manuals I had:
Quote:
HSERSTAT
The HSERSTAT command lets you check the status and/or clear the
hardware serial port buffers. Before using this command you must
use the SETHSERIAL command (see page 122) to set the correct
baud rate.
Also, before using the HSERSTAT command, a program must use
the ENABLEHSERIAL command. The ENABLEHSERIAL command
enables serial communications, and is required for the HSERSTAT,
HSERIN, and HSEROUT commands.
Syntax
hserstat funct{,label}
funct is a value from 0 to 6 that determines the function of the
hserstat command according to the following list:
Value Function
0 Clear input buffer
1 Clear output buffer
2 Clear both buffers
3 If input data is available go to label
4 If input data is not available go to label
5 If output data is being sent go to label
6 If output data is not being sent go to label
label is an optional argument (use with values 3 – 6) that
specifies the destination jump address.
Examples
The following example will wait for input data to be available before
continuing, then input 3 bytes of data from the hardware serial port.
ant var byte
bat var byte
cat var byte
enablehserial
sethserial h2400 ; 2400 baud
hserstat 0 ; clear input buffer
getdata
hserstat 4, getdata ; loop if no data in buffer
hserin [ant,bat,cat] ; get 3 bytes of data
The following example will wait for all data to be sent before
continuing program execution. The variable "ant" is a 20 element
array which has been defined and populated.
enablehserial
sethserial h2400 ; 2400 baud
for x = 0 to 19
hserout [ant(x)] ; output the array contents
next
notyet
hserstat 5, notyet ; wait until all data is sent
Since data output may be slower than program execution, it may be
necessary to wait before proceeding, depending on program and
peripheral devices
Nathan mentioned in the email 0-7 for UART1... Not sure what 7 is...
Note: earlier when I tried to use hserstat to check for input available, I had problems with the program resetting. Not sure why it is a very simple function, so I rolled my own. Since then Nathan worked on the SSC-32 emulation for Arc32 and added a new function (hserinnext), which is followed by an argument. If the argument is a 1 or 2 this says to get the next character from the specified hardware serial port, if none is available it will wait. If the argument is 0x81 or 0x82 it says to return the first character from the queue. If none is available it will return -1 and not wait... So for example in my XBee code I have a function to return the next packet of data. At the start it has:
Code:
_fapiWaitForInput var byte
APIRecvPacket[_fapiWaitForInput]:
' First see if the user wants us to wait for input or not
; hserstat HSERSTAT_INPUT_EMPTY, _TP_Timeout ; if no input available quickly jump out.
; Well Hserstat is failing, try rolling our own.
if not _fapiWaitForInput then
; use the new hserinnext instead of assembly to see if there is input...
#ifdef BASICATOMPRO28
if (hserinnext 0x81) = -1 then
#else
if (hserinnext 0x82) = -1 then
#endif
return 0;
endif
endif
I hope that helps
Kurt