turing-machines / tpi

CLI tool to control your Turing Pi 2 board
https://docs.turingpi.com/docs/turing-pi2-tpi-cli
Apache License 2.0
29 stars 3 forks source link

tpi usb status does not reflect the mode #27

Open ralph-mcardell opened 5 months ago

ralph-mcardell commented 5 months ago

tpi usb status

Output does not reflect the mode. It always shows usba / bmc (route) under USB Host and node N under USB Device, viz:

# tpi usb -n 1 host
ok
# tpi usb status
  USB Host  --> USB Device
    usba    -->   node 1
# tpi usb -n 1 device
ok
# tpi usb status
  USB Host  --> USB Device
    usba    -->   node 1
# tpi usb -n 1 flash
ok
# tpi usb status
  USB Host  --> USB Device
    usba    -->   node 1

Possible cause (I am not a Rust expert and not set up for Rust development)

In legacy_handler.rs in function print_usb_status @ line line 623 - 646 it looks like the result field values are extracted from JSON and forced to lower case, for the mode value this is on line 631. Following this mode is compared to "Host" to determine the mode, which if it was originally "Host" would have just previously been transformed to "host", hence never a match and display acts as if mode is never host (however spelt / capitalised).