Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Error fetching ether gadget attributes #102

Open
pboucherat-thegoodpenguin opened this issue Oct 30, 2024 · 3 comments
Open

Error fetching ether gadget attributes #102

pboucherat-thegoodpenguin opened this issue Oct 30, 2024 · 3 comments

Comments

@pboucherat-thegoodpenguin

The show-gadgets example fails when trying to display an ether gadget's attributes. The example programs e.g. gadget-acm-ecm create the gadgets passing a null attributes pointer, and the ether gadget only creates 4 attributes dev_addr, host_addr, ifname and qmult, whereas in src/function/ether.c there are 7 attributes defined so usbg_f_net_get_attrs() fails when it tries to fetch the fifth one (class_) and returns USBG_ERROR_NOT_FOUND. So after running gadget-acm-ecm, output from show-gadgets looks like this with the not found error where it should be listing the ecm.usb0 attributes :

ID 1d6b:0104 'g1'                                                                                                                                                                                                                                                        
  UDC                   38100000.usb                                                                                                                                                                                                                                     
  bcdUSB                2.01                                                                                                                                                                                                                                             
  bDeviceClass          0x00                                                                                                                                                                                                                                             
  bDeviceSubClass       0x00                                                                                                                                                                                                                                             
  bDeviceProtocol       0x00                                                                                                                                                                                                                                             
  bMaxPacketSize0       64                                                                                                                                                                                                                                               
  idVendor              0x1d6b                                                                                                                                                                                                                                           
  idProduct             0x0104
  bcdDevice             0.01
  Language:     0x409
    Manufacturer        Foo Inc.
    Product             Bar Gadget
    Serial Number       0123456789
  Function, type: acm instance: usb0
    port_num            0
  Function, type: acm instance: usb1
    port_num            1
Error: USBG_ERROR_NOT_FOUND : Not found (file or directory removed)
  Configuration: 'The only one' ID: 1
    MaxPower            2
    bmAttributes        0x80
    Language:   0x409
      configuration     CDC 2xACM+ECM
    acm.GS0 -> acm usb0
    acm.GS1 -> acm usb1
    ecm.usb0 -> ecm usb0

@pboucherat-thegoodpenguin
Copy link
Author

pboucherat-thegoodpenguin commented Oct 30, 2024

I'm at "721e3a1 correct attribute import / export" which is from about 18 months ago, so I will check this with the latest code - yes still seem to getting the same with "fe39790 Merge pull request #95 from mgrzeschik/feature/meson" from September.

@pboucherat-thegoodpenguin
Copy link
Author

I suppose an easy fix would be to remove the class_, subclass and protocol attributes, but I don't know if these are used by anything.

@pboucherat-thegoodpenguin
Copy link
Author

pboucherat-thegoodpenguin commented Oct 30, 2024

Output looks ok with the attached patch, but I don't know the code well enough to know if this is the best way, it feels more like a sticking plaster than a fix :
0001-Fix-get-attibutes-function-for-ether.c.txt


ID 1d6b:0104 'g1'
  UDC                   38100000.usb
  bcdUSB                2.01
  bDeviceClass          0x00
  bDeviceSubClass       0x00
  bDeviceProtocol       0x00
  bMaxPacketSize0       64
  idVendor              0x1d6b
  idProduct             0x0104
  bcdDevice             0.01
  Language:     0x409
    Manufacturer        Foo Inc.
    Product             Bar Gadget
    Serial Number       0123456789
  Function, type: acm instance: usb0
    port_num            0
  Function, type: acm instance: usb1
    port_num            1
  Function, type: ecm instance: usb0
    dev_addr            c6:5d:d:84:9a:ab
    host_addr           7a:16:a2:45:d9:b0
    ifname              usb0
    qmult               5
  Configuration: 'The only one' ID: 1
    MaxPower            2
    bmAttributes        0x80
    Language:   0x409
      configuration     CDC 2xACM+ECM
    acm.GS0 -> acm usb0
    acm.GS1 -> acm usb1
    ecm.usb0 -> ecm usb0

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant