Unix serial code: first version

Ned Konz ned at bike-nomad.com
Sat Jul 15 23:39:24 UTC 2000


Hi all,

I wrote the Linux version of the Unix serial code this AM.

It's now on CVS at Sourceforge, which means that everyone
should be able to try it.

It is set up in non-blocking mode, which should allow polling
(though I'd much rather see async reads). This is because 
the existing code doesn't have any provision for async reads.

For those of you who aren't familiar with the serial API
that's there, it provides this high-level interface
(more or less):

	openPort: portNum	opens port /dev/ttyS0 through /dev/ttyS9
	close
	readInto: aStringOrByteArray startingAt: index
	nextPutAll: bytes

So if there aren't any bytes yet, and you do a read, you
get an empty string without waiting.

And if you try to write more bytes than can be written at
once (which depends on how many bytes are already buffered),
some of them don't get written, and you don't find out. But
you don't block.

Now, the primitive at least returns the number of bytes
read or written, so you could do better than nextPutAll: for
a high-level write interface.

I'm not too happy with the serial plugin API within Squeak;
it's missing several things that I've found useful in the past
when dealing with arbitrary serial devices:

* async operation (how does one signal a semaphore from C?)
 (this would include timeouts, of course)

* setting line parameters (other than the common ones like
data rate, input/output flow control, xon/xoff chars, stop bits,
data bits, and parity)

* changing line parameters on an open port

* flushing input or output without closing the port

* detecting break signals, or parity or framing errors

* sending breaks

* error reporting (how is this handled generally? I don't see
any easy way to pass back errno...)

* reading or setting modem control line states (beyond DTR,
maybe DCD, and RTS/CTS) (or waiting for change in their status)

So my question is this: Are people depending on the current
implementation of the serial plugin, or is this new? Has the
SerialPort interface stayed constant for a while?

I'd change it (or, I guess, I could extend the current plugin
and SerialPort class) if I could do so without upsetting too
many people.

One possibility would be to support the ioctl() call, allowing
for arbitrary set/get commands to be done (most of the above).
And the set and get termios calls. (I don't know how much they
overlap the ioctl()).

Of course, line status (and serial port presence) can be read from
/proc/tty/driver/serial, but the existing code isn't doing this.

What are you using the serial stuff for?

Would you like to see an improvement?

(And, BTW, I didn't touch MIDI. Why is it in with the serial
stuff, anyway?)

-- 
Ned Konz
currently: Stanwood, WA
email:     ned at bike-nomad.com
homepage:  http://bike-nomad.com
-------------- next part --------------
A non-text attachment was scrubbed...
Name: sqUnixSerialAndMIDIPort.c
Type: application/octet-stream
Size: 12702 bytes
Desc: not available
Url : http://lists.squeakfoundation.org/pipermail/squeak-dev/attachments/20000715/205289f1/sqUnixSerialAndMIDIPort.obj


More information about the Squeak-dev mailing list