General > General Technical Chat

Idea for a first YouTube Video

<< < (8/13) > >>

nctnico:

--- Quote from: shabaz on March 24, 2024, 02:47:28 am ---I'm using Windows normally, but gave it a shot, this is currently working for me (with Ubuntu):

I plugged in the BP5, and typed (a wide screen is needed, otherwise it will truncate the grep'd result on the right side!):


--- Code: ---udevadm info /dev/ttyACM0 | grep ttyACM1
--- End code ---

I made a note of the line containing DEVPATH= and then typed:


--- Code: ---udevadm info /dev/ttyACM1 | grep ttyACM1
--- End code ---

For me, the two results were:
/devices/pci0000:00/0000:00:1d.0/usb1/1-1/1-1.2/1-1.2:1.0/tty/ttyACM0
/devices/pci0000:00/0000:00:1d.0/usb1/1-1/1-1.2/1-1.2:1.2/tty/ttyACM1

Then, I created (as root user) in folder /etc/udev/rules.d a file called 97-buspirate.rules:


--- Code: ---# BP5 udev rules file
#

SUBSYSTEM=="tty", ENV{ID_VENDOR_ID}=="1209", ENV{ID_MODEL_ID}=="7332", MODE="0666", DEVPATH=="/devices/pci0000:00/0000:00:1d.0/usb1/1-1/1-1.2/1-1.2:1.0/tty/ttyACM0", SYMLINK+="bp0"

SUBSYSTEM=="tty", ENV{ID_VENDOR_ID}=="1209", ENV{ID_MODEL_ID}=="7332", MODE="0666", DEVPATH=="/devices/pci0000:00/0000:00:1d.0/usb1/1-1/1-1.2/1-1.2:1.2/tty/ttyACM1", SYMLINK+="bp1"

--- End code ---


--- End quote ---
This is not going to work. As soon as you plug a phone in or any other device that registers as an ttyACMx, the numbering will be off. You'll need to look for some kind of sub-device ID and use that for matching. So vendor id, model id and sub-device number should be used for the udev rule to make it universal. That way no matter which ttyACM the BP5 is assigned to, the symlinks will always work. You can also include the serialnumber (if the USB device has one) and have specific devices attach to specific symlinks.

tggzzz:

--- Quote from: nctnico on March 24, 2024, 10:53:10 am ---ttyACMx, the numbering will be off. You'll need to look for some kind of sub-device ID and use that for matching. So vendor id, model id and sub-device number should be used for the udev rule to make it universal. That way no matter which ttyACM the BP5 is assigned to, the symlinks will always work. You can also include the serialnumber (if the USB device has one) and have specific devices attach to specific symlinks.

--- End quote ---

That was my presumption as well.

I haven't seen any definition of the mapping between what tools tell me is on the usb bus, and what can be put in a filter. So what would be suitable filters, given

usb-devices output is

--- Code: ---T:  Bus=01 Lev=01 Prnt=01 Port=04 Cnt=02 Dev#= 16 Spd=12  MxCh= 0
D:  Ver= 2.00 Cls=ef(misc ) Sub=02 Prot=01 MxPS=64 #Cfgs=  1
P:  Vendor=1209 ProdID=7332 Rev=01.01
S:  Manufacturer=Bus Pirate
S:  Product=Bus Pirate 5
S:  SerialNumber=123456789012
C:  #Ifs= 5 Cfg#= 1 Atr=80 MxPwr=100mA
I:  If#= 0 Alt= 0 #EPs= 1 Cls=02(commc) Sub=02 Prot=00 Driver=cdc_acm
I:  If#= 1 Alt= 0 #EPs= 2 Cls=0a(data ) Sub=00 Prot=00 Driver=cdc_acm
I:  If#= 2 Alt= 0 #EPs= 1 Cls=02(commc) Sub=02 Prot=00 Driver=cdc_acm
I:  If#= 3 Alt= 0 #EPs= 2 Cls=0a(data ) Sub=00 Prot=00 Driver=cdc_acm
I:  If#= 4 Alt= 0 #EPs= 2 Cls=08(stor.) Sub=06 Prot=50 Driver=usb-storage
--- End code ---

Or the usbview output is

--- Code: ---Bus Pirate 5
Manufacturer: Bus Pirate
Serial Number: 123456789012
Speed: 12Mb/s (full)
Bus:   1
Address:  16
USB Version:  2.00
Device Class: ef(misc )
Device Subclass: 02
Device Protocol: 01
Maximum Default Endpoint Size: 64
Number of Configurations: 1
Vendor Id: 1209
Product Id: 7332
Revision Number:  1.01

Config Number: 1
Number of Interfaces: 5
Attributes: 80
MaxPower Needed: 100mA

Interface Number: 0
Name: cdc_acm
Alternate Number: 0
Class: 02(comm.)
Sub Class: 02
Protocol: 00
Number of Endpoints: 1

Endpoint Address: 81
Direction: in
Attribute: 3
Type: Int.
Max Packet Size: 8
Interval: 16ms

Interface Number: 1
Name: cdc_acm
Alternate Number: 0
Class: 0a(data )
Sub Class: 00
Protocol: 00
Number of Endpoints: 2

Endpoint Address: 02
Direction: out
Attribute: 2
Type: Bulk
Max Packet Size: 64
Interval: 0ms

Endpoint Address: 82
Direction: in
Attribute: 2
Type: Bulk
Max Packet Size: 64
Interval: 0ms

Interface Number: 2
Name: cdc_acm
Alternate Number: 0
Class: 02(comm.)
Sub Class: 02
Protocol: 00
Number of Endpoints: 1

Endpoint Address: 83
Direction: in
Attribute: 3
Type: Int.
Max Packet Size: 8
Interval: 16ms

Interface Number: 3
Name: cdc_acm
Alternate Number: 0
Class: 0a(data )
Sub Class: 00
Protocol: 00
Number of Endpoints: 2

Endpoint Address: 04
Direction: out
Attribute: 2
Type: Bulk
Max Packet Size: 64
Interval: 0ms

Endpoint Address: 84
Direction: in
Attribute: 2
Type: Bulk
Max Packet Size: 64
Interval: 0ms

Interface Number: 4
Name: usb-storage
Alternate Number: 0
Class: 08(stor.)
Sub Class: 06
Protocol: 50
Number of Endpoints: 2

Endpoint Address: 05
Direction: out
Attribute: 2
Type: Bulk
Max Packet Size: 64
Interval: 0ms

Endpoint Address: 85
Direction: in
Attribute: 2
Type: Bulk
Max Packet Size: 64
Interval: 0ms
--- End code ---

nctnico:
You can try to look up the ACM devices from the BP5 in sysfs and trace back to the device driver / bus instance they belong to. From there you might be able to spot a useful discriminator to seperate the text and binary interface.

tggzzz:

--- Quote from: nctnico on March 24, 2024, 01:42:52 pm ---You can try to look up the ACM devices from the BP5 in sysfs and trace back to the device driver / bus instance they belong to. From there you might be able to spot a useful discriminator to seperate the text and binary interface.

--- End quote ---

Well, I have spent too much time trying and failing. Yes, I'm profoundly ignorant of USB and udev, and have absolutely no inclination to change that. Fundamentally this information should be supplied by the manufacturer. Since this is a new device, I will cut them some slack - and wait until a usable workaround is announced.

If it doesn't appear, then I'll point it out. I'll probably be one of many doing that.

I'll just use /dev/ttyACM0 and call it a day.

shabaz:
I didn't think of additional ttyACMs, good point.. I can't find a way to do it either : (
I could only come up with this not-so-great workaround. I have tested by inserting another ttyACM device, and it seems to function OK (replace 'screen' with minicom etc), and save with 755 permissions or similar. I'm not very good with bash so I'm sure this could be improved a lot. It assumes that the lower ttyACM value out of the pair will be for the text console, this seems to repeatably be the case with my BP5. Currently it checks just for ttyACM0 to 9, it's really ugly:


--- Code: ---#!/bin/bash

PORT="none"
for i in {0..9}
do
  if udevadm info /dev/ttyACM$i | grep -q 'Pirate'
  then
    echo "Pirate device found at /dev/ttyACM$i"
    PORT=/dev/ttyACM$i
    break
  fi
done

# execute screen on the port if it was found
if [ "$PORT" != "none" ]
then
  screen $PORT 115200
else
  echo "No Pirate device found"
fi
--- End code ---


Navigation

[0] Message Index

[#] Next page

[*] Previous page

There was an error while thanking
Thanking...
Go to full version
Powered by SMFPacks Advanced Attachments Uploader Mod