Arduino Communications Device Naming with udev
Jvaughters (Talk | contribs) |
Jvaughters (Talk | contribs) (→udev) |
||
(5 intermediate revisions by one user not shown) | |||
Line 1: | Line 1: | ||
− | + | <anyweb>http://combustory.com/wiki/ads/ad_rtc_1.html</anyweb> | |
+ | |||
+ | {{default}} | ||
+ | |||
+ | __NOTOC__ | ||
+ | <anyweb>http://combustory.com/wiki/ads/ad_rtc_1.html</anyweb> | ||
{{Article summary start}} | {{Article summary start}} | ||
{{Article summary text|This article covers the configuration of udev for Arduino Communication.}} | {{Article summary text|This article covers the configuration of udev for Arduino Communication.}} | ||
{{Article summary end}} | {{Article summary end}} | ||
− | If you use more than one Arduino with USB or have other USB to Serial devices, then you may find it convenient to make the device have the same name every time you reboot or connect the Arduino. The technique here is shown for an FTDI device, but the same process can be used for just about any USB to | + | ==Summary== |
+ | If you use more than one Arduino with USB or have other USB-to-Serial devices, then you may find it convenient to make the device have the same name every time you reboot or connect the Arduino. The technique here is shown for an FTDI device, but the same process can be used for just about any USB-to-Serial device that the system recognizes. | ||
+ | |||
+ | ==Assumptions== | ||
+ | * You are familiar with the Linux command line | ||
+ | * You understand basic text file configuration methods | ||
+ | * You are familiar with serial communications in Linux | ||
==Installation== | ==Installation== | ||
Line 21: | Line 32: | ||
===udev=== | ===udev=== | ||
− | It can be annoying to have to look up what {{ic|/dev/ttyUSB[0-9]}} the device gets assigned, so it's a good idea to add a simple udev rule that creates | + | It can be annoying to have to look up what {{ic|/dev/ttyUSB[0-9]}} the device gets assigned, so it's a good idea to add a simple udev rule that creates a link to the device when it is plugged in. It used to be possible to rename the device which would leave the ttyUSB[0-9] open for other devices. If you are using a linux kernel that is old enough you can rename the device. However, the linux community has determined the link is the proper method to track the device. Below I will show both methods. |
− | First of all, you will need to find out the serial number of FTDI chip on the | + | First of all, you will need to find out the serial number of FTDI chip on the Arduino. This can be achieved by running the following, assuming your device is plugged in and was assigned to {{ic|/dev/ttyUSB0}}: |
udevadm info --attribute-walk -n /dev/ttyUSB0 | udevadm info --attribute-walk -n /dev/ttyUSB0 | ||
Line 29: | Line 40: | ||
Now add/create the following file: | Now add/create the following file: | ||
− | + | /etc/udev/rules.d/98-arduino.rules | |
− | <nowiki> | + | |
+ | For the old kernels put this in your file: | ||
+ | |||
+ | <pre><nowiki> | ||
SUBSYSTEMS=="usb", ATTRS{serial}=="XXXXXXXX", ATTRS{product}=="FT232R USB UART", ATTRS{idProduct}=="6001", ATTRS{idVendor}=="0403", NAME="arduino_1" | SUBSYSTEMS=="usb", ATTRS{serial}=="XXXXXXXX", ATTRS{product}=="FT232R USB UART", ATTRS{idProduct}=="6001", ATTRS{idVendor}=="0403", NAME="arduino_1" | ||
− | </nowiki>}} | + | </nowiki></pre> |
+ | |||
+ | For the new kernels put this in your file: | ||
+ | |||
+ | <pre><nowiki> | ||
+ | SUBSYSTEMS=="usb", ATTRS{serial}=="XXXXXXXX", ATTRS{product}=="FT232R USB UART", ATTRS{idProduct}=="6001", ATTRS{idVendor}=="0403", SYMLINK+="arduino_1" | ||
+ | </nowiki></pre> | ||
Change 'ATTRS{serial}=="XXXXXXXX"' to the serial on your device and force udev to load the new rule: | Change 'ATTRS{serial}=="XXXXXXXX"' to the serial on your device and force udev to load the new rule: | ||
Line 38: | Line 58: | ||
udevadm control --reload-rules | udevadm control --reload-rules | ||
− | At this point, whenever you plug in the device, the device should be renamed to {{ic|/dev/ | + | At this point, whenever you plug in the device, the device should be renamed to {{ic|/dev/arduino_1}} or a link created. You can rename or link more by adding more lines to the rules file and extract the serial number for each device and of course name it what ever you like. The same process can be used for other USB-to-Serial devices as well. |
==Communication== | ==Communication== | ||
Line 45: | Line 65: | ||
* {{ic|minicom}} | * {{ic|minicom}} | ||
− | minicom -b 115200 -8 -D /dev/ | + | minicom -b 115200 -8 -D /dev/arduino_1 |
* {{ic|screen}} | * {{ic|screen}} | ||
− | screen /dev/ | + | screen /dev/arduino_1 115200 8N1 |
* {{ic|picocom}} | * {{ic|picocom}} | ||
− | picocom -b 115200 -p n -d 8 /dev/ | + | picocom -b 115200 -p n -d 8 /dev/arduino_1 |
+ | * {{ic|putty}} - gui utility | ||
+ | putty -serial /dev/arduino_1 -sercfg 115200,8,n,1,X | ||
+ | * {{ic|plink}} - cli utility | ||
+ | plink -serial /dev/arduino_1 -sercfg 115200,8,n,1,X |
Latest revision as of 18:08, 4 March 2019
Welcome to Combustory
Any questions or comments:
- Send them to - combustor@combustory.com
|
Summary |
---|
This article covers the configuration of udev for Arduino Communication. |
Summary
If you use more than one Arduino with USB or have other USB-to-Serial devices, then you may find it convenient to make the device have the same name every time you reboot or connect the Arduino. The technique here is shown for an FTDI device, but the same process can be used for just about any USB-to-Serial device that the system recognizes.
Assumptions
- You are familiar with the Linux command line
- You understand basic text file configuration methods
- You are familiar with serial communications in Linux
Installation
The drivers for the FTDI chip is included in the kernel, so it should be detected as soon as it's plugged in, and assigned to device /dev/ttyUSB[0-9]
.
To check where it got assigned, run:
dmesg | grep FTDI
The output will contain a line that looks something like this:
usb 1-4.4: FTDI USB Serial Device converter now attached to ttyUSB0
udev
It can be annoying to have to look up what /dev/ttyUSB[0-9]
the device gets assigned, so it's a good idea to add a simple udev rule that creates a link to the device when it is plugged in. It used to be possible to rename the device which would leave the ttyUSB[0-9] open for other devices. If you are using a linux kernel that is old enough you can rename the device. However, the linux community has determined the link is the proper method to track the device. Below I will show both methods.
First of all, you will need to find out the serial number of FTDI chip on the Arduino. This can be achieved by running the following, assuming your device is plugged in and was assigned to /dev/ttyUSB0
:
udevadm info --attribute-walk -n /dev/ttyUSB0
Now add/create the following file:
/etc/udev/rules.d/98-arduino.rules
For the old kernels put this in your file:
SUBSYSTEMS=="usb", ATTRS{serial}=="XXXXXXXX", ATTRS{product}=="FT232R USB UART", ATTRS{idProduct}=="6001", ATTRS{idVendor}=="0403", NAME="arduino_1"
For the new kernels put this in your file:
SUBSYSTEMS=="usb", ATTRS{serial}=="XXXXXXXX", ATTRS{product}=="FT232R USB UART", ATTRS{idProduct}=="6001", ATTRS{idVendor}=="0403", SYMLINK+="arduino_1"
Change 'ATTRS{serial}=="XXXXXXXX"' to the serial on your device and force udev to load the new rule:
udevadm control --reload-rules
At this point, whenever you plug in the device, the device should be renamed to /dev/arduino_1
or a link created. You can rename or link more by adding more lines to the rules file and extract the serial number for each device and of course name it what ever you like. The same process can be used for other USB-to-Serial devices as well.
Communication
To communicate with the device, you can use any of the following, to name a few:
-
minicom
minicom -b 115200 -8 -D /dev/arduino_1
-
screen
screen /dev/arduino_1 115200 8N1
-
picocom
picocom -b 115200 -p n -d 8 /dev/arduino_1
-
putty
- gui utility
putty -serial /dev/arduino_1 -sercfg 115200,8,n,1,X
-
plink
- cli utility
plink -serial /dev/arduino_1 -sercfg 115200,8,n,1,X