Getting the /dev/ttyA* name

Discussion in 'Module Connector (MC)' started by John Gwinner, Oct 25, 2019.

  1. John Gwinner

    John Gwinner New Member

    I've experimented with cables a LOT as I tracked down my module problem.

    We have two modules, and need both; an X4M200 and an X4M300

    I noticed that the modules will change device names sometimes. I've seen /dev/ttyACM2 and /dev/ttyACM3 even.

    lsusb gives a different device but will show the same ID (hardware ID), which is weird, they are different modules - I guess they are really both X4M02's

    Code:
    pi@caremon5:~/sensor/Python $ dir /dev/ttyA*
    crw-rw---- 1 root dialout 166,  0 Oct 24 19:49 /dev/ttyACM0
    crw-rw---- 1 root dialout 166,  1 Oct 24 19:49 /dev/ttyACM1
    crw-rw---- 1 root dialout 204, 64 Oct 20 17:17 /dev/ttyAMA0
    pi@caremon5:~/sensor/Python $ lsusb
    ...
    Bus 001 Device 034: ID 03eb:6124 Atmel Corp. at91sam SAMBA bootloader
    Bus 001 Device 035: ID 03eb:6124 Atmel Corp. at91sam SAMBA bootloader
    Bus 001 Device 001: ID 1d6b:0002 Linux Foundation 2.0 root hub
    
    What is the recommended manner of looping through all of the possible /dev/ttyACM* devices to see if one of them is an X4M200? We have both the X4M200 and XM4300, and it looks like sometimes they have the same /dev/ttyACMX number?

    Also, can the Module Connector look for a specific module, or do we just have to repetitively try looping through /dev/ttyACMX and check to see if mc.get_x4m200 works, or will it work with a 300?

    How do we know we're talking to the right sensor?

    == John ==
     
  2. Allen Wu

    Allen Wu Moderator Staff Member

    Hi John,

    This is what I would do to find out:

    Before plug in device 1, for example X4M200:
    pi@raspberrypi:~/Desktop/git_hub_mc_eg $ ls -l /dev/ttyA*
    crw--w---- 1 root tty 204, 64 Sep 26 03:17 /dev/ttyAMA0

    After plug in X4M200:
    pi@raspberrypi:~/Desktop/git_hub_mc_eg $ ls -l /dev/ttyA*
    crw-rw---- 1 root dialout 166, 0 Oct 25 10:52 /dev/ttyACM0
    crw--w---- 1 root tty 204, 64 Sep 26 03:17 /dev/ttyAMA0

    --> The system assigned /dev/ttyACM0 to X4M200

    Then, we plug in device 2, for example X4M300:
    pi@raspberrypi:~/Desktop/git_hub_mc_eg $ ls -l /dev/ttyA*
    crw-rw---- 1 root dialout 166, 0 Oct 25 10:52 /dev/ttyACM0
    crw-rw---- 1 root dialout 166, 1 Oct 25 10:52 /dev/ttyACM1
    crw--w---- 1 root tty 204, 64 Sep 26 03:17 /dev/ttyAMA0

    --> The system assigned /dev/ttyACM1 to X4M300

    You can also try python example: “xt_modules_print_info.py”
    https://github.com/xethru/XeThru_Mo...s/blob/master/PYTHON/xt_modules_print_info.py

    $ python3.5 xt_modules_print_info.py

    It will try to auto-detect the device (last plug in device).

    Allen
     
    Last edited: Oct 25, 2019