Operating System - OpenVMS
1753883 Members
7523 Online
108809 Solutions
New Discussion юеВ

terminal $QIO test for read

 
SOLVED
Go to solution
Alex Chupahin
Super Advisor

Re: terminal $QIO test for read

Dear Hein,
thank you very much for code example.
If the
sys$qiow(efn,ttchan,IO$_SENSEMODE|IO$M_TYPEAHDCNT,&iosb, 0,0, &vkbuff,0,0,0,0,0);

be able to sleep while nothing to read vkbuff.number is equal to 0 this should be very great.
But it returns immediately.
Hein van den Heuvel
Honored Contributor

Re: terminal $QIO test for read



>> If the ...IO$_SENSEMODE|IO$M_TYPEAHDCNT ...
be able to sleep while nothing to read

Ah, now I understand your question better.
I was only answering the first question

>> I'm need to check if terminal have something to read.

That's exactly what the sensemode does but not what you want, nor as others pointed out what you want to use as it leads to polling algorithms.

>> Mailbox driver has a good IO$M_READATTN

Yes, that warn but takes no action.
This is not available in the terminal driver.
The closest thing is the OUTBAND setmode, but that initiated with selected control characters. Not generic.

And I suppose you could issue a 1 byte read with AST, but then that byte will be in the buffer. That becomes awkward quickly.

You'll probably want to create a wrappers to be able to give a 'read_terminal' routine which does not actually do a qio, but returns the data from a qio which already completed.

You can decide whether the program processes each read completely before issuing the next, or just keeps on reading fulling multiple buffers if need be.

As John indicated it is often handy to use SYS$DCLAST to get the show rolling. Probably passing control block parameter with IOSB and buffer and whatever else is handy to keep all context pointed to in one parameter.

The IOSB is needed if you do fancy terminator handling.... but for anything fancy yo may want to look at SMG or similar.

Cheers,
Hein
Hoff
Honored Contributor

Re: terminal $QIO test for read

If that's the actual C code being tested, consider adding return status and IOSB status checks into the C code.

Status checks are a defensive coding technique that often helps track the triggers of errors, and can provide an effective means of avoiding a application stackdump when something gets tangled and trips on an earlier and unhandled error within the application.

Also consider moving away from hard-coding a static EFN (and particularly not using an EF that the lib$get_ef call "owns" and can pass out) and moving to an allocated event flag or (for something akin to this case) to ENF$C_ENF "don't care" event flag, too.

ENF$C_ENF is defined in EFNDEF.H