GithubHelp home page GithubHelp logo

Comments (12)

HubertD avatar HubertD commented on July 17, 2024

unfortunately don't have a good idea where to put a software version, either.
it'd be nice to have, though.
Using iSerial is not a good option imho, as it would probably be used for udev rules to assign a certain can interface name to a certain can bus. That shouldn't change with a software update.
Using iProduct might not be great, but I see it as an option. At least, it would be easily accessible...

from candlelight_fw.

normaldotcom avatar normaldotcom commented on July 17, 2024

I append git rev/repo information to the product string on the stock CANable firmware. It's certainly not pretty, but it works well. Example dmesg output:

[1263955.892535] usb 1-1: New USB device strings: Mfr=1, Product=2, SerialNumber=3
[1263955.892538] usb 1-1: Product: CANable 1205aa6 https://github.com/normaldotcom/cantact-fw
[1263955.892541] usb 1-1: Manufacturer: Protofusion Labs
[1263955.892543] usb 1-1: SerialNumber: 0024000D524E431120373533

from candlelight_fw.

brian-brt avatar brian-brt commented on July 17, 2024

I'll add a 👍 for putting a git hash somewhere. A vendor-specific descriptor which just has the string seems like a "clean" approach, but pretty annoying to retrieve.

It's been a while since I dealt with USB devices on Windows, but I think there's a possibility of it being unhappy if you change any of the standard strings without also changing bcdDevice. Ignoring the new value and caching the old one seems more unlikely. Have you done any experiments with that @normaldotcom?

from candlelight_fw.

fenugrec avatar fenugrec commented on July 17, 2024

Just working on this right now ! Quick test was to set iConfiguration in the config descriptor - the code was ready for this, config.h already had USBD_CONFIGURATION_STRING_FS so I just needed to add USBD_IDX_CONFIG_STR in the config descriptor.
It's pretty straightforward : lsusb -v will show the string that way.

Interesting point re windows caching standard strings, although I can't see how they could assume that every usb gadget is guaranteed to change bcdDevice when they upgrade firmware ?

from candlelight_fw.

fenugrec avatar fenugrec commented on July 17, 2024

According to https://techcommunity.microsoft.com/t5/microsoft-usb-blog/how-does-usb-stack-enumerate-a-device/ba-p/270685 (possibly outdated), it does mention caching for the MS OS Descriptor Query ,

subsequent enumerations of any device with the same VID/PID/Revision will read the bVendorCode from this registry value rather than querying the device.

I think they have no choice (per USB) but to query the config descriptor every time. Just firing up a win7 VM to check.

from candlelight_fw.

fenugrec avatar fenugrec commented on July 17, 2024

Ok. Tested in a win7 VM, using usbtreeview to check the config descriptor before / after a rebuild changing the string, it works as expected, i.e. Win isn't shadowing the strings and usbtreeview returns the correct strings.
This would seem like a pretty convenient way of doing this. Thoughts ? @HubertD ?

from candlelight_fw.

fenugrec avatar fenugrec commented on July 17, 2024

@normaldotcom , @tuna-f1sh , you guys also use this and/or have forks, can you think of any reason not to do this by adding a config descriptor as I described ?

This is what iConfiguration it looks like with lsusb on linux :

Bus 005 Device 003: ID 1d50:606f OpenMoko, Inc. cannette gs_usb
Device Descriptor:
  bLength                18
  bDescriptorType         1
  bcdUSB               2.00
 ........
  bNumConfigurations      1
  Configuration Descriptor:
    bLength                 9
    bDescriptorType         2
    wTotalLength       0x0032
    bNumInterfaces          2
    bConfigurationValue     1
    iConfiguration          4 ec69f1f8-pr62
    bmAttributes         0x80
      (Bus Powered)
    MaxPower              150mA
    Interface Descriptor:
....

from candlelight_fw.

tuna-f1sh avatar tuna-f1sh commented on July 17, 2024

I can't think of a reason not to, no. Sounds like a useful feature to me.

How are you injecting it to the source? Using a cmake function?

from candlelight_fw.

fritz-net avatar fritz-net commented on July 17, 2024

Have you looked into git describe? If there is space in the description string i would probably use this since it can generate a version number based on tags with an additional git has so there is also a humane readable indication for the current version.

I have used git describe --tags --match "Version-[0-9].[0-9].[0-9]" --abbrev=6 in the past:
image
The last Tag in the example is 474 commits away and is named "Version-3.0.0"

from candlelight_fw.

fenugrec avatar fenugrec commented on July 17, 2024

How are you injecting it to the source? Using a cmake function?

TBD. For testing I was just updating it manually; in another project I use some cmake magic I lifted somewhere:

https://github.com/fenugrec/nisprog/blob/master/cmake/gitversion.cmake

I'd probably start with that and see if I need to address the edge-case of someone compiling from a tarball without 'git' available.

So I'm not too worried about the "how", but rather, would it ever be a problem on win/mac , having a config descriptor string that can change ? I can't think of a use case where this would cause problems. Someone wanting to identify multiple connected devices will be using iSerial anyway as a unique ID. And the OS probably never cares much about iConfiguration...

from candlelight_fw.

fenugrec avatar fenugrec commented on July 17, 2024

I have a PR something usable ready for testing/review, #71

from candlelight_fw.

fenugrec avatar fenugrec commented on July 17, 2024

Closed via #71

from candlelight_fw.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.