Serial Port access from Squeak

Todd Coram tcoram at pobox.com
Tue Jan 13 04:20:05 UTC 1998



Dan Ingalls wrote:

> BASIC (and, esp, DOS) has had to deal with this for a long time.  They use file names like
>
>         "COM2:2400,N,8,1"
>
> to set the port specs.  I wrote a whole real-time weather station controller using this kind of access.  BASIC lets you test if a character is waiting with EOF, so you can poll for input, and then you can put that on a timer interrupt if you want to do other work in between.
>
> I think that SOME such general and portable serial access should be a priority in Squeak, but I don't know how far we'll get with real serial interrupts in the immediate future, since it tends to be somewhat complex and platform-dependent.
>
>         - Dan

  I certainly don't want to get involved with kernel-level stuff (interrupts and such) at this time -- that water is too deep for me.

Let me pull back a little... To implement the level of support I need to interface with a fairly simple serial device (query/response with the occasional "unsolicited event" byte) I just need to wrap system level APIs, such as:
    setSpeed
    setDataBits
    setParity
    setStopBits
    getByte
    putByte - (with appropriate flow control and queuing?)  ...etc...

and it would be nice to have:
    sendBreak
    setDTR
    rxReadyCount  - (a byte is ready to read)
    txReadyToSend ... etc..

The interface is  pretty portable and the results are pretty predictable.  However, the implementation is highly system dependent. (For example, in Unix these APIs would be provided by ioctl(), read(), write(), and select() or poll()). Any queueing logic (backoff buffering until
ready-to-send, etc) would be portable.

Anyway, a kind reader of this list, Andy van Tol, pointed me to Alejandro F. Reimondo's Windows API for Squeak 1.23.  This sounds like a good place for me to start.

Since the UART does most of the work for me (buffering, flow control, etc), it isn't critical that I have "kernel level" interrupts. Most devices on a serial port (except mice, tablets and other "busy" input devices) do just fine with "user level" programming (polling, blocking,
queuing, etc).

Thanks for the comments.  Hopefully Alejandro's work will help me out. Otherwise, I may move my work over to Unix (where I am more comfortable) and do some inital I/O primitives there. Once I work out a decent protocol for Serial access, get some (Win95 or Linux) primitives
working and my camera talking, I will post the info here (if anyone is interested).

Any additional insights, comments or help are welcome.

--
Todd Coram (Maroc Ddot)
tcoram at BLaCKSMITH.com | tcoram at pobox.com

Sardonic slaughterer of sacred cows.





More information about the Squeak-dev mailing list