python-e3dc
python-e3dc copied to clipboard
Catch wrong encryption key error (was: struct.error: unpack requires a buffer of 2 bytes)
Hi, Trying to get this running against a S10 Pro. Not sure if this is a problem with my system, or the module. Any tip would be greatly appreciated !
Python 3.7.3
Installed it via:
- git clone
- pip3 install .
Using the sample provided from the readme,:
`from e3dc import E3DC TCP_IP = 'x.x.x.x' USERNAME = 'xx' PASS = 'xx' KEY = 'xx' SERIALNUMBER = 'xx'
print("local connection") e3dc = E3DC(E3DC.CONNECT_LOCAL, username=USERNAME, password=PASS, ipAddress = TCP_IP, key = KEY) print(e3dc.poll()) print(e3dc.poll_switches())`
Executed: python3 test.py
Result: local connection Traceback (most recent call last): File "/usr/local/lib/python3.7/dist-packages/e3dc/_e3dc_rscp_local.py", line 51, in sendRequest receive = self._receive() File "/usr/local/lib/python3.7/dist-packages/e3dc/_e3dc_rscp_local.py", line 42, in _receive decData = rscpDecode( self.encdec.decrypt(data) )[0] File "/usr/local/lib/python3.7/dist-packages/e3dc/_rscpLib.py", line 149, in rscpDecode magic = struct.unpack(magicCheckFmt, data[:struct.calcsize(magicCheckFmt)])[0] struct.error: unpack requires a buffer of 2 bytes
During handling of the above exception, another exception occurred:
Traceback (most recent call last): File "/usr/local/lib/python3.7/dist-packages/e3dc/_e3dc.py", line 340, in sendRequest self.rscp.connect() File "/usr/local/lib/python3.7/dist-packages/e3dc/_e3dc_rscp_local.py", line 79, in connect ('RSCP_AUTHENTICATION_PASSWORD', 'CString', self.password)]) ) File "/usr/local/lib/python3.7/dist-packages/e3dc/_e3dc_rscp_local.py", line 54, in sendRequest raise CommunicationError e3dc._e3dc_rscp_local.CommunicationError
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "test.py", line 18, in
Mmm it seems that the system is returning some wrong data. I think that the only situation in which you could have this error is if the 'data' variable is smaller than 2 bytes. Maybe you can try troubleshooting by adding a print(len(data)) in rscpDecode before the statement that raised the error.
it prints out 0 any further idea would be greatly appreciated !
Maybe could you check the encryption key if it's correct?
facepalm that is --- thanks!!
Lol. Glad that we found the culprit. I should try to catch the error and return a meaningful error message.
Can someone help me where I find or set this encryption key? The only key I found is the cloud-registry key in "User Profile" but I get the same error as described here when I use that one.
In German:
Hauptmenü > Personalisieren > Benutzerprofil > RSCP Passwort
Thank you! Maybe someone could add that to the README.md to clarify "The encryption key as set under the preferences of the system"?
this info can be found in the readme (just checked) -> this issue can be closed I think?