-
Notifications
You must be signed in to change notification settings - Fork 7
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
Function needs to return a negative number #4
Comments
If |
I think it’s the meaning of when +ve and -ve
Regards
Sunny Varma
…________________________________
From: Nazar Mokrynskyi ***@***.***>
Sent: Wednesday, August 23, 2023 9:57:55 AM
To: nazar-pc/solax-local-api-docs ***@***.***>
Cc: amravs ***@***.***>; Author ***@***.***>
Subject: Re: [nazar-pc/solax-local-api-docs] Function needs to return a negative number (Issue #4)
If n is 32768 or more the result will be negative. I have no idea why manufacturer couldn't just return normal signed integers, but we have what we have.
—
Reply to this email directly, view it on GitHub<#4 (comment)>, or unsubscribe<https://github.com/notifications/unsubscribe-auth/ARDTAV5H7SAKT6WHTY5U74TXWXAZHANCNFSM6AAAAAA33DP3F4>.
You are receiving this because you authored the thread.Message ID: ***@***.***>
|
at a guess they are simple 2's complement numbers poorly converted |
Yes you’re correct, I’m aligning the battery power inputs to the power card plus in home assistant where -ve for production and +ve for consumption.
Regards
Sunny Varma
…________________________________
From: Simone ***@***.***>
Sent: Wednesday, August 23, 2023 12:27:09 PM
To: nazar-pc/solax-local-api-docs ***@***.***>
Cc: amravs ***@***.***>; Author ***@***.***>
Subject: Re: [nazar-pc/solax-local-api-docs] Function needs to return a negative number (Issue #4)
at a glance they are simple 2's complement numbers poorly converted
—
Reply to this email directly, view it on GitHub<#4 (comment)>, or unsubscribe<https://github.com/notifications/unsubscribe-auth/ARDTAV43FVAFXZGZJSZQLHTXWXSI3ANCNFSM6AAAAAA33DP3F4>.
You are receiving this because you authored the thread.Message ID: ***@***.***>
|
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Hi
This is great work and helping me immensely extract data but when I apply the functions the flow of energy is always positive eg battery power should flow in and out depending on the demand?
function read16BitSigned(n) {
if (n < 32768) {
return n;
} else {
return n - 65536;
}
The returned value is always positive and a slight tweak to ensure a signed return would be to multiply the < 32768 by -1?
I aplied this change to my config and my energy flows are now correct.
function read16BitSigned(n) {
if (n < 32768) {
return n*-1;
} else {
return n - 65536;
}
What do you think?
The text was updated successfully, but these errors were encountered: