Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

enumerate/0 does not seem to work in WSL #53

Open
ejpcmac opened this issue Nov 8, 2018 · 5 comments
Open

enumerate/0 does not seem to work in WSL #53

ejpcmac opened this issue Nov 8, 2018 · 5 comments

Comments

@ejpcmac
Copy link

ejpcmac commented Nov 8, 2018

Setup

  • Version: 1.2.0
  • OS: Windows (WSL)
  • Platform: PC

Description

When a serial port is visible as COM5 on Windows, it is accessible as /dev/ttyS5 in the WSL. After ensuring access rights are OK, it is possible to open the connection with nerves_uart:

iex> {:ok, uart} = Nerves.UART.start_link
{:ok, #PID<...>}
iex> Nerves.UART.open(uart, "/dev/ttyS5")
:ok

However, it is not enumerated properly.

Expected Behavior

Nerves.UART.enumerate/0 should return a list of available serial ports.

Actual Behavior

Nerves.UART.enumerate/0 always returns %{}, even if a device is connected.

Steps to Reproduce the Problem

  1. Setup a project with nerves_uart in WSL.

  2. Connect a device and get its COM port in the device manager on Windows.

  3. In the WSL shell, do:

     $ sudo chmod 666 /dev/ttySx
    

    where x is the COM port number in COMx.

  4. Assert the communication works properly.

  5. Try to enumerate the ports with nerves_uart.

@ejpcmac ejpcmac changed the title enumerate/0 does not seem to work enumerate/0 does not seem to work in WSL Nov 8, 2018
@fhunleth
Copy link
Contributor

fhunleth commented Nov 8, 2018

Thanks for the report! I've never tried nerves_uart in WSL. This is good to know that there's a gap. I'll add it to my list of things to look at. If you have any insight into getting this to work, I'd certainly appreciate it.

@ejpcmac
Copy link
Author

ejpcmac commented Nov 8, 2018

I’ve tried this at work on a colleage’s PC who needed a small tool I’ve developed: it was my first time in WSL. I thought it would be simpler to setup as I use Nix to handle the environment and WSL is expected to behave as Linux, but heh, that’s Windows. I’m not completely surprised in the end. Except this, all seems to work properly.

If I find something interesting I’ll let you know or provide a patch.

@michaelkschmidt
Copy link

michaelkschmidt commented Nov 8, 2018

Do the serial ports actually work from WSL? I thought those were all "dummy" files at the moment

Sorry I should have read closer. That is cool that the serial ports are actually working

@ejpcmac
Copy link
Author

ejpcmac commented Nov 8, 2018

@michaelkschmidt Reading this article from Microsoft, it seems it is. I’ve been able to get a :ok from Nerves.UART.open/2 after chmod-ing. I’ve not tried yet to actually communicate with the device as it is a custom protocol and it was on a colleage’s computer who had to left. If I can manage to get some time on it tomorrow, I’ll try to:

  1. actually communicate with the device by selecting the port by hand in my custom protocol library,
  2. look at the contents of /sys/class/tty to see if there is some differences with the real Linux one.

@jmerriweather
Copy link

I can confirm that the serial ports work properly from WSL. I don't use Nerves.UART.enumerate from WSL as it doesn't return anything

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants