How to use the serial port on MacOS X?

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
5 messages 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.
Reply | Threaded
Open this post in threaded view
|

Re: How to use the serial port on MacOS X?

Ben Coman
Just a few random thoughts...

Can you load an echo program into the Arduino to check comms is not getting corrupted? 


Is the problem with a USB3 port? 
Try using a USB2 port.


Are you using an FTDI cable?

try disabling Apple's Virtual Com Port and using FTDI's per section 7...

or using a non-FTDI serial adpator.

cheers -ben


On Mon, Mar 13, 2017 at 12:21 AM, olivier auverlot <[hidden email]> wrote:
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.

Reply | Threaded
Open this post in threaded view
|

Re: How to use the serial port on MacOS X?

Olivier Auverlot
Hi Ben,

I don't think that the problem concerns the USB port or the cable because:

* I have tested with a simple Perl script (with the Device::SerialPort module) and all is ok. 
* In a shell, I can activate the rx/tx leds of the Arduino with the command "more -f /dev/cu.usbmodel1411".
* I can use the Arduino IDE to program the card and send my binaries.

If my Pharo code is correct, I suspect a problem in the serial plugin for MacOS X. I tried unsuccessful with Pharo 5 and Pharo 6.

Best regards
Olivier :)

2017-03-13 8:01 GMT+01:00 Ben Coman <[hidden email]>:
Just a few random thoughts...

Can you load an echo program into the Arduino to check comms is not getting corrupted? 


Is the problem with a USB3 port? 
Try using a USB2 port.


Are you using an FTDI cable?

try disabling Apple's Virtual Com Port and using FTDI's per section 7...

or using a non-FTDI serial adpator.

cheers -ben


On Mon, Mar 13, 2017 at 12:21 AM, olivier auverlot <[hidden email]> wrote:
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.


Reply | Threaded
Open this post in threaded view
|

Re: How to use the serial port on MacOS X?

Ben Coman
Hi Olivier,  

You'd only mentioned the middle one, which I didn't think was sufficient.
But I agree the other two are strong tests indicating the USB is okay. 
Sorry I don't have OSX to test further.

But a question for me to learn something, what makes these two ports equivalent test points between your Pharo code and your "more" test.
* /dev/ttyACM0
/dev/cu.usbmodel1411

To be specific, did ttyACM0 with Perl and the IDE ? 

cheers -ben

On Mon, Mar 13, 2017 at 3:27 PM, olivier auverlot <[hidden email]> wrote:
Hi Ben,

I don't think that the problem concerns the USB port or the cable because:

* I have tested with a simple Perl script (with the Device::SerialPort module) and all is ok. 
* In a shell, I can activate the rx/tx leds of the Arduino with the command "more -f /dev/cu.usbmodel1411".
* I can use the Arduino IDE to program the card and send my binaries.

If my Pharo code is correct, I suspect a problem in the serial plugin for MacOS X. I tried unsuccessful with Pharo 5 and Pharo 6.

Best regards
Olivier :)

2017-03-13 8:01 GMT+01:00 Ben Coman <[hidden email]>:
Just a few random thoughts...

Can you load an echo program into the Arduino to check comms is not getting corrupted? 


Is the problem with a USB3 port? 
Try using a USB2 port.


Are you using an FTDI cable?

try disabling Apple's Virtual Com Port and using FTDI's per section 7...

or using a non-FTDI serial adpator.

cheers -ben


On Mon, Mar 13, 2017 at 12:21 AM, olivier auverlot <[hidden email]> wrote:
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.



Reply | Threaded
Open this post in threaded view
|

Re: How to use the serial port on MacOS X?

Ben Coman
I don't know how pertinent this is, but to answer my own question...


/dev/tty.* and /dev/cu.* and AppleUSBFTDI

Difference between cu.* and tty.*

cheers -ben

On Mon, Mar 13, 2017 at 8:13 PM, Ben Coman <[hidden email]> wrote:
Hi Olivier,  

You'd only mentioned the middle one, which I didn't think was sufficient.
But I agree the other two are strong tests indicating the USB is okay. 
Sorry I don't have OSX to test further.

But a question for me to learn something, what makes these two ports equivalent test points between your Pharo code and your "more" test.
* /dev/ttyACM0
/dev/cu.usbmodel1411

To be specific, did ttyACM0 with Perl and the IDE ? 

cheers -ben

On Mon, Mar 13, 2017 at 3:27 PM, olivier auverlot <[hidden email]> wrote:
Hi Ben,

I don't think that the problem concerns the USB port or the cable because:

* I have tested with a simple Perl script (with the Device::SerialPort module) and all is ok. 
* In a shell, I can activate the rx/tx leds of the Arduino with the command "more -f /dev/cu.usbmodel1411".
* I can use the Arduino IDE to program the card and send my binaries.

If my Pharo code is correct, I suspect a problem in the serial plugin for MacOS X. I tried unsuccessful with Pharo 5 and Pharo 6.

Best regards
Olivier :)

2017-03-13 8:01 GMT+01:00 Ben Coman <[hidden email]>:
Just a few random thoughts...

Can you load an echo program into the Arduino to check comms is not getting corrupted? 


Is the problem with a USB3 port? 
Try using a USB2 port.


Are you using an FTDI cable?

try disabling Apple's Virtual Com Port and using FTDI's per section 7...

or using a non-FTDI serial adpator.

cheers -ben


On Mon, Mar 13, 2017 at 12:21 AM, olivier auverlot <[hidden email]> wrote:
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.