Skip to content

usbstoragedriver: Allow to define a different waiting medium timeout #1711

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

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

panicking
Copy link

Nice to have a way to define a timeout for usb storage driver if it used after a usb switch. This will make this code more simpler

mux_driver = target.get_driver('LXAUSBMuxDriver')
mux_driver.set_links(['host-device'])
time.sleep(3) <-- avoid to use a new sleep here

usb = target.get_driver('USBStorageDriver')
assert usb.get_size() > 0

Let's consider this as first interaction with the project. Could be that somenthing is missing here and there. It's more an RFC patch


def __attrs_post_init__(self):
super().__attrs_post_init__()
self._expect = PtxExpect(self)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is totally unused, why was this added?

@panicking panicking force-pushed the feature/usbstorage-driver-timeout branch from f209948 to ecb0d50 Compare August 3, 2025 06:44
WAIT_FOR_MEDIUM_TIMEOUT = 10.0 # s
timeout = attr.ib(default=0.0, validator=attr.validators.instance_of(float))
default=10.0,
validator=attr.validators.instance_of(float))
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Two timeouts and two validators does not look like valid python code.

@@ -39,15 +39,22 @@ class USBStorageDriver(Driver):
"NetworkUSBSDWireDevice",
},
}

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Stray newline, please remove it.

WAIT_FOR_MEDIUM_SLEEP = 0.5 # s
MOUNT_RETRIES = 5

def __attrs_post_init__(self):
if self.timeout < 0.0:
raise ValueError("timeout must be positive")
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This should be moved into the validation function for attrs.

Nice to have a way to define a timeout for usb storage driver if
it used after a usb switch. This will make this code more simpler

mux_driver = target.get_driver('LXAUSBMuxDriver')
mux_driver.set_links(['host-device'])
time.sleep(3) <-- avoid to use a new sleep here

usb = target.get_driver('USBStorageDriver')
assert usb.get_size() > 0

Signed-off-by: Michael Trimarchi <[email protected]>
@panicking panicking force-pushed the feature/usbstorage-driver-timeout branch from ecb0d50 to 6bf4032 Compare August 3, 2025 11:13
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