question

palu3492 avatar image
palu3492 asked

BlueSolar bulk HEX commands over serial getting inconsistent responses

I'm sending many HEX Get commands at one time to my BlueSolar 75|10 over serial via Python but the responses are almost never the full response.

Example request:

:7FEED0063

:71222001A

:71122001B

:790ED00D1

:7FDED0064

:7E5ED007C

Response:

:7FEED000162

:A0002000148

:A0102000048

:71122002003F8

:790ED01D0

:A0202000200000045

:AD5ED00DA04AB

:AADED000100B0

Some of the requests are getting responses but not all of them.

When I send about 70 commands at once I usually only get about 50 responses.

Python code:

import serial

string = """

:7FEED0063

:71222001A

:71122001B

:790ED00D1

:7FDED0064

:7E5ED007C

"""

s = serial.Serial('/dev/hw/bluesolar', baudrate = 19200,parity=serial.PARITY_NONE,stopbits=serial.STOPBITS_ONE, bytesize=serial.EIGHTBITS)

s.flushInput()

s.flushOutput()

s.write(string)

r = s.read_until("\r")

print(r)

Any idea why this happens?

Thanks.

MPPT Controllers
2 |3000

Up to 8 attachments (including images) can be used with a maximum of 190.8 MiB each and 286.6 MiB total.

1 Answer
Thiemo van Engelen (Victron Energy staff) avatar image
Thiemo van Engelen (Victron Energy staff) answered ·

Hi @palu3492

This happens because the MPPT does not have a very big input buffer for its serial port and it needs time to handle a command. Because of this, some bytes are lost on the MPPT side, causing it to receive incomplete commands and ignoring that data.

The solution is to send 1 command and wait for a response before sending the next command.

Kind regards,

Thiemo van Engelen


4 comments
2 |3000

Up to 8 attachments (including images) can be used with a maximum of 190.8 MiB each and 286.6 MiB total.

palu3492 avatar image palu3492 commented ·
Thanks for the answer. I suspected it was something like that but I wanted to avoid sending 70 individual commands and waiting for each to go through. I'll modify my code and test that out.


I did find that if I separated each command, in the bulk message, with many \n, I was able to get more responses from the MPPT.

0 Likes 0 ·
palu3492 avatar image palu3492 commented ·

I'm successfully retrieving all variables when sending each command individually. However, it seems I need a delay in between each command, or else the command will fail. How much delay is required? If I was retrieving 70 variables, do I need to send each request individually or is there a more efficent way to do this?

0 Likes 0 ·
Thiemo van Engelen (Victron Energy staff) avatar image Thiemo van Engelen (Victron Energy staff) ♦ palu3492 commented ·

Hi

It should not be necessary to add delays. When you wait until you have a proper answer for the request you sent (so when sending a :7 command, also wait for the corresponding :7 response) it should work.

When this is not the case, please add a logging that shows the problem so we can look at it.

Kind regards,

Thiemo van Engelen

0 Likes 0 ·
palu3492 avatar image palu3492 Thiemo van Engelen (Victron Energy staff) ♦ commented ·

I discovered my serial reading was the problem. A delay is no longer needed in my code. Fetching the 70 variables I'm looking for now takes about 4 seconds which is perfect for me.

Reading using the method read_until("\r") was the problem. I'm now essentially doing read_until(":7") + read_until("\n") then parsing.

Thanks!

0 Likes 0 ·