Robert Epprecht wrote:
> 
> I'm writing an editor for some musical equipment with gforth on Linux.
> 
> I open /dev/midi with OPEN-FILE and can send and get MIDI input with
> WRITE-FILE and READ-FILE.
> 
> Now I need a word to ckeck for midi input without blocking the program
> flow (READ-FILE waits until the MIDI message arrives).
> 
> I think I would have to open /dev/midi with O_NONBLOCK set (open(2)).
> How can I do that with gforth?

If you want to do that, you should use the C interface.

> I assume that `read-file'       c-addr u1 wfileid - u2 wior
> would return immediately after such a non-blocking open call and set
> u2 to zero, if there was no input on /dev/midi.

Maybe.  While you are dealing with the C interface, you might just as
well use read(2), instead of read-file (which uses fread(3)).

> But I do not really know if that's the right way to do it...

You could also try to use

key?-file       ( wfileid -- n )                gforth  key_q_file

and

key-file        ( wfileid -- n )                gforth  paren_key_file

to do it character-by-character (if you are sure you know the length
of the message, and that it's there, you can also try READ-FILE).

- anton

---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to