How to use the serial port on MacOS X?

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
1 message Options
Reply | Threaded
Open this post in threaded view
|

How to use the serial port on MacOS X?

Olivier Auverlot
Hi,

I try to use the serial port to communicate with an Arduino. On Linux, no problemo. I can open the serial port with the following code:

| serialPort baudRate comPortNumber | 
baudRate := 31250. 
  comPort := '/dev/ttyACM0'. 
 
  serialPort := SerialPort new 
    baudRate: 31250; 
               dataBits: 8; 
               stopBitsType: 1; 
               parityType: 0; 
              yourself. 

        "the port is closed to ensure that it will be free"
serialPort close.
(serialPort openPort: comPort) isNil 
ifTrue: [ ^self error: 'COM port not available' ] 
ifFalse: [ serialPort inspect ].
serialPort close.

But on MacOS X (10.11.6), the same code used with /dev/cu.usbmodel1411 doesn't run. The error is "Cannot open '/dev/cu.usbmodel1411'". I'm sure that is the correct serial port. If I type "more -f /dev/cu.usbmodel1411" in a terminal, the rx/tx leds of the Arduino are blink.

Someone has an idea about this problem that is not specific of the Arduino but concerns the generic usage of the serial port with Pharo?

Best regards
Olivier

ps: I can't test on Windows but I'm interested by a feedback.