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

[Windows] add support for port information #9

Merged
merged 4 commits into from
Oct 23, 2023

Conversation

lachlanm-git
Copy link
Contributor

This is an attempt to add serial port information (issue #8) . This is done iteratively via InformationIterator which will return a PortInformation struct for each serial port.

This PR only adds Windows support. It is (I thought) surprisingly convoluted to get things like the serial number.

I'm thinking perhaps something like a VCP is not handled well but I do not have a device to test.
I have tested with devices using Windows CDC driver and FTDI.

Referenced implementations :


Note, I'm very fresh to Zig and I'm sure a lot of this code could be improved. So please, feel free to make edits or suggestions - it would be a good learning experience for me.

added `PortInformation` defines various information we can gather about a serial port device.

implemented Windows `WindowsInformationIterator` to support retrieve all availble serial port information.

Added example/list_port_info.zig and added to build.zig
parsing serial number for CDC serial driver requires additional work
Sometimes on Windows the serial number has to be obtained from a parent node
@lachlanm-git
Copy link
Contributor Author

Here is some example output from running serial-list-info.exe.
I found it useful to compare/test against "usbview.exe" and py -m serial.tools.list_ports --verbose (pyserial)

Port name: COM5

  • System location: \.\COM5
  • Friendly name: USB Serial Port (COM5)
  • Description: USB Serial Port
  • Manufacturer: FTDI
  • Serial #: FT1UKRMGA
  • HW ID: FTDIBUS\VID_0403+PID_6001+FT1UKRMGA\0000
  • VID: 0x0403 PID: 0x6001

Port name: COM4

  • System location: \.\COM4
  • Friendly name: USB Serial Port (COM4)
  • Description: USB Serial Port
  • Manufacturer: FTDI
  • Serial #: RC8DEXWRA
  • HW ID: FTDIBUS\VID_0403+PID_6001+RC8DEXWRA\0000
  • VID: 0x0403 PID: 0x6001

Port name: COM6

  • System location: \.\COM6
  • Friendly name: USB Serial Device (COM6)
  • Description: USB Serial Device
  • Manufacturer: Microsoft
  • Serial #: E6614104035C3C31
  • HW ID: USB\VID_2E8A&PID_0005&MI_00\6&C508D77&0&0000
  • VID: 0x2E8A PID: 0x0005

Port name: COM7

  • System location: \.\COM7
  • Friendly name: USB Serial Device (COM7)
  • Description: USB Serial Device
  • Manufacturer: Microsoft
  • Serial #: 0
  • HW ID: USB\VID_3473&PID_0001\0
  • VID: 0x3473 PID: 0x0001

Note, the thorny one is USB\VID_2E8A&PID_0005&MI_00\6&C508D77&0&0000. This requires iterating over parent nodes to extract the serial number.

@ikskuh
Copy link
Collaborator

ikskuh commented Oct 23, 2023

Very cool, looks good so far!

@ikskuh ikskuh merged commit 394bf7c into ZigEmbeddedGroup:master Oct 23, 2023
@lachlanm-git lachlanm-git deleted the port-info-windows branch October 27, 2023 03:22
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.

2 participants