elixir-circuits / circuits_uart

Discover and use UARTs and serial ports in Elixir
Apache License 2.0
189 stars 48 forks source link

Same USB / Serial Converter works in 485 mode on Mac but not Nerves #179

Open CaptChrisD opened 3 weeks ago

CaptChrisD commented 3 weeks ago

Setup

Expected Behavior

The port should be able to open on both system in RS485 mode.

Actual Behavior

I am using the waveshare USB -> RS485 convertor (uses FTDI FT232RL) and on the Mac and in Nerves. On the Mac I am able to open the port but on Nerves I get {:error, :enotty}

Steps to Reproduce the Problem

      serial_port = "/dev/ttyUSB0" # "/dev/cu.usbserial-A10KV16U" on Mac
      {:ok, port} = Circuits.UART.start_link()

      Circuits.UART.open(
        port,
        serial_port,
        speed: 250_000,
        rs485_enabled: true,
        stop_bits: 2,
        parity: :none
      )

Additional Information

The USB adapter is detected on Nerves and loads sio driver

[    9.259140] usb 1-1: New USB device found, idVendor=0403, idProduct=6001, bcdDevice= 6.00
[    9.259167] usb 1-1: New USB device strings: Mfr=1, Product=2, SerialNumber=3
[    9.259177] usb 1-1: Product: FT232R USB UART
[    9.259185] usb 1-1: Manufacturer: FTDI
[    9.259218] usb 1-1: SerialNumber: A10KV16U
[    9.262701] ftdi_sio 1-1:1.0: FTDI USB Serial Device converter detected
[    9.262940] usb 1-1: Detected FT232RL
[    9.263907] usb 1-1: FTDI USB Serial Device converter now attached to ttyUSB0

The port can be opened with rs485_enabled: false