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

Optional serde build feature #45

Open
fpagliughi opened this issue May 1, 2024 · 1 comment
Open

Optional serde build feature #45

fpagliughi opened this issue May 1, 2024 · 1 comment

Comments

@fpagliughi
Copy link
Contributor

It would be nice to have an optional cargo build feature to allow Device information and Event data to be easily serialized using serde.

If you're interested, I could do the work and put up a PR.

For example, an event for a USB device insertion, serialized to JSON, might look like this:

{
  "type": "add",
  "seqNum": 24130,
  "subsystem": "usb",
  "sysname": "1-1",
  "devtype": "usb_device",
  "device": {
    "devnum": 48414,
    "syspath": "/sys/devices/pci0000:00/0000:00:14.0/usb1/1-1",
    "devpath": "/devices/pci0000:00/0000:00:14.0/usb1/1-1",
    "devnode": "/dev/bus/usb/001/031",
    "subsystem": "usb",
    "sysname": "1-1",
    "sysnum": 1,
    "devtype": "usb_device",
    "driver": "usb",
    "attributes": {
      "authorized": "1",
      "avoid_reset_quirk": "0",
      "bConfigurationValue": "1",
      "bDeviceClass": "00",
      "bDeviceProtocol": "00",
      "bDeviceSubClass": "00",
      "bMaxPacketSize0": "8",
      "bMaxPower": "100mA",
      "bNumConfigurations": "1",
      "bNumInterfaces": " 1",
      "bcdDevice": "0600",
      "bmAttributes": "a0",
      "busnum": "1",
      "configuration": "",
      "descriptors": "\u0012\u0001",
      "dev": "189:30",
      "devnum": "31",
      "devpath": "1",
      "driver": "usb",
      "firmware_node": "",
      "idProduct": "6001",
      "idVendor": "0403",
      "ltm_capable": "no",
      "manufacturer": "FTDI",
      "maxchild": "0",
      "port": "",
      "product": "US232R",
      "quirks": "0x0",
      "removable": "removable",
      "rx_lanes": "1",
      "serial": "FTDBHX3J",
      "speed": "12",
      "subsystem": "usb",
      "tx_lanes": "1",
      "uevent": "MAJOR=189,MINOR=30,DEVNAME=bus/usb/001/031,DEVTYPE=usb_device,DRIVER=usb,PRODUCT=403/6001/600,TYPE=0/0/0,BUSNUM=001,DEVNUM=031",
      "urbnum": "18",
      "version": " 2.00"
    },
    "properties": {
      "ACTION": "add",
      "BUSNUM": "001",
      "DEVNAME": "/dev/bus/usb/001/031",
      "DEVNUM": "031",
      "DEVPATH": "/devices/pci0000:00/0000:00:14.0/usb1/1-1",
      "DEVTYPE": "usb_device",
      "DRIVER": "usb",
      "ID_BUS": "usb",
      "ID_FOR_SEAT": "usb-pci-0000_00_14_0-usb-0_1",
      "ID_MODEL": "US232R",
      "ID_MODEL_ENC": "US232R",
      "ID_MODEL_FROM_DATABASE": "FT232 Serial (UART) IC",
      "ID_MODEL_ID": "6001",
      "ID_PATH": "pci-0000:00:14.0-usb-0:1",
      "ID_PATH_TAG": "pci-0000_00_14_0-usb-0_1",
      "ID_REVISION": "0600",
      "ID_SERIAL": "FTDI_US232R_FTDBHX3J",
      "ID_SERIAL_SHORT": "FTDBHX3J",
      "ID_USB_INTERFACES": ":ffffff:",
      "ID_VENDOR": "FTDI",
      "ID_VENDOR_ENC": "FTDI",
      "ID_VENDOR_FROM_DATABASE": "Future Technology Devices International, Ltd",
      "ID_VENDOR_ID": "0403",
      "MAJOR": "189",
      "MINOR": "30",
      "PRODUCT": "403/6001/600",
      "SEQNUM": "24130",
      "SUBSYSTEM": "usb",
      "TAGS": ":seat:uaccess:",
      "TYPE": "0/0/0",
      "USEC_INITIALIZED": "257380779616"
    }
  }
}
@Drakulix
Copy link
Member

Drakulix commented May 2, 2024

Granted we can provide a stable serialization here (with regards to different udev-implementations and versions), this looks like a good idea to me!

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

2 participants