alengwenus / pypck

Asynchronous LCN-PCK library written in Python
MIT License
8 stars 4 forks source link

Comments in for outputs, relays, leds, keys, etc. #68

Closed maximilianriemensberger closed 3 years ago

maximilianriemensberger commented 3 years ago

The modules have a decent internal storage for commenting individual entities or functions like outputs, relays, leds, keys, logic ops, etc.

Is there a possibility to request those via pck? Those comments would be quite neat for generating a self explanatory modules dump beyond just address, serials, name, comment, and groups.

alengwenus commented 3 years ago

Short answer: No, it is not possible in a satisfactory way with PCK commands.

Long answer: The comments for outputs, relays, etc. seem to be stored consecutively in a huge buffer in the module. One can access the 12-bytes blocks of the buffer with commands (hex-mode) like X27EFFnn where nn is the block number in the range of [8, ...]. PCHK will convert the response message to =Mmmss.[tt] ([tt] is the text block). So far so good... Unfortunately comments can have a length >12 bytes and are therefore distributed over more than a single block. So the developers had to choose a separation byte between two comments in the buffer... They chose the \0 character (along with some identifier bytes for the port). And exactly this \0 character causes trouble with PCHK. When interpreting the incoming telegram data from the bus, PCHK seems to interpret the \0 character as a string termination and stops converting the remaining characters of the comment for the interpreted block. Those characters which actually belong to the subsequent comment are lost in the response message. So basically there is no sufficient working way to receive all these comments using PCK commands.

maximilianriemensberger commented 3 years ago

@alengwenus Thanks a lot for the explanation. Not the answer I had hoped to get. But those PCHK problems sound pretty fundamental.