[Info-vax] Programming the serial port on an Alphaserver 200
JF Mezei
jfmezei.spamnot at vaxination.ca
Sun Mar 1 23:49:55 EST 2009
One great advantage of the $QIO interface for the terminal drive is AST
processing.
You specify the address of a subroutine to be executed automatically
(think of it as an interrupt) when the IO completes.
So you can have i your mainline:
status = SYS$QIO(bunch of params, myAST, myASTparam );
then:
int myAST(unsigned long astparam)
{
check the iostatus.status to see how the io completed (success, timeout,
error etc)
iostatus.count contains the number of bytes read.
so you process (quickly) the data you juyst read and then:
status = SYS$QIO(bunch of params, myAST, astparam );
which reissues the next IO which will execute myAST when it completes,
making an infinite loop to read characters.
}
the astparam could contin a pointer to a structure that includes the
channel, iostatus block, address of buffers and any other stuff you need
that is specific to that channel.
If you are reading variable length lines with no idea on the lengths:
you start with
SYS$QIO to read a single byte with no timeout.
when you do get that character, you can do issue $QIO with a 512 byte
buffer and a 1 second timeout. So when the data has been sent, the QIO
times out ad gives you whatever number of characters have been sent.
You can also specify a terminator mask wich causes the QUI to terminate
upon receipt of any specificed character.
So if you know that your "packet" is terminated with <ETX> then you make
a QIO that reads up to 512 bytes with a 1 second timeout and a
terminator mask that specified ETX. This way, the instant the ETX is
received, the QIO completes without needing to timeout.
The VMS terminal driver has great functionality. But you need to go over
the doc a few times to understand it.
More information about the Info-vax
mailing list