SmartPower 3 log web frontend

Post Reply
smitna
Posts: 15
Joined: Mon Feb 03, 2014 2:45 am
languages_spoken: english, german
ODROIDs: ODROID-X, ODROID-U3, ODROID-XU, 3x ODROID-C2, 2x ODROID-C4
Location: Germany
Has thanked: 1 time
Been thanked: 4 times
Contact:

SmartPower 3 log web frontend

Post by smitna »

Hello,

i have build a little webpage (recycled from SmartPower2 UI...) to output the log from a SmartPower 3.

Image

If you want to use it, you need a SmartPower 3 with the lastest firmware (WiFi logger) and activated logging.
You also need a little "server" eg. an ODROID-C4 (WEBSOCKIFY_HOST) with linux and websockify

sudo apt install websockify

Example (without additional web server)
Free port for web and websocket (ws://), ex. 81
Start
websockify [IP_OF_YOUR_WEBSOCKIFY_HOST]:81 [SMARTPOWERWIFI_IP]:23 --web=/var/www/html/smartpower

Place the content of the attachment in /var/www/html/smartpower
and open the URL http://[IP_OF_YOUR_WEBSOCKIFY_HOST]:81/smartpower3.html

I hope the watt/h measurement (calculated per time) is ok.

Notes:
It's only possible to use one client (browser) at the same time but you can start multiple websockify instances with different ports or use an other solution (like a proxy).
This is far away from beeing perfect. The measurement can be wrong or inaccurate. Please post your comments...

That's it. Feel free to test and modify it.

sp3toweb.zip
(200.33 KiB) Downloaded 9 times

Beside that I noticed a bug in the (I hope) firmware (2021/Nov/26):
After some random time the logging stops working and the LCD output freezes and the device needs a cold restart. That could happen after a short time or after a few hours. That's very strange and I hope not dangerous for the powered devices.
The voltages settings seems to be hold. But this must be fixed, I think.
These users thanked the author smitna for the post (total 2):
odroid (Thu Dec 02, 2021 11:15 am) • mctom (Thu Dec 02, 2021 6:15 pm)

lsc1117
Posts: 280
Joined: Thu Aug 22, 2013 12:46 am
languages_spoken: english
Location: South Korea
Has thanked: 9 times
Been thanked: 37 times
Contact:

Re: SmartPower 3 log web frontend

Post by lsc1117 »

@smitna,

It's a very useful feature that I can show power data on my web browser.
SP3 doesn't need any firmware updates to use this feature!

It works well with only two lines of command on my Host-PC(x86 ubuntu).

User avatar
rooted
Posts: 9004
Joined: Fri Dec 19, 2014 9:12 am
languages_spoken: english
Location: Gulf of Mexico, US
Has thanked: 745 times
Been thanked: 422 times
Contact:

Re: SmartPower 3 log web frontend

Post by rooted »

Certainly makes for a nice way to display the date.

User avatar
mad_ady
Posts: 10178
Joined: Wed Jul 15, 2015 5:00 pm
languages_spoken: english
ODROIDs: XU4, C1+, C2, C4, N1, N2, H2, Go, Go Advance
Location: Bucharest, Romania
Has thanked: 632 times
Been thanked: 821 times
Contact:

Re: SmartPower 3 log web frontend

Post by mad_ady »

SMARTPOWERWIFI_IP:23
I don't get it... Is the web interface parsing log data via USB, or is there a way to turn on wifi on the SP3 and get it over telnet? If yes, how? (with the stock firmware)

lsc1117
Posts: 280
Joined: Thu Aug 22, 2013 12:46 am
languages_spoken: english
Location: South Korea
Has thanked: 9 times
Been thanked: 37 times
Contact:

Re: SmartPower 3 log web frontend

Post by lsc1117 »

@smitna,

I've been using my SP3 with this web feature for three hours. I have set the baudrate of SP3 to 921600bps and the interval to 5ms.
Could you share your set baud rate and interval? I have to learn how to reproduce the freezing issue.
sp3_web.jpg
sp3_web.jpg (487.32 KiB) Viewed 487 times


@mad_ady,

You can turn on WiFi in Firmware 2021/Nov/26.

https://wiki.odroid.com/accessory/power ... erial_port
These users thanked the author lsc1117 for the post:
mad_ady (Thu Dec 02, 2021 6:49 pm)

smitna
Posts: 15
Joined: Mon Feb 03, 2014 2:45 am
languages_spoken: english, german
ODROIDs: ODROID-X, ODROID-U3, ODROID-XU, 3x ODROID-C2, 2x ODROID-C4
Location: Germany
Has thanked: 1 time
Been thanked: 4 times
Contact:

Re: SmartPower 3 log web frontend

Post by smitna »

lsc1117 wrote:
Thu Dec 02, 2021 4:57 pm
@smitna,

I've been using my SP3 with this web feature for three hours. I have set the baudrate of SP3 to 921600bps and the interval to 5ms.
Could you share your set baud rate and interval?

sp3_web.jpg



@mad_ady,

You can turn on WiFi in Firmware 2021/Nov/26.

https://wiki.odroid.com/accessory/power ... erial_port

I have tested it with up to 921600 but much lower interval (>=100). You can also play with the refresh intervall in the JavaScript code (var delay).
Edit: Sorry your question was related to the freezing issue:
It happened starting with moderate rates from 230400 to the max 921600 and also a interval starting at 100 to 500.
I guess it's in the WiFi part, but I try to reproduce it and hope I get soon an error output vie USB.
Indeed, that could be the same: https://github.com/hardkernel/smartpower3/issues/9

@mad_ady,
It's working with the newest firmware and logging/WiFi on.
There is also a way to "websockify" the screen/telnet directly, but I haven't tried it yet.
Last edited by smitna on Thu Dec 02, 2021 9:39 pm, edited 1 time in total.
These users thanked the author smitna for the post:
mad_ady (Thu Dec 02, 2021 6:49 pm)

User avatar
mctom
Posts: 1016
Joined: Wed Nov 11, 2020 4:44 am
languages_spoken: english, polish
ODROIDs: N2+, Game Advance, a few XU4
Location: Gdansk, Poland
Has thanked: 104 times
Been thanked: 125 times
Contact:

Re: SmartPower 3 log web frontend

Post by mctom »

Very cool!
smitna wrote:
Thu Dec 02, 2021 6:50 am
After some random time the logging stops working and the LCD output freezes and the device needs a cold restart. That could happen after a short time or after a few hours. That's very strange and I hope not dangerous for the powered devices.
The voltages settings seems to be hold. But this must be fixed, I think.
I think this may be related to already filed issue on github, that firmware generally slowed down visibly with additional Wi-Fi task. Fortunately there are some ways identified to optimize the code quite easily.
Punk ain't no religious cult, punk means thinking for yourself!

Maintainer of PiStackMon

User avatar
odroid
Site Admin
Posts: 38570
Joined: Fri Feb 22, 2013 11:14 pm
languages_spoken: English, Korean
ODROIDs: ODROID
Has thanked: 2239 times
Been thanked: 1296 times
Contact:

Re: SmartPower 3 log web frontend

Post by odroid »

Is there any strange message from the USB device port console when the slow down or freezing problem?
We still can't reproduce the freezing issue yet as @lsc1117 said.

smitna
Posts: 15
Joined: Mon Feb 03, 2014 2:45 am
languages_spoken: english, german
ODROIDs: ODROID-X, ODROID-U3, ODROID-XU, 3x ODROID-C2, 2x ODROID-C4
Location: Germany
Has thanked: 1 time
Been thanked: 4 times
Contact:

Re: SmartPower 3 log web frontend

Post by smitna »

odroid wrote:
Thu Dec 02, 2021 7:13 pm
Is there any strange message from the USB device port console when the slow down or freezing problem?
We still can't reproduce the freezing issue yet as @lsc1117 said.
Ok, after some hours I have got the freeze, but this time the logging itself is still active (USB and WiFi).
Settings logging: 921600bps / 500 ms

I can change the settings with no effect (LCD, USB and of course WiFi):


Image

Logging gives no new values, no further error.

Image

Edit: Second freeze after ~30 min., same result.

This is not the right topic for this issue. Maybe I open a new one.

User avatar
odroid
Site Admin
Posts: 38570
Joined: Fri Feb 22, 2013 11:14 pm
languages_spoken: English, Korean
ODROIDs: ODROID
Has thanked: 2239 times
Been thanked: 1296 times
Contact:

Re: SmartPower 3 log web frontend

Post by odroid »

Okay. Please create another thread.

lsc1117
Posts: 280
Joined: Thu Aug 22, 2013 12:46 am
languages_spoken: english
Location: South Korea
Has thanked: 9 times
Been thanked: 37 times
Contact:

Re: SmartPower 3 log web frontend

Post by lsc1117 »

@smitna,

I can't reproduce the issue freezing the SP3 on my side. I have tested with this web frontend for 3~4 days. And I repeated the test three to four times.
I think the issue varies depending on the network environment.

We have changed the logging protocol to UDP from TCP because SP3 slowed down in the TCP protocol.
It is more stable and faster to use UDP on SmartPower3. After changing the protocol, we couldn't see any obvious system/display slow down issue yet.
But, we have a concern about data loss since UDP has no packet guarantee as far as we know.

https://wiki.odroid.com/accessory/power ... martpower3

However, we need an app that bridges between UDP and websocket like websockify.

User avatar
mad_ady
Posts: 10178
Joined: Wed Jul 15, 2015 5:00 pm
languages_spoken: english
ODROIDs: XU4, C1+, C2, C4, N1, N2, H2, Go, Go Advance
Location: Bucharest, Romania
Has thanked: 632 times
Been thanked: 821 times
Contact:

Re: SmartPower 3 log web frontend

Post by mad_ady »

That udp to tcp bridging should be doable with nc/socat: https://unix.stackexchange.com/question ... or-vlc-med
These users thanked the author mad_ady for the post:
smitna (Tue Dec 21, 2021 6:11 am)

smitna
Posts: 15
Joined: Mon Feb 03, 2014 2:45 am
languages_spoken: english, german
ODROIDs: ODROID-X, ODROID-U3, ODROID-XU, 3x ODROID-C2, 2x ODROID-C4
Location: Germany
Has thanked: 1 time
Been thanked: 4 times
Contact:

Re: SmartPower 3 log web frontend

Post by smitna »

lsc1117 wrote:
Mon Dec 20, 2021 12:30 pm
@smitna,

I can't reproduce the issue freezing the SP3 on my side. I have tested with this web frontend for 3~4 days. And I repeated the test three to four times.
I think the issue varies depending on the network environment.

We have changed the logging protocol to UDP from TCP because SP3 slow down in the TCP protocol.
It is more stable and faster to use UDP on SmartPower3. After changing the protocol, we couldn't see any obvious system/display slow down issue yet.
But, we have a concern about data loss since UDP has no packet guarantee as far as we know.

https://wiki.odroid.com/accessory/power ... martpower3

However, we need an app that bridges between UDP and websocket like websockify.
thanks for the test and the changes, I will try it.
But I don't think that I have problems with my network environment. Stable AC/N WiFi and 1 Gbit/10 Gbit-Network. I also cannot understand why the SmartPower3 freezes complely if only a network problem exists.
With the new UDP solution I have to change the JS code.

smitna
Posts: 15
Joined: Mon Feb 03, 2014 2:45 am
languages_spoken: english, german
ODROIDs: ODROID-X, ODROID-U3, ODROID-XU, 3x ODROID-C2, 2x ODROID-C4
Location: Germany
Has thanked: 1 time
Been thanked: 4 times
Contact:

Re: SmartPower 3 log web frontend

Post by smitna »

mad_ady wrote:
Mon Dec 20, 2021 2:28 pm
That udp to tcp bridging should be doable with nc/socat: https://unix.stackexchange.com/question ... or-vlc-med
yes, thanks for your hint, it's working with this change:
Example on SmartPower3 (192.168.0.74 is your ODROID C4 or an other linux host)
IP: 192.168.0.74
Port 6000

On an ODROID C4 (first terminal, your can change of course port 82 to an other free port)
sudo websockify 192.168.0.74:81 192.168.0.74:82 --web=/var/www/html/smartpower

and new with UDP on a second terminal / the same terminal when daemonizing websockify:
sudo netcat -u -l 6000 | netcat -k -l 82

There will be certainly a better solution, but it's working.

But in the moment this gives you no output in the browser because I have to change the Javascript. The data string from the the SmartPower now contains byte/hex data and that is not compatible for now.
These users thanked the author smitna for the post:
odroid (Tue Dec 21, 2021 9:33 am)

User avatar
mad_ady
Posts: 10178
Joined: Wed Jul 15, 2015 5:00 pm
languages_spoken: english
ODROIDs: XU4, C1+, C2, C4, N1, N2, H2, Go, Go Advance
Location: Bucharest, Romania
Has thanked: 632 times
Been thanked: 821 times
Contact:

Re: SmartPower 3 log web frontend

Post by mad_ady »

But in the moment this gives you no output in the browser because I have to change the Javascript. The data string from the the SmartPower now contains byte/hex data and that is not compatible for now.
Can you show a small sample of the udp and converted tcp data? Maybe there's something easy to change in the netcat settings. Try using wireshark on the input/output port at the same time.

Post Reply

Return to “Smart Power”

Who is online

Users browsing this forum: No registered users and 0 guests