-
Notifications
You must be signed in to change notification settings - Fork 23
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
MCP39F511N metrics provider #429
Conversation
Eco-CI Output:
📈 Energy graph:
5.89 ┤ ╭╮ ╭╮ ╭───╮ ╭──────╮ ╭───╮╭─╮
5.47 ┤ ╭╮ ││ ╭╮ ││ │ ╰╮ ╭─╮╭╮ │ ╰╮ │ ││ │
5.04 ┤ │╰╮ ╭─╮ ╭╮╭╮ ╭╯│ ╭╮╭╮ ╭─╯│ ╭╯│ ╭╮ ╭──╮ ╭╮╭╮ ╭─╮ ╭╮ ╭╮ ╭╮ ╭╮ │ ╰╮╭─╯ ╰╯╰╮ │ ╰╮ │ ╰╯ ╰╮ ╭╮ ╭──╮ ╭╮ ╭╮ ╭╮ ╭╮ ╭╮ ╭╮ ╭╮ ╭╮ ╭╮ ╭╮ ╭╮ ╭
4.62 ┤ ╭╮╭╮ ╭╯ │╭─╯ ╰───────────╮╭─╯╰╯╰─╯ ╰──────────╯╰╯╰─╯ ╰─╯ ╰╮╭─────╮╭╯╰─────╮│ ╰───╯╰╯│ │ │╭╮ ╭╮╭─────────╯╰───╯╰─────╯╰───╯╰───────╯ ││ │ │ │ │ │ │╰╮ │ ╰─╮ ╭╮ ╭╮ ╭╮ ╭─╮ ││ ╭╮ ││ ╭─╯│ ╭╮ ││ ││ ╭──╮ ╭─╮ ╭╮╭╮ ╭╮ │╰╮ ││ ││ ╭╮ ││╭╮ ╭╮ ╭╮ ││ ││ ╭╯
4.20 ┤ ││││ │ ╰╯ ╰╯ ││ ╰╯ ││ ╰╮╭╮ │ ╰╯╰─╯╰╯ ╰╯ │ ╭╯ │╭╯ │ │ │╭╯ │ ╭╯│ ╭╮ ││ ╭─╮ ╭╯│ │ │ ╭╮ ╭─╮ │╰╮ ││ ╭╮ ╭╮ ││ │ │ ╭╮ ╭─╮││ ╭───╮ ╭╮ ╭╮││ ╭╮╭╮ ╭╮ ╭─╯│ ╭╮ ╭╮ │ │ ╭╮ │ │ ││││ ││ │ │ ││ │╰╮ ││ ││││ ╭─╮ ││ ╭╮ ││ │╰╮││ ╭╮ ╭╮ │
3.78 ┤ │││╰─╯ ││ ╰╯ │││ │ │╭╮ │ ╰╯ │ │ ││ │ ╭╮╭╮ ╭╮ ╭╯ │ ││ ╭╯│ │ │ │ │ │ │ ╭─╮ ││ │ │ │ │ ││ ││ ││ │╰╮ │ │ ││ ╭╮ │ ╰╯│ ╭╮ │ │ ││ │╰╯│ ││││ ││ │ │ ││╭╮ ││ │ │ │╰╮ ╭─╮╭╯ ╰╮ ││││ ││ │ │ ╭╮ │╰╮ │ │ │╰╮││││ │ │ ╭╯│╭╮ ││ ╭╯│ │ ╰╯│ ││╭╮ ││ │
3.36 ┤ ╭─╯╰╯ ╰╯ ╰╯│╭╯ ╰╯│ ╭╯ │ ╭╯ ╰╯ ╰╮ ╭─╯╰╯╰╮ │╰╮│ │ ││ │ ╰╮ │ │ │ ╰╮ │ ╰╮ │ │ │╰╮ │ │ │ │ │╰╮ │╰╮ ╭╯│ │ │ │ ╰╮ │╰╮ │╰╮│ │ ╭╮ │╰╮│ │ ╭╮ │╰╮│ ╰╮ ╭─╯╰╯╰╮ │╰╮│ ╰╮ ╭─╯╰╯│ ││ │ │ ╭╯ ╰─╮ │ ││ │ ╭─╯│││ ││ │ │ ││ │ │ ╭╮ ╭╮ ╭╯ │ ╭─╯ ╰╯│││ ╭╮│ │ ╭╯ │││ ╭╯│ ╭╯ │╭╮ ╭╮ │ ╰╮ ╭─╯│││ ╭╯│ │
2.93 ┤ │ ╰╯ │ ╭─╮ │ │ │ │ │ │ │ ││ │ │╰╮ │ │ │ ╰╮ │ │ │ │ │ │ ╭╯ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ ││ │ ╭╯│ │ ││ │ │╰╮ │ ││ │ │ │ │ ││ │ │ │ ╭╯│ │ │ ╭╯ │ │ ││ │ │ ╰╯│ ││ │ │ ││ ╭╯ │ ╭╯│ ╭╯│ │ ╰╮ │ │││ │││ │ │ ││╰╮ ╭╮│ ╰╮ │ │││ ││╭╯ │ │ ╰╯│ │ │╭╯
2.51 ┤ │ │ │ │ │ ╰╮ │ │ │ │ │ ││ │ │ │ ╭╮ │ │ │ │ │ │ ╭╯ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ ╰╮ │ │ ╭╯ │ │ ││ │ │ │ │ ││ │ │ │ │ ││ │ │ │ │ ││ │ │ │ │ ╰─╯ │ │ │ │ ││ │ │ │ │╰╮│ │ ││ │ │ │ │ │ │ │ │ │ │││ ╭╯││ ╰╮ │ ││ │ │││ │ │ ╰╯│ │││ │ │ │ │ ││
2.09 ┼╮ ╭╯ ╰────╯ │ │ │ │ ╰─╮ │ │ ╭╮╭╮│ ╰╯ ╰╮╭╮╭╮ ╭─╯ ╰╮││ │ ╰─╮ ╭╮╭╯ │ ╭╯ │ ╭╮╭╮│ │ ╭╮╭╮╭╯ │ ╭╮ ╭╯ │╭╮ ╭╯ ╰╮╭╮ │ │ ╭╮ ╭──╮│ ╰╮╭╮ ╭╯ │ ╭╮ ╭╯ │╭╮ ╭╮│ │╭╮ ╭╮ ╭╯ ╰╮ ╭╮ ╭╮│ │ ╭╯ ╰╯ ╰╮╭╮ ╭╯ │ ╭╮ │ ││ │╭╮ ╭─╮│ │ ╭─╮ ╭╯ ││ │ │ ╰╮╭╮ ╭╮╭╯ ││ ╰──╮ ╭╮│ ╰╮ ╭╮│ │╭╮╭─╮ │ ╰╮ │ ││ │ ╭─╮╭╮╭╯ ╰╮ ╭╮ ╭╯ ╰╯ ╰╮╭╮ ╭╯╰╮╭╮ ╭─╯ ╰─╮╭╮ │ │ ╭╮ ╭╯ │ ╭╮ ╭╮╭╯ ╰─╮ ╭╮ │ ╰╯╰╮ ╭──╮ │ ││ ╰╮ ╭╮ │ ╰╯ │ ╭╯││ │╭╮╭─╮ │ │╭─╮╭╮╭╮│││ │ ╭╮ │ │ ╭╮ ╭╮╭╯ ││
1.67 ┤╰──╯ ╰─╯ ╰─────╯ ╰─────╯ ╰───╯╰╯╰╯ ╰╯╰╯╰──╯ ╰╯╰─────╯ ╰───╯╰╯ ╰───────╯ ╰───╯╰╯╰╯ ╰───╯╰╯╰╯ ╰──╯╰───╯ ╰╯╰─────╯ ╰╯╰──────╯ ╰─╯╰──╯ ╰╯ ╰╯╰────╯ ╰────╯╰─╯ ╰╯╰─────╯╰╯ ╰╯╰──╯╰─╯ ╰─╯╰─╯╰╯ ╰──────╯ ╰╯╰────╯ ╰────╯╰─╯ ╰╯ ╰╯╰───╯ ╰╯ ╰─╯ ╰──╯ ╰╯ ╰───────╯ ╰╯╰─╯╰╯ ╰╯ ╰──╯╰╯ ╰────╯╰╯ ╰╯╰╯ ╰──╯ ╰──────╯ ╰╯ ╰─╯ ╰╯╰╯ ╰───╯╰─╯ ╰╯╰─────╯ ╰╯╰───╯ ╰╯╰────╯ ╰──╯╰───╯ ╰─╯╰──╯╰╯ ╰──╯╰─╯ ╰─╯ ╰─╯ ╰╯ ╰─╯╰───╯ ╰─────╯ ╰╯ ╰╯╰╯ ╰──╯ ╰╯ ╰╯╰╯╰╯╰╯ ╰──╯╰───╯ ╰─╯╰─╯╰╯ ╰╯
Watts over time |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Just an initial quick read. Is this something we want to maintain for the future? The I would probably refactor it. I can do this :)
printf("\t-i : specifies the milliseconds sleep time that will be slept between measurements\n\n"); | ||
exit(0); | ||
case 'i': | ||
msleep_time = atoi(optarg); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why is msleep_time
global and not in main
?
sizeof(f511_set_accumulation_interval), | ||
(unsigned char *)&reply, fd); | ||
if(res < 0) return res; | ||
return fd; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Where is fd
defined? Or is this the global fd? Why return it then?
|
||
setvbuf(stdout, NULL, _IONBF, 0); | ||
|
||
long fd = f511_init("/dev/ttyACM0"); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The function returns an int
but is long
here? And fd
is already defined globally?
|
||
command_packet[0] = 0xa5; | ||
command_packet[1] = cmd_length + 3; | ||
memcpy(command_packet + 2, cmd, cmd_length); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
cmd
and cmd_length
are not checked if they fit into cmd
for (i = 0; i < cmd_length + 2; i++) { | ||
checksum += command_packet[i]; | ||
} | ||
command_packet[i] = checksum; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
why if cmd_length
is > 80
} | ||
command_packet[i] = checksum; | ||
tcflush(fd, TCIOFLUSH); | ||
len = write(fd, command_packet, cmd_length + 3); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why is fd passed as a parameter if it is defined globally?
|
||
const unsigned char f511_read_active_power[] = { 0x41, 0x0, 0x16, 0x4E, 8 }; | ||
const unsigned char f511_read_active_power1[] = { 0x41, 0x0, 0x16, 0x4E, 4 }; | ||
const unsigned char f511_read_active_power2[] = { 0x41, 0x0, 0x1a, 0x4E, 4 }; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What is the difference between these read power chars?
* main: (103 commits) Removing some noise debug BCC typos Bump actions/checkout from 3 to 4 (#450) Bump orjson from 3.9.7 to 3.9.9 (#506) Bump fastapi from 0.103.2 to 0.104.0 (#511) Added BCC functionality for email sending (#510) Refactors the system checkers (#507) Bump psutil from 5.9.5 to 5.9.6 (#508) FIXME disabled in Pylint Added simple HTML5 validation to request.html Network key is optional for HOG Clarified error message and clarified actual exception caught extends the install script to have a random password option (#504) Jobs.py now sends email when old jobs are present; Bugfixes in SQL query Flow process runtime bumped to 60+ minutes Sorting must be additionaly done by table to show indicator Repositories generated table also shall show sorting indicators Removing legacy datatable includes for energy-timeline Removed 'sortable' class where we are using datatables and not jQuery-Sort Bugifx: If Jobs object is not set do not access ...
Eco-CI Output:
📈 Energy graph:
7.07 ┤ ╭╮ ╭╮
6.53 ┤ ││ ││
5.99 ┤ ││ ╭─╮ ╭╮╭╮ ╭─╮ ││
5.45 ┤ ╭╮ ╭╯│ │ ╰╮ │││╰──╮ │ ╰─╯│
4.91 ┤ ╭╮ ╭╮││ ╭╮ │ │ ╭╯ │ ╭────╮ │╰╯ ╰╮ │ │
4.37 ┤ ╭╯│ ╭──╮ ╭╮│││╰╮ ││ │ ╰╮ ╭╮ │ ╰╮╭─╯ │ │ │╭╯ │ ╭╮╭╮ ╭╮ ╭╮ ╭╮ ╭╮
3.83 ┤ │ ╰────╮╭─────────╮│ ╰╮ ╭──────────╮╭─────────╯││││ │ ││╭───╮╭─╮ ╭────────────╮│ ╰──────╯╰───────╯ ││ │ │ ││ │ ╭╯│││ ╭─╮ ╭╮ ╭╮ ╭╮ ╭╮ ╭╮ ││ ╭─╮ ╭╮ ╭╮ ╭╮ ╭╮ ││ ╭╮ ╭╯│ ╭╮ ╭╯│ ╭╮ ╭╮ ╭──╮╭╮ ╭╮
3.29 ┤ ╭╯ ╰╯ ╰╯ ╰─╯ ╰╯ ╰╯╰╯ │ │╰╯ ╰╯ ╰───╯ ││ ││ ╰╮ │ ││ │ │ │││ │ │ ╭╮ ╭╮ │╰╮ ╭╮ ╭─╮ │╰╮ │╰╮ │╰╮ ╭╮ ╭─╮ ╭─╮ ╭─╮ ╭╮ ╭─╮ │╰╮ ╭╯│ │ ╰╮ ││ ╭─╯╰╮ ╭╮ ╭╯╰╮ ││ ╭╯╰╮ ╭╮ ││ │ ╰╮ ╭╮ ╭╯╰╮ ╭╮ ╭╮ │ ╰╮ ╭╮ ╭╮ │╰╮ ╭╮ ╭─╮ ╭╮ ╭╮ │╰╮ ╭──╮ ╭╮ ╭─╮ ╭╮ │ ╰╯│ ││ ╭─╮
2.75 ┤ │ │╭─╯ ││ ╰╯ │╭╮ ╭╯ ╰╯ ╰╮ │ ╰╯╰─╯ │ ╭╯│╭╮ ││ │ ╰╮ ╭╯│ │ ╰╮ ╭╯ │ │ │ │ │ ╭╯│ │ │ │ │ │ ╰╮ ╭╯│ │ │ │ │ │ │ │ │ ╭╮ ││ │ │ ││ │ ╰╮ ╭╮ ││ │ │ ││╭╮ ││ │ │ ╭╯│╭╮ ╭─╮╭╯ │ ││╭╮ ││ │ │ ╭╯│╭╮ ││ │ │ │╰╮ ╭╯ │ ││ │╰╮ ╭╯ │ │ │╭╮ ╭╯╰╮ ╭─╮ │ │ ╭╯│ │ ╰╮ ╭─╮ ││ │ ╰╮ ╭
2.21 ┤ │ ╰╯ ╰╯ │││ │ │ ╭╯ │ │ │││ ╭╯│╭╯ │ │ ╰╮ │ │ │ │ ╭╮ │ ╰╮ │ ╰╮ │ ╰╮ │ │ │ ╰╮ │ │ │ ╰╮ │ │ │ │ ╭╯ ╰╮ │ ╰╮ ││ ││ │ │ ╭╮ │╰╮│ │ ││ ││ │ ╰╮ ╭╯╰╯│ ││ │ │ │ │││ │ ││ │ ╭─╯│││ ╭╯│╭╯ │ │ │││ ╭╯│╭╯ │ │ │ │ │ ╭╯│ │ │ │ ╰╮ ╭╯ ╰╯│ ╭╮│ │ ╭╯ ╰╮ │ │ │ ╰─╮ ╭╮╭╯ │ ╭╮ ╭╯ ╰╮ ││ │ │ │
1.67 ┼────╯ ╰╯╰──────╯ ╰──────╯ ╰────────╯ ╰╯╰───────╯ ╰╯ ╰────────╯ ╰────────╯ ╰────────╯ ╰───╯╰────╯ ╰────────╯ ╰────────╯ ╰────────╯ ╰─────────╯ ╰────────╯ ╰────────╯ ╰────────╯ ╰─────────╯ ╰────────╯ ╰────────╯ ╰────────╯╰────────╯╰─╯ ╰────────╯╰────────╯ ╰╯ ╰────────╯╰────────╯╰─╯ ╰───────╯ ╰────────╯╰─╯ ╰────────╯ ╰╯╰───────╯ ╰╯ ╰───────╯ ╰╯╰───────╯ ╰╯ ╰────────╯ ╰╯╰───────╯ ╰╯ ╰─────────╯ ╰────────╯ ╰────────╯ ╰─────────╯ ╰────────╯ ╰───────╯ ╰────────╯╰╯ ╰───────╯ ╰──────────╯ ╰────────╯ ╰───────╯╰╯ ╰────╯╰─╯ ╰────────╯╰─╯ ╰───────╯
Watts over time |
Updated. @ribalba Can you give it another look? I clarified in the code what the original author is doing, although some implementations are not documented and cannot be checked completely |
I will merge it in for now, please put your comments in here if you have any |
@ribalba Can you give the C code a quick read.
As said in the file: I am including a library of unknown original origin.