Re: unbuffered getc() ?
- Posted by tubby.toast at ntlworld.com May 12, 2003
- 396 views
Erm, no. That won't work through the serial port, or will it? Sorry, I'm rubbish at explaining things - it's the serial port I'm trying to read from. chris. > > Did you try get_key() and/or wait_key()? > > -- Brian > > chris wrote: > > > > Hi, > > I am using Euphoria (2.4 alpha) in Linux to interface with a serial LCD > > screen and keypad. Sending output is no problem (once I'd remembered to > > use > > flush() ) but I'm having trouble reading from the keypad. I tried > > something > > like the following: > > > > integer lcd, key > > > > lcd=open("/dev/ttyS1","ub") > > while 1 do > > puts(lcd,{#FE,#26}) > > -- this tells the device to return the contents of its key buffer, or if > > the > > -- buffer is empty, to return 0x00 > > flush(lcd) > > key=getc(lcd) --just locks up here! > > print(1,key) > > end while > > > > This doesn't work because according to the Euphoria docs: > > > > "File input using getc() is buffered, i.e. getc() does not actually go > > out > > to the disk for each character. Instead, a large block of characters > > will be > > read in at one time and returned to you one by one from a memory buffer. > > When getc() reads from the keyboard, it will not see any characters > > until > > the user presses Enter. Note that the user can type control-Z, which the > > operating system treats as "end of file". -1 will be returned. " > > > > So it seems that getc() won't return anything until Euphoria sees a line > > feed or an EOF. So my question (if you've read this far): how can I get > > a > > Euphoria program to read a single byte, immediately and without dealing > > with > > buffers, from a file descriptor. Is there a standard C function I can > > easily wrap? (I'm not very good with C) > > > > I hope that made some sort of sense, > > chris. > > > > > > > TOPICA - Start your own email discussion group. FREE! > >