Skip to content

usb: display power supply overload notifications#33

Merged
hnez merged 4 commits into
linux-automation:mainfrom
hnez:usb-limits
Oct 6, 2023
Merged

usb: display power supply overload notifications#33
hnez merged 4 commits into
linux-automation:mainfrom
hnez:usb-limits

Conversation

@hnez
Copy link
Copy Markdown
Member

@hnez hnez commented Aug 30, 2023

Add warning on the LCD …

lcd

… and web interface if the LXA TAC' USB ports are overloaded.

web

Comment thread src/usb_hub.rs Outdated
Comment thread src/ui/screens/usb_overload.rs
@hnez hnez force-pushed the usb-limits branch 2 times, most recently from eb15c64 to a7b4b5c Compare September 26, 2023 14:14
@hnez
Copy link
Copy Markdown
Member Author

hnez commented Sep 26, 2023

I've implemented the overcurrent warning level constants as @KarlK90 suggested and fixed some merge conflicts while rebasing on the current main branch,
Please re-approve and merge at will.

@hnez hnez force-pushed the usb-limits branch 2 times, most recently from d22555f to b38944c Compare September 27, 2023 12:10
@hnez
Copy link
Copy Markdown
Member Author

hnez commented Sep 27, 2023

Changes introduced by #27 necessitated some changes with regard to error handling of ADC readings, which I have just pushed:

tacd/src/usb_hub.rs

Lines 291 to 304 in b38944c

spawn(async move {
loop {
let overloaded_port = OverloadedPort::from_currents(
total.get().map(|m| m.value).unwrap_or(0.0),
port1.get().map(|m| m.value).unwrap_or(0.0),
port2.get().map(|m| m.value).unwrap_or(0.0),
port3.get().map(|m| m.value).unwrap_or(0.0),
);
overload_task.set_if_changed(overloaded_port);
sleep(POLL_INTERVAL).await;
}
});

In addition to that I've also implemented @KarlK90's suggestion for inlining the let overload_* bindings into the if … else if … chain.

@hnez
Copy link
Copy Markdown
Member Author

hnez commented Oct 6, 2023

Hi @KarlK90 can I get a new approval? The previous one was invalidated by required changes in a rebase.

Copy link
Copy Markdown
Member

@KarlK90 KarlK90 left a comment

Choose a reason for hiding this comment

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

@hnez done!

hnez added 4 commits October 6, 2023 15:07
The simulated total USB Host current is calculates by summing up the
individual host currents. This channel does not have anything like
exponential decay and thus sets the time constants as zero.
Prevent divide by zero and provide immediate decay.

Signed-off-by: Leonard Göhrs <l.goehrs@pengutronix.de>
This can also be achieved by subscribing to the individual port current topics,
but a centralized low-traffic topic is preferable in terms of resource usage.

Signed-off-by: Leonard Göhrs <l.goehrs@pengutronix.de>
This should make debugging mis-behaving USB devices a bit easier.

Signed-off-by: Leonard Göhrs <l.goehrs@pengutronix.de>
This should make debuging mis-behaving USB devices easier.

Signed-off-by: Leonard Göhrs <l.goehrs@pengutronix.de>
@hnez hnez merged commit c19e3e9 into linux-automation:main Oct 6, 2023
@hnez hnez deleted the usb-limits branch October 6, 2023 13:25
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.

3 participants