Showing posts with label serial port. Show all posts
Showing posts with label serial port. Show all posts

Tuesday, December 12, 2017

How to remove unused USB serial ports in windows and change port numbers

Sometimes when you connect usb to serial adapter to your pc it gets com number with very high numbers. Not every software can handle that big port numbers. For example some programs cannot work with port numbers higher than com20. So if 20 com ports are in use it is impossible to use that software.  That happens because every time you plug in new USB to serial adapter it gets new com port number, and even if you do not use it anymore port is marked as "in use".
To delete these ports open elevated command prompt: find cmd, right click on it and select "run as administrator".
Then type:

set DEVMGR_SHOW_NONPRESENT_DEVICES=1

after that run device manager:

devmgmt.msc

Enable "Show hidden devices" in the "View" menu, and uninstall grayed-out COM ports

After that you can change your device com port number: right click on it, select properties, then  advanced setting.

Tuesday, February 21, 2017

Fixed names for usb devices in linux

usb devices appear as /dev/ttyUSB<somenumber> devices. When you plug it to another USB port <somenumber> is unpredictable and you always wasting time to figure out what is the right port number for your device.
To fix this, you can create "udev" rules, so every time you plug in your device there will be the same sym link created for that particular device.

Check vendor and product id with lsusb command:

~# lsusb
Bus 001 Device 011: ID 0403:6001 FTDI FT232 USB-Serial (UART) IC 
Bus 001 Device 010: ID 0403:6001 FTDI FT232 USB-Serial (UART) IC 

ok, we have 2 FTDI chips and we can't distinguish which chip is from what device.
Let's check device serial number(we know that it is connected to ttyUSB0):

~# udevadm info -a -n /dev/ttyUSB0 | grep '{serial}'
 ATTRS{serial}=="0000:00:14.0"

Then go to /etc/udev/rules.d and create file 99-usb-serial.rules
~#sudo touch 99-usb-serial.rules

open file for edit and add these line:

SUBSYSTEM=="tty", ATTRS{idVendor}=="0403", ATTRS{idProduct}=="6001", ATTRS{serial}=="0000:00:14.0", SYMLINK+="arduino"

Now everytime when you plug in your board it will be accesible via symlink /dev/arduino

~# ls -l /dev/arduino 
lrwxrwxrwx 1 root root 7 Nov 15 20:11 /dev/arduino -> ttyUSB0

~# ls -l /dev/ttyUSB0
crw-rw---- 1 root uucp 188, 0 Nov 15 20:11 /dev/ttyUSB1