Serial port on OS X

Ned Konz ned at bike-nomad.com
Fri May 16 01:38:23 UTC 2003


On Thursday 15 May 2003 06:11 pm, Russel Howe wrote:
> Hello all,
>       I am using Squeak on Mac OS X (VM 3.5.0beta4, image 3.5.5180)
> and am trying to communicate over a serial port.  I have a Keyspan
> USB adapter which I know is working; I can read and write to this
> device from the command line (cat/echo/stty) with no trouble, but I
> can't figure out how to get at it in Squeak.
>       Under Linux,
> port <- SerialPort new baudRate:57600; openPort:1
> opens /dev/ttyS1 and readByteArray/writeByteArray provide all the
> access I need.
> Under OS X, the openPort call never fails (even for ridiculous port
> numbers) and I never get any data from a readByteArray.  What
> device name is Squeak looking for?  Is there some other way to get
> at the serial port in Squeak?  Is the serial port even supported on
> OS X?  Any hints would be appreciated.
> Russel Howe

Hi Russel,

I've recently run into this same problem with my work on the Bionode ( 
http://www.microship.com/bionode/ ).

The problem is that the Squeak Mac serial support dates back to when 
Macs actually had serial ports.

Your Keyspan adapter is some /dev/usbtty... device somewhere. 

The Mac serial support doesn't know about Unix devices.

The best suggestion would be to make a fixed version of the Apple 
serial plugin that works with arbitrary devices. If I were making a 
new serial plugin today, I would base it on the async file support. 
The old serial plugin API requires polling (I matched the API of the 
old Mac serial plugin when I wrote the Unix one, unfortunately).

Another suggestion would be to build (or get someone else to build) a 
VM based on the Unix code. Then you can symlink your /dev/usbwhatever 
device to /dev/ttyS1 (for instance) and use the Unix serial support. 
I know that Ian's sources have been compiled on Mac OS/X, but I think 
you need the X11 libs and headers to get it to go.

Another is to try to use the async file support that's already built 
in. However, you won't be able to set the data rate and other 
parameters using this. If you use stty first to set it, it may stay 
set adequately to use this way.

I've attached some very early (and not really working) code that I was 
trying that used the AsyncFile for serial; perhaps it will give you 
something to work with.

I don't think I ever tried it on OS/X, but if the Mac VM has the 
AsyncFile plugin you might be able to get it working.

-- 
Ned Konz
http://bike-nomad.com
GPG key ID: BEEA7EFE
-------------- next part --------------
A non-text attachment was scrubbed...
Name: AsyncFileSerial-nk.1.cs
Type: text/x-squeak-changeset
Size: 5948 bytes
Desc: not available
Url : http://lists.squeakfoundation.org/pipermail/squeak-dev/attachments/20030515/30c4bbdc/AsyncFileSerial-nk.1.bin


More information about the Squeak-dev mailing list