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

Generate a device ID if expected fields are missing #234

Closed
wants to merge 1 commit into from

Conversation

abdelq
Copy link
Contributor

@abdelq abdelq commented Nov 4, 2022

Some devices are not setting the device ID properly. In the case of the cheap printer I have, it's just whitespace. Without this change I end up with usb://Unknown/Unknown?serial=Printer. Not very useful for lprint's autoadd for example...

Copy link
Owner

@michaelrsweet michaelrsweet left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think I want to generate a device ID string in this case, but want to dig a bit more to be sure. But in concept I am OK with this change.

@michaelrsweet michaelrsweet self-assigned this Nov 4, 2022
@michaelrsweet michaelrsweet added enhancement New feature or request priority-medium platform issue Issue is specific to an OS or desktop labels Nov 4, 2022
@michaelrsweet michaelrsweet added this to the v1.3 milestone Nov 4, 2022
@abdelq abdelq force-pushed the usb-desc-make-model branch 4 times, most recently from 802719b to fd91673 Compare November 7, 2022 06:44
@abdelq
Copy link
Contributor Author

abdelq commented Nov 7, 2022

Alright, second attempt. Feedback appreciated (maybe snprintf instead? maybe papplDeviceParseID and pass anything that is not MFG, MDL?).

Did test this with lprint devices -o verbose and got:

usb://STMicroelectronics/POS58%20Printer%20USB%20%20%20%20%20%20%20?serial=Printer
    STMicroelectronics POS58 Printer USB        (USB)
    MFG:STMicroelectronics;MDL:POS58 Printer USB       ;SN:Printer;

Trailing spaces are from the actual product name...

@abdelq abdelq changed the title Try getting USB descriptors for manufacturer and model Generate a device ID if expected fields are missing Nov 7, 2022
michaelrsweet added a commit that referenced this pull request Nov 10, 2022
@michaelrsweet
Copy link
Owner

OK, I've pushed a similar change:

[master 1a28cf9] Generate device ID as needed (Issue #234)

Can you review and provide feedback?

Copy link
Owner

@michaelrsweet michaelrsweet left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pushed a slightly different (but similar) change - basically always get the serial, manufacturer, and product strings and cache the device ID. Let me know what you think!

@abdelq abdelq closed this Nov 12, 2022
@abdelq
Copy link
Contributor Author

abdelq commented Nov 12, 2022

Thanks Michael. This is more in line with the alternative implementation I was thinking of. My only comment is that setting '\0' with libusb_get_string_descriptor_ascii is redundant.

Refs:

michaelrsweet added a commit that referenced this pull request Nov 22, 2022
@michaelrsweet
Copy link
Owner

Noted, and I pushed a change to simplify:

[master 84279c3] Clean up libusb API usage (Issue #234)

michaelrsweet added a commit that referenced this pull request Jan 4, 2023
michaelrsweet added a commit that referenced this pull request Jan 4, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request platform issue Issue is specific to an OS or desktop priority-medium
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants