tuna-f1sh / cyme

List system USB buses and devices; a lib and modern cross-platform lsusb that attempts to maintain compatibility with, but also add new features
GNU General Public License v3.0
141 stars 7 forks source link

cyme.json not read #3

Closed Mellbourn closed 1 year ago

Mellbourn commented 1 year ago

I can't for the life of me make cyme find the config file without a parameter.

Using the --config= parameter I can force cyme to use my cyme.json file. But without the parameter, cyme does not find the file.

I'm on macOS and I've tried these paths:

I don't know Rust, but in the code, it looks to me like the CONF_NAME variable isn't actually used.

Thanks for a cool tool!

tuna-f1sh commented 1 year ago

Hmm, I just double checked and with '$HOME/Library/Application Support/cyme/cyme.json' it loads the config file there.

CONF_NAME is used when looking. Can you run with the debug argument -Z: cyme -Z. It should show something like:

2023-01-25T14:23:32.557Z INFO  [cyme::config] Looking for cyme system config "/Users/john/Library/Application Support/cyme/cyme.json"
2023-01-25T14:23:32.557Z INFO  [cyme::config] Loaded cyme system config Config { icons: IconTheme { user: None, tree: None }, colours: ColourTheme { name: Some(BrightBlue), serial: Some(Green), manufacturer: Some(Blue), driver: Some(Cyan), string: Some(Blue), icon: None, location: Some(Magenta), path: Some(Cyan), number: Some(Cyan), speed: Some(Magenta), vid: Some(BrightYellow), pid: Some(Yellow), class_code: Some(BrightYellow), sub_code: Some(Yellow), protocol: Some(Yellow), attributes: Some(Magenta), power: Some(Red), tree: Some(BrightBlack), tree_bus_start: Some(BrightBlack), tree_bus_terminator: Some(BrightBlack), tree_configuration_terminator: Some(BrightBlack), tree_interface_terminator: Some(BrightBlack), tree_endpoint_in: Some(Yellow), tree_endpoint_out: Some(Magenta) }, blocks: None, bus_blocks: None, config_blocks: None, interface_blocks: None, endpoint_blocks: None, mask_serials: None, lsusb: false, tree: true, verbose: 0, more: false, hide_buses: true, hide_hubs: true, decimal: false, no_padding: false, ascii: false, headings: false, force_libusb: false }

Thanks.

Mellbourn commented 1 year ago

Ok, that flag shows that there is a problem with my config file.

cyme -z
2023-01-25T15:07:06.347Z INFO  [cyme::config] Looking for cyme system config "/Users/klas.mellbourn/Library/Application Support/cyme/cyme.json"
2023-01-25T15:07:06.348Z WARN  [cyme::config] Failed to read cyme system config "/Users/klas.mellbourn/Library/Application Support/cyme/cyme.json": Error(missing field `lsusb` at line 24 column 1)
2023-01-25T15:07:06.470Z INFO  [cyme] Filtering with None

This is the file

{
  "blocks": ["bus-number", "device-number", "icon", "name", "speed"],
  "bus-blocks": ["name", "host-controller"],
  "config-blocks": ["number", "name", "icon-attributes", "max-power"],
  "interface-blocks": [
    "port-path",
    "icon",
    "alt-setting",
    "class-code",
    "sub-class",
    "protocol",
    "name"
  ],
  "endpoint-blocks": [
    "number",
    "direction",
    "transfer-type",
    "sync-type",
    "usage-type",
    "max-packet-size"
  ],
  "tree": true,
  "headings": false
}
Mellbourn commented 1 year ago

I got this config file working

{
  "blocks": ["bus-number", "device-number", "icon", "name", "speed"],
  "bus-blocks": ["name", "host-controller"],
  "config-blocks": ["number", "name", "icon-attributes", "max-power"],
  "interface-blocks": [
    "port-path",
    "icon",
    "alt-setting",
    "class-code",
    "sub-class",
    "protocol",
    "name"
  ],
  "endpoint-blocks": [
    "number",
    "direction",
    "transfer-type",
    "sync-type",
    "usage-type",
    "max-packet-size"
  ],
  "tree": true,
  "lsusb": false,
  "verbose": 0,
  "more": false,
  "hide-buses": false,
  "hide-hubs": false,
  "decimal": false,
  "no-padding": false,
  "ascii": false,
  "headings": false,
  "force-libusb": false
}

So, it did find the correct file. But maybe errors that occur when reading the config file should be reported?

tuna-f1sh commented 1 year ago

Yes, I've added a fix and test for this now - I missed the macro to de-serialise with defaults for all fields. Thanks for helping to debug.