Virtual console (tty & pst) and Extended Serial Port

Samir Saidani saidani at info.unicaen.fr
Sat Jun 18 15:18:06 UTC 2005


Hi,

I'm playing a bit with the ability of Squeak to talk with /dev/tty and
/dev/pts/x, and encountered some problems with ExtendedSerialPort.

I first used the classic SerialPort, and with some modification in the
sqUnixSerial.c (
/* portNum      0=/dev/ttyS0, etc. */
/* include 1 byte for NUL at end */
#define PORT_NAME_SIZE 11
static const char serialPortBaseName[] = "/dev/pts/0";

/* #define PORT_NAME_SIZE 10
static const char serialPortBaseName[] = "/dev/tty2"; */),

it is possible to write and read without problems on the virtual
console.

With SerialPortExtended, writing is not a problem, modulo some
modifications attached with this mail. I modified eagain, oonblock,
etc... Maybe should we create a new class
SerialPortExtendedSessionLinux because I found for instance a
different value for eagain (11) in the linux system than the original
one (32 for BSD one I guess)... Probably Linux/GNU system is not unix
:-) Oh yes, comments are welcome on this piece of code ! Because
ExtendedSerialPort seems to have been created with modem communication
in mind, and I've had to do some weird things (see in the attached
file, in primOpenPort:..., (targetFileName value includesSubString:
'ttyS') - set speed of a virtual console gives an error)

Anyway, when I try to read characters, there is a problem : here is a
trace after the function read of ExtendedSerialPortPlugin

(
 bytesRead = read(fd, array+startIndex-1, (size_t)count);
 fprintf (stderr, "after reading buffer number of bytesRead : %i\n", bytesRead );
 fprintf (stderr, "errno : %i\n", errno );

)

after reading buffer number of bytesRead : -1
errno : 11
after reading buffer number of bytesRead : -1
errno : 11
... etc
and when I hit some keys, nothing changes but when I hit return,
suddenly :

after reading buffer number of bytesRead : 1
errno : 0
bafter reading buffer number of bytesRead : 1
errno : 0
oafter reading buffer number of bytesRead : 1
errno : 0
nafter reading buffer number of bytesRead : 1
errno : 0
jafter reading buffer number of bytesRead : 1
errno : 0
oafter reading buffer number of bytesRead : 1
errno : 0
uafter reading buffer number of bytesRead : 1
errno : 0
rafter reading buffer number of bytesRead : 1
errno : 0

it displays the keys and return to the loop :

after reading buffer number of bytesRead : -1
errno : 11
after reading buffer number of bytesRead : -1
errno : 11

...


The behaviour is different with SerialPort, in fact, it is as expected
: bytesRead = 0 when I hit nothing, and 1 when a key is pressed.

My first guess was that the file was incorrectly opened, but after
some modifications (on Linux the way SerialPortExtendedSessionUnix
sets attributes is wrong), and although the openAttributes was set
correctly (O_RDWR|O_NONBLOCK|O_NOCTTY), the same problem holds.

Another question : in which extent could I use XtermEmulator and
VT102Emulator to talk with /dev/pst/1 ? For instance, I would like to
display colored characters on the console and so one, but don't know
how to tackle this issue !

Thanks !

Samir


-- 
Samir SAIDANI				
PhD Student in CS / Doctorant en informatique 	web : http://www.info.unicaen.fr/~saidani
Universite de Caen - Laboratoire GREYC          tel : 02-31-56-74-30
Equipe MAD - Campus II - 14032 Caen Cedex       fax : 02-31-56-76-30

-------------- next part --------------
A non-text attachment was scrubbed...
Name: SerialPortExtendedSessionUnix-*squeakenh-extendedserialplugin.st
Type: application/octet-stream
Size: 3651 bytes
Desc: not available
Url : http://lists.squeakfoundation.org/pipermail/squeak-dev/attachments/20050618/58fadc0e/SerialPortExtendedSessionUnix-squeakenh-extendedserialplugin.obj


More information about the Squeak-dev mailing list