Skip to main content

Show Posts

This section allows you to view all Show Posts made by this member. Note that you can only see Show Posts made in areas you currently have access to.

Messages - Fixer

1
Bus Pirate Support / Re: PirateScope - yet another BP oscilloscope client
[quote author="tgvaughan"]
Also, if your bus pirate shows up on a different device file to /dev/ttyUSB0, you'll need to change this under File->Set Bus Pirate Device.  (There's currently no permanent config file, so you'll have to do this every time you start the program or do a search and replace in the script itself.)
[/quote]

Following is the process I follow to make sure the multiple devices that use a FTDI serial chip are assigned to permanent names. This works on Ubuntu/Debian systems and should work on any Linux system that uses udev.

=======================================================================================
Adding a persistant name to a USB device, or altering permissions for that device.

1) Determining the Vendor and Product ID

  Plug in the device and run the command

Code: [Select]
lsusb

ie:

[tt:]Bus 002 Device 002: ID 051d:0002 American Power Conversion Uninterruptible Power Supply
Bus 002 Device 001: ID 1d6b:0001 Linux Foundation 1.1 root hub
Bus 001 Device 023: ID 0403:6001 Future Technology Devices International, Ltd FT232 USB-Serial (UART) IC
Bus 001 Device 008: ID 0424:2504 Standard Microsystems Corp. USB 2.0 Hub[/tt:]

The device I am interested in is the FTDI device, since I know this is the USB to serial device installed.

2) Now I need to find out the unique ID for this device, since many products use the FTDI chip for USB->serial conversion. To do this, you need to look in the '/var/log/messages' file for the message printed by the kernel when it added the device.

Code: [Select]
tail /var/log/messages

[tt:]Sep 22 19:15:41 athalon kernel: [368961.864982] USB Serial support registered for FTDI USB Serial Device
Sep 22 19:15:41 athalon kernel: [368961.865204] ftdi_sio 1-1.2:1.0: FTDI USB Serial Device converter detected
Sep 22 19:15:41 athalon kernel: [368961.865283] usb 1-1.2: Detected FT232RL
Sep 22 19:15:41 athalon kernel: [368961.865286] usb 1-1.2: Number of endpoints 2
Sep 22 19:15:41 athalon kernel: [368961.865288] usb 1-1.2: Endpoint 1 MaxPacketSize 64
Sep 22 19:15:41 athalon kernel: [368961.865290] usb 1-1.2: Endpoint 2 MaxPacketSize 64
Sep 22 19:15:41 athalon kernel: [368961.865292] usb 1-1.2: Setting MaxPacketSize 64
Sep 22 19:15:41 athalon kernel: [368961.865656] usb 1-1.2: FTDI USB Serial Device converter now attached to ttyUSB0
Sep 22 19:15:41 athalon kernel: [368961.865675] usbcore: registered new interface driver ftdi_sio
Sep 22 19:15:41 athalon kernel: [368961.865677] ftdi_sio: v1.5.0:USB FTDI Serial Converters Driver[/tt:]

This tells us that the device is currently assigned /dev/ttyUSB0

3) Once we have the current device ID, we can look at it in more detail and see what the serial number of the product is:

Code: [Select]
udevadm info -a -n /dev/ttyUSB0|grep serial


[tt:]    SUBSYSTEMS=="usb-serial"
    ATTRS{serial}=="A700eLPP"
    ATTRS{serial}=="0000:00:13.2"[/tt:]

You can look at the output in more detail, but the line that is of interest to us is the first line:

ie: ATTRS{serial}=="A700eLPP"

4) We have to now make a couple of command decisions.

        a) what owner/group to use
        b) what permissions to use

Since the device is going to be for my unique use, I will use my information. This is user=fixer, group=fixer.

5) With all the above information, we can create a UDEV rule for assigning this device each time it is plugged in.

Local udev rules go in /etc/udev/rules.d on ubuntu systems

Code: [Select]
'cd /etc/udev/rules.d'

'vim 99-local.rules

insert the line:
[tt:]SUBSYSTEM=="tty", ATTRS{idVendor}=="0403", ATTRS{idProduct}=="6001", ATTRS{serial}=="A700eLPP", SYMLINK+="buspirate", OWNER="fixer", GROUP="fixer", MODE="0660"[/tt:]

save the file and then plug in the device.

6) Testing!

Code: [Select]
ls -al /dev/ | grep ttyUSB*

[tt:]lrwxrwxrwx   1 root root             7 2010-12-06 17:40 buspirate -> ttyUSB0
crw-rw----   1 fixer  fixer       188,   0 2010-12-06 17:40 ttyUSB0[/tt:]

WooHoo!! IT WORKS!!

As you can see, the original device is still there, but now it is owned by my user and in my group. There is also a symlink name that I can now use in any scripts or configurations that may be specific to this device.

You can use any username or any group name that you want in the udev rule. You can also alter the permissions.

For example, if I want one of my web pages to read a set of coordinates from a GPS reciever,

The apache server on ubuntu runs as the www-data group by default. So the udev rule would become:
[tt:]SUBSYSTEM=="tty", ATTRS{idVendor}=="0403", ATTRS{idProduct}=="6001", ATTRS{serial}=="A700eLPP", SYMLINK+="gpsdongle", GROUP="www-data", MODE="0660"[/tt:]

I have removed the 'OWNER' parameter as it is not needed and changed the group to the one that apache belongs to.

=======================================================================================

Hope this helps the Linux users out there.

--
Fixer

( ! ) Fatal error: Uncaught exception 'Elk_Exception' with message 'Please try again. If you come back to this error screen, report the error to an administrator.' in /var/www/dangerousprototypes/forum/sources/database/Db-mysql.class.php on line 696
( ! ) Elk_Exception: Please try again. If you come back to this error screen, report the error to an administrator. in /var/www/dangerousprototypes/forum/sources/database/Db-mysql.class.php on line 696
Call Stack
#TimeMemoryFunctionLocation
10.01272274896session_write_close ( )...(null):0
20.01302406472ElkArte\sources\subs\SessionHandler\DatabaseHandler->write( )...(null):0
30.01302407248Database_MySQL->query( ).../DatabaseHandler.php:119
40.05912545960Database_MySQL->error( ).../Db-mysql.class.php:273