Skip to content

Vid pid details #369

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

Merged
merged 9 commits into from
Jul 17, 2018
Merged

Vid pid details #369

merged 9 commits into from
Jul 17, 2018

Conversation

bridadan
Copy link
Contributor

This is part of the solution to #165. The next step would take place in the base class which would be responsible for altering the device_type field.

This PR implements a mechanism for each OS (Windows, Linux, and Mac) to provide the Vendor ID and Product ID of the Mbed devices present on the system. These two data items are present in the results as vendor_id and product_id respectively.

Both the vendor_id and product_id fields should be displayed as a 4 character, lower case hex string.

FYI @theotherjimmy @jupe

Here is some sample output:

$ mbedls -j
[
    {
        "daplink_build": "Jan 11 2016 16:12:36",
        "daplink_url": "http://mbed.org/device/?code=07400221076061193824F764",
        "daplink_version": "0221",
        "device_type": "daplink",
        "directory_entries": [
            "DETAILS.TXT",
            "MBED.HTM"
        ],
        "mount_point": "/mnt/pci-0000_00_06_0-usb-0_3_1_1-scsi-0_0_0_0",
        "platform_name": "NUCLEO_F411RE",
        "platform_name_unique": "NUCLEO_F411RE[0]",
        "product_id": "374b",
        "serial_port": "/dev/ttyACM1",
        "target_id": "07400221076061193824F764",
        "target_id_mbed_htm": "07400221076061193824F764",
        "target_id_usb_id": "0671FF554856805087112815",
        "vendor_id": "0483"
    },
    {
        "daplink_auto_reset": "0",
        "daplink_automation_allowed": "1",
        "daplink_bootloader_crc": "0xb92403e6",
        "daplink_bootloader_version": "0244",
        "daplink_daplink_mode": "Interface",
        "daplink_git_sha": "0beabef8aa4b382809d79e98321ecf6a28936812",
        "daplink_hic_id": "97969900",
        "daplink_interface_crc": "0x434eddd1",
        "daplink_interface_version": "0246",
        "daplink_local_mods": "0",
        "daplink_overflow_detection": "1",
        "daplink_remount_count": "0",
        "daplink_unique_id": "0240000032044e4500257009997b00386781000097969900",
        "daplink_usb_interfaces": "MSD, CDC, HID",
        "daplink_version": "0246",
        "device_type": "daplink",
        "directory_entries": [
            "MBED.HTM",
            "DETAILS.TXT"
        ],
        "mount_point": "/mnt/pci-0000_00_06_0-usb-0_2_1_0-scsi-0_0_0_0",
        "platform_name": "K64F",
        "platform_name_unique": "K64F[0]",
        "product_id": "0204",
        "serial_port": "/dev/ttyACM0",
        "target_id": "0240000032044e4500257009997b00386781000097969900",
        "target_id_mbed_htm": "0240000032044e4500257009997b00386781000097969900",
        "target_id_usb_id": "0240000032044e4500257009997b00386781000097969900",
        "vendor_id": "0d28"
    }
]

@coveralls
Copy link

coveralls commented Jul 16, 2018

Coverage Status

Coverage increased (+0.7%) to 80.347% when pulling 10f906a on bridadan:vid_pid_details into 0e5f95c on ARMmbed:master.

full_sysfs_path = os.readlink(sysfs_path)
path_parts = full_sysfs_path.split('/')

end_index = -1
Copy link
Contributor

Choose a reason for hiding this comment

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

I think it's more pythonic to use None here.

usb_info_path = os.path.join(SYSFS_BLOCK_DEVICE_PATH, os.sep.join(usb_info_rel_path))

vendor_id = 'unknown'
product_id = 'unknown'
Copy link
Contributor

Choose a reason for hiding this comment

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

I would like to use None here as well. I don't like string matching on "unknown" as an API.

Copy link
Contributor Author

@bridadan bridadan Jul 17, 2018

Choose a reason for hiding this comment

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


On second thought, `"unknown"` is completely unnecessary, I'll just leave it as `None`.

Copy link
Contributor

@theotherjimmy theotherjimmy left a comment

Choose a reason for hiding this comment

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

Tests look great!

@bridadan
Copy link
Contributor Author

Thanks for the feedback, I'll get those changes in soon

@bridadan
Copy link
Contributor Author

Changes pushed!

FYI I have firmware detection based on this working! When this gets merged I'll put up the firmware detection PR.

@theotherjimmy theotherjimmy merged commit 281c44a into ARMmbed:master Jul 17, 2018
@theotherjimmy
Copy link
Contributor

@bridadan Let's have that firmware detection PR.

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

Successfully merging this pull request may close these issues.

3 participants