linux-automation / usbsdmux

USB-SD-Mux Project - Driver and Documentation
GNU Lesser General Public License v2.1
66 stars 19 forks source link

implement 'info' command to show SD card SCR, CID and CSD #58

Closed jluebbe closed 11 months ago

SmithChart commented 12 months ago

One more thing I found while using this tooling:

./venv/bin/usbsdmux /dev/usb-sd-mux/id-000000000114 host && ./venv/bin/usbsdmux /dev/usb-sd-mux/id-000000000114 info

will fail while reading the info:

Traceback (most recent call last):
  File "/home/chris/work/Projects/github/usb-sd-mux-ctl/./venv/bin/usbsdmux", line 10, in <module>
    sys.exit(main())
  File "/home/chris/work/Projects/github/usb-sd-mux-ctl/usbsdmux/__main__.py", line 98, in main
    ctl.info()
  File "/home/chris/work/Projects/github/usb-sd-mux-ctl/usbsdmux/usbsdmux.py", line 126, in info
    scr = self._usb.read_scr()
  File "/home/chris/work/Projects/github/usb-sd-mux-ctl/usbsdmux/usb2642.py", line 480, in read_scr
    return self._read_register(0x1B, 8)
  File "/home/chris/work/Projects/github/usb-sd-mux-ctl/usbsdmux/usb2642.py", line 467, in _read_register
    raise SDTransactionFailed(
usbsdmux.usb2642.SDTransactionFailed: SCSI Transaction ended with status 2. SD Transaction has probably failed.

But it works a short moment later. Should we include some forced waiting time before reading the registers?

jluebbe commented 11 months ago

But it works a short moment later. Should we include some forced waiting time before reading the registers?

Hmm, that would make every call slower, even when not necessary to solve this corner case. Perhaps just retry and wait on error? Or check if a card is detected via /sys/class/block/<bdev>/size != 0?

SmithChart commented 11 months ago

But it works a short moment later. Should we include some forced waiting time before reading the registers?

Hmm, that would make every call slower, even when not necessary to solve this corner case. Perhaps just retry and wait on error? Or check if a card is detected via /sys/class/block/<bdev>/size != 0?

For me wait and retry on error sounds like the sensible solution.