philippoo66 / optolink-splitter

Splitter for Viessmann Optolink connection
GNU General Public License v3.0
18 stars 4 forks source link

Error descriptions with return code 3 #19

Closed FransOv closed 3 months ago

FransOv commented 3 months ago

I have some trouble writing datapoints that according to the documentation are writable, but return an error: w ;0x3022;2;220 returns the response:3;0x3022;21 The 3 means Error message, presumably identified by the returned data 21. Any idea what the different error messages are?

Found out how to write the 2-byte temperature value: Command: w;0x3022;2;0xE600 Response: 1;0x3022;58880 Value written: 1;0x3022;230 (temp*10)

So it seems that in order to write a two byte integer I have to write a hex string in LSB format. Raw writes did not do anything, gave no response and had no effect. Turns out that with raw writes you do not specify the length as it is implicit in the hex string. The description of the raw writes in the wiki is incorrect.

I changed big into little in line 166 and 169 of module requests_util.py and now setting a 2 byte integer works correctly.

philippoo66 commented 3 months ago

Hi Frans!

In fact I never tested writing of 2 byte 'decimals' since there is no such 2 byte value in Vitodens to be written. The 'multi-byte values' such as time schedules have to get written 'top-down' (MSB-LSB - kind of big endian, even each time is only one byte as far as I remember).

So it is possible that 2 byte decimals need to get written LSB-MSB, what would make sense since when reading they come LSB-MSB as well. So I think I should apply your change. THANK YOU very much!

Turns out that with raw writes you do not specify the length as it is implicit in the hex string. The description of the raw writes in the wiki is incorrect.

Pls have a look at line 166 of request_util: bval = (utils.get_int(parts[3])).to_bytes(int(parts[2]), 'little') First the value (parts[3]) is converted to integer, what means that decimal or hex (leading 0x) can be given. Then this gets converted to_bytes with a lenght of parts[2], which is the data length according to the wiki. These bytes (with according/specified length) get performed by write_datapoint_ext, which takes the length from the len(bytes)

I think this is correct, or what do you think? I think the only bug was the wrong endian? {edit: see below!}

last not least: I do not have any information nor even an idea of the meaning of the error codes returned with a rejected request - sorry!

philippoo66 commented 3 months ago

SORRY! The line 166 applies to 'write', not to 'writeraw'. YOU ARE RIGHT, I will correct the Wiki, THANKS AGAIN!

FransOv commented 3 months ago

I searched through the code of a number of Optolink projects, but none of them had a list of error codes. At least I'm fairly sure now that error code 21 is "Value out of bounds".

philippoo66 commented 3 months ago

perhaps it would make sense to crawl Vitosoft for the codes? As far as I can see this early morning, the 21 is hex, isn't it?

FransOv commented 3 months ago

Looks like hex yes. Lines 170-172:

            elif(data):
                # probably error message
                val = utils.arr2hexstr(data)  #f"{int.from_bytes(data, 'little')} ({utils.bbbstr(data)})"
philippoo66 commented 3 months ago

do you have posibility to decompile Vitosoft.exe? My current Visual Studio is too old (2015), I think later ones can do

FransOv commented 3 months ago

You could try to use the strings command of Windows to find strings in an executable. However, I think the Vitosoft program stores it strings externally to support the translations. I'm looking at the Textresource_en.xml file in the ServiceTool\Web\XmlDocuments\ subdirectory of the program files directory of the Vitosoft program. Looks promising, but I have not found it yet.

philippoo66 commented 3 months ago

problem with text resource may be that the code mapping may be missing...

FransOv commented 3 months ago

I cannot find the error codes in the text resource xml. However by testing I found: 0x01: invalid address 0x04: invalid length 0x21: value out of bounds writing a read only value is ignored, does not return an error.