Hi Mikko,
Is there any way of without using getparameters function we can set all following client settiings in python client example in following way.
settings.client.ciphering.Security = Security.ENCRYPTION
settings.client.SystemTitle = bytes("xxxxxxxx".encode('utf-8'))
settings.client.ciphering.authenticationKey =bytes("xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx".encode('utf-8'))
settings.client.ciphering.blockCipherKey = bytes("xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx".encode('utf-8'))
Please let me know how can I do?
Regards
Satish
Hi, Yes, this is how you can…
Hi,
Yes, this is how you can set the secured parameters if they are ASCII strings.
getParameters is used only to get command line arguments.
BR,
Mikko
Hi Mikko, Please let me know…
Hi Mikko,
Please let me know should I convert all keys in ASCII or I can give in hex . Please let me know by example which key I can give in ASCII and which in hex and how I will give them.
Thanks
Regards
Satish
Hi Mikko, I have set all my…
Hi Mikko,
I have set all my key properly as when I call initializeConnection() function it prints all set keys. But I'm not understanding if I call get parameter fuction then my code runs without any error but when I don't use getparameter function and set all keys and property manually then my program giving error. Please suggest. I'm giving my code as following:
client = GXDLMSSecureClient(useLogicalNameReferencing = True,clientAddress = 32, serverAddress = 1, forAuthentication = Authentication.LOW, password = bytes("ISK_SEC1".encode('utf-8')), interfaceType = InterfaceType.HDLC)
client.proposedConformance = client.proposedConformance | Conformance.GENERAL_PROTECTION
client.invocationCounter = "0.0.43.1.2.255"
client.ciphering.security = Security.ENCRYPTION
client.ciphering.systemTitle = bytes("ISK00001".encode('utf-8'))
client.ciphering.authenticationKey = bytes.fromhex("000102030405060708090A0B0C0D0E0F")
client.ciphering.blockCipherKey = bytes.fromhex("000102030405060708090A0B0C0D0E0F")
media = GXSerial(port="COM10")
media.baudRate = 9600
media.open()
reader = GXDLMSReader(client = client , media = media , trace = 0x8, invocationCounter = 0)
reader.initializeConnection()
obj = GXDLMSData("0.0.96.1.0.255")
x = reader.read(obj, 2)
print(f"Meter Sr. No is: {x}")
reader.disconnect()
media.close()
Authentication: 1
ClientAddress: 0x20
ServerAddress: 0x1
Standard: 0
Security: 32
System title: 49 53 4B 30 30 30 30 31
Authentication key: 00 01 02 03 04 05 06 07 08 09 0A 0B 0C 0D 0E 0F
Block cipher key: 00 01 02 03 04 05 06 07 08 09 0A 0B 0C 0D 0E 0F
TX: 12:29:08 7E A0 07 03 41 93 5A 64 7E
RX: 12:29:08 7E A0 20 41 03 73 3E 9D 81 80 14 05 02 03 40 06 02 03 40 07 04 00 00 00 01 08 04 00 00 00 01 B7 29 7E
TX: 12:29:08 7E A0 57 03 41 10 DF 07 E6 E6 00 60 49 A1 09 06 07 60 85 74 05 08 01 03 A6 0A 04 08 49 53 4B 30 30 30 30 31 8A 02 07 80 8B 07 60 85 74 05 08 02 01 AC 0A 80 08 49 53 4B 5F 53 45 43 31 BE 17 04 15 21 13 20 00 00 00 00 F4 8F 19 F6 58 14 32 72 55 06 FE BB A2 53 A5 F9 7E
RX: 12:29:08 7E A0 34 41 03 30 EC 5C E6 E7 00 61 26 A1 09 06 07 60 85 74 05 08 01 03 A2 03 02 01 01 A3 05 A1 03 02 01 01 BE 0D 04 0B 2E 09 20 00 00 0A DF 7C 32 48 1B CA FB 7E
Traceback (most recent call last):
File "C:\Users\s_paliwal\AppData\Local\Programs\Python\Python311\Lib\site-packages\gurux_dlms\_GXAPDU.py", line 819, in parsePDU2
_GXAPDU.parseUserInformation(settings, cipher, buff, xml)
File "C:\Users\s_paliwal\AppData\Local\Programs\Python\Python311\Lib\site-packages\gurux_dlms\_GXAPDU.py", line 330, in parseUserInformation
_GXAPDU.parseInitiate(False, settings, cipher, data, xml)
File "C:\Users\s_paliwal\AppData\Local\Programs\Python\Python311\Lib\site-packages\gurux_dlms\_GXAPDU.py", line 557, in parseInitiate
_GXAPDU.parse(initiateRequest, settings, cipher, data, xml, tag)
File "C:\Users\s_paliwal\AppData\Local\Programs\Python\Python311\Lib\site-packages\gurux_dlms\_GXAPDU.py", line 410, in parse
raise ValueError("Invalid tag.")
ValueError: Invalid tag.
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "C:\Users\s_paliwal\AppData\Local\Programs\Python\Python311\Final_08072024.py", line 69, in <module>
reader.initializeConnection() # First command start from here
File "C:\Users\s_paliwal\AppData\Local\Programs\Python\Python311\GXDLMSReader.py", line 312, in initializeConnection
self.client.parseAareResponse(reply.data)
File "C:\Users\s_paliwal\AppData\Local\Programs\Python\Python311\Lib\site-packages\gurux_dlms\GXDLMSClient.py", line 581, in parseAareResponse
self.isAuthenticationRequired = _GXAPDU.parsePDU(self.settings, self.settings.cipher, reply, None) == SourceDiagnostic.AUTHENTICATION_REQUIRED
File "C:\Users\s_paliwal\AppData\Local\Programs\Python\Python311\Lib\site-packages\gurux_dlms\_GXAPDU.py", line 655, in parsePDU
ret = _GXAPDU.parsePDU2(settings, cipher, buff, xml)
File "C:\Users\s_paliwal\AppData\Local\Programs\Python\Python311\Lib\site-packages\gurux_dlms\_GXAPDU.py", line 826, in parsePDU2
raise GXDLMSException(resultComponent, resultDiagnosticValue)
gurux_dlms.GXDLMSException.GXDLMSException: Connection is permanently rejected
No reason is given.
Hi, You have not read the…
Hi,
You have not read the invocation counter value from the meter and update it.
Check your block cipher and authentication keys.
BR,
Mikko
Thanks Mikko, Please let me…
Thanks Mikko,
Please let me know where I will update invocation counter value.
Regards
Satish
Hi, Check updateFrameCounter…
Hi,
Check updateFrameCounter method.
https://github.com/Gurux/Gurux.DLMS.Python/blob/9c7e211eb9dce49366c16de…
BR,
Mikko
Hi Kurumi & Mikko, Thanks a…
Hi Kurumi & Mikko,
Thanks a lot. Now issue has been resolved. I have no words to express my thanks.
Regards
Satish