Thursday, 11 January 2018

USB-to-Serial on OS X/macOS - an Example

Problem:

I have a USB-to-Serial adapter that I need to use on a Mac. How do I configure it, and how do I read/write to it?

I am already partially familiar with using serial ports on Linux and Windows.

Notes:

This post is written as a reminder and contains just enough information to reproduce these steps in the future. It is not thorough. A little Google may be required in order to clarify or expand on some points.

The following steps were verified to work with macOS 10.12.6, with a very specific USB-to-serial adaptor that happened to work fine with Apple's default drivers. Your mileage may vary with other configurations and devices.

Steps Overview:

  1. Before you start, if drivers do not already exist then install them.
  2. Plug USB-to-Serial adaptor into your Mac
  3. Find info in "About this Mac" - More below
  4. Setup null modem and speed using Network Preferences - More below
  5. Find the device's path to access the Linux/POSIX way - More below

Step: Find adapter info:

To find out some basic information about your USB-to-Serial adapter, use the following steps.

  1. Go to "About This Mac" and click "More Info..." or "System Report..." (depending on your OS version)
  2. Find your device in the system report under "USB", and make note of what is there. This will help you identify your device in other steps.

Step: Configure serial communication using Network Preferences

To configure your USB-to-Serial adapter speed, etc., for use with other apps on your Mac, use the following steps.

  1. Open "System Preferences" and open the "Network" preferences pane
  2. Select your USB-to-Serial adapter if it is in the list, or add it then select it
  3. Click "Advanced..."
  4. Configure as null modem with the desired baud rate. The example screenshot below shows the attached device configured to 9600 bps (as well as some other configuration)

Step: Access your usb-to-serial port the Linux/Posix way:

  • to find the path to your serial port, in Terminal type in the following command and find your device:
    ioreg -c IOSerialBSDClient | grep usb
  • in the example screenshot above, the serial port is "/dev/cu.usbserial-FTAN3DQ" and an example of its use in VirtualBox is shown in the screenshot below.
  • (optional) to test your serial port directly, you can use the "screen" command in Terminal. More on this command in Apple's screen man page

    References:

  • No comments:

    Post a Comment