Before commenting read Forum rules
Don't comment the topic if you have a new question.
You can create a new topic selecting correct category from Gurux Forum and then create a new topic selecting "New Topic" from the top left.
Before commenting read Forum rules
Don't comment the topic if you have a new question.
You can create a new topic selecting correct category from Gurux Forum and then create a new topic selecting "New Topic" from the top left.
Hi,
I am trying to write token to meter. It can write with its own MeterTalk application. But with Gurux I get an error.
When I read the tokenObject ("0.0.19.40.0.255")
_reader.AddToClientObject("0.0.19.40.0.255", Gurux.DLMS.Enums.ObjectType.TokenGateway);
_reader.GetScalersAndUnits();
var dlmsObject = _reader.GetObject();
GXDLMSTokenGateway tokenObject = (GXDLMSTokenGateway)dlmsObject;
tokenObject.Token = HexStringToByteArray(value, null);
--
result log:
tokenObject.Datavalue: 0000000001
tokenObject.DeliveryMethod: Remote
tokenObject.StatusCode: TokenExecutionOk
To write into the meter;
I tried with this:
_reader.Write(tokenObject, 1);
Log:
TX: 12:50:53 00 01 00 01 00 10 00 28 C9 26 30 00 00 00 07 E8 5F 85 F2 41 C2 2D 22 32 78 B7 23 62 A5 FB A7 BF 47 DF CA 49 97 A2 CA 44 B4 40 64 0F 8C FA 9F 13
RX: 12:50:55 00 01 00 10 00 01 00 17 CD 15 30 00 00 00 07 89 F9 C3 1F 8B 93 73 DE C0 95 19 A5 E7 1B F5 A1
Gurux.DLMS.GXDLMSException: Access Error : Device reports Read-Write denied.
-----
with this:
_reader.ReadDataBlock(_settings.Client.Write(tokenObject, 1), new GXReplyData());
Log:
TX: 12:50:55 00 01 00 01 00 10 00 28 C9 26 30 00 00 00 08 4A 21 F8 DB 0C D6 97 C9 F6 A2 E7 59 DF F2 AC A6 45 7C FE 87 D6 78 03 23 56 E3 2B 58 9F 96 4F 5D 61
RX: 12:50:56 00 01 00 10 00 01 00 17 CD 15 30 00 00 00 08 C0 44 C6 F1 62 D7 73 DE 13 24 8D 4E D4 F9 E4 E5
Gurux.DLMS.GXDLMSException: Access Error : Device reports Read-Write denied.
-----
and with this I do not get any response or error but it doesn't apply token:
_settings.Client.Method(tokenObject.LogicalName, ObjectType.TokenGateway, 1, tokenObject.Token, DataType.OctetString);
---
and this is the succesfully completed metertalk software log:
22-11-17 13:10:00:859 178.242.183.31:10000 Send: 00 01 00 01 00 10 00 63 60 61 80 02 07 80 A1 09 06 07 60 85 74 05 08 01 03 A6 0A 04 08 00 00 00 00 00 00 00 00 8A 02 07 80 8B 07 60 85 74 05 08 02 05 AC 12 80 10 57 AF 60 38 4A 3E 14 C4 48 E6 8D A4 20 74 7A 9E BE 23 04 21 21 1F 30 00 00 00 00 02 88 DA CE 66 E9 BC 96 F3 28 BC A6 75 02 5C 0B C3 48 4E 60 3F 6E 56 4C DA 3F
22-11-17 13:10:02:655 178.242.183.31:10000 Receive: 00 01 00 10 00 01 00 6B 61 69 A1 09 06 07 60 85 74 05 08 01 03 A2 03 02 01 00 A3 05 A1 03 02 01 0E A4 0A 04 08 45 44 4D 00 34 C4 B4 00 88 02 07 80 89 07 60 85 74 05 08 02 05 AA 12 80 10 E5 91 0E 72 93 62 E3 E1 93 19 79 7B 83 4D BB 62 BE 23 04 21 28 1F 30 00 00 00 00 41 91 9E 0F 8A 53 51 AF 9C 60 E4 0D D7 95 C1 48 81 5E 00 42 31 F4 AE BD 8C B4
22-11-17 13:10:02:673 178.242.183.31:10000 Send: 00 01 00 01 00 10 00 33 CB 31 30 00 00 00 02 12 16 A1 9B 7C 5D F6 84 68 3C 13 CA 96 0A 00 E9 71 9D 7C 72 20 6F F0 3B 4C 7C CD 9E DC 5D E4 52 5F 6A 4A 49 91 61 96 52 F4 4F 52 9A
22-11-17 13:10:04:251 178.242.183.31:10000 Receive: 00 01 00 10 00 01 00 2C CF 2A 30 00 00 00 02 16 0B AA FB 85 D2 D6 19 5F E2 84 DC C2 4C 33 1D D3 A3 23 47 5B 33 89 7C FE 9F F7 EA A3 BD 3E 3B EF D3 92 E1 91
17/11/2022 13:10:04 Meter Reading Start. CurrentTime:1
22-11-17 13:10:04:252 Write(ACTION) Write Token {115,0-0:19.40.0.255,01} Start
22-11-17 13:10:04:255 178.242.183.31:10000 Send: 00 01 00 01 00 10 00 36 CB 34 30 00 00 00 03 40 89 B2 64 1B EF 77 A3 2D 96 93 EB 8E B3 AC C2 D1 E6 45 9A 7D 79 ED A4 FF 91 82 45 47 4C C9 B9 FA 57 6A FA C4 B8 4A 45 BA C3 6B 56 20 53 21
22-11-17 13:10:05:795 178.242.183.31:10000 Receive: 00 01 00 10 00 01 00 21 CF 1F 30 00 00 00 03 80 2F C1 57 4E 2C 14 21 63 86 9F 46 6B 26 B3 56 09 ED 1D BA 7B D4 EF B9 13 88
22-11-17 13:10:06 WriteToken Action Result: token_status : (3)Token execution result OK
22-11-17 13:10:06:003 Write(ACTION) Write Token {115,0-0:19.40.0.255,01} Success!
17/11/2022 13:10:06 Meter Reading End. CurrentTime:1
Hi,
Hi,
Because you din't add the block cipher and authentication keys I can't check this from the bytes, but I believe that token is empty. Check the token.
_settings.Client.Method only generates the bytes. You need to send them to the meter after that.
BR,
Mikko
tokenObject.Token
Hi Mikko,
Hi Mikko,
Thank you for your reply.
When I read token object it says:
GetAccess(1) : Read
GetAccess3(1) : Read, Write
btw: Not sure about the difference between the two.
I can connect with HighGmac and I also set block cipher and auth keys:
Client.ClientAddress = 1;
Client.ServerAddress = 0x10;
Client.Authentication = Authentication.HighGMAC;
Client.Password = Encoding.ASCII.GetBytes("00000000");
Client.InterfaceType = InterfaceType.WRAPPER;
Client.Ciphering.SystemTitle = GXDLMSTranslator.HexToBytes("0000000000000000");
Client.Ciphering.Security = Security.AuthenticationEncryption;
Client.Ciphering.AuthenticationKey = GXDLMSTranslator.HexToBytes("00000000000000000000000000000000");
Client.Ciphering.BlockCipherKey = GXDLMSTranslator.HexToBytes("00000000000000000000000000000000");
I can read any value with this setting. Also the token object definitely has a token. Please see below.
Token Object token bytes: 64 2 16 36 41 89 19 131 148 114
Info: Receive-Send Waiting Time: 5 sn.
TX: 15:17:52 00 01 00 01 00 10 00 28 C9 26 30 00 00 00 07 E8 5F 85 F2 41 C2 2D 22 32 78 B7 23 62 A5 FB A7 BF 47 DF CA 49 97 A2 CA 44 B4 40 64 0F 8C FA 9F 13
RX: 15:17:53 00 01 00 10 00 01 00 17 CD 15 30 00 00 00 07 89 F9 C3 1F 8B 93 73 DE C0 95 19 A5 E7 1B F5 A1
Gurux.DLMS.GXDLMSException: Access Error : Device reports Read-Write denied.
This is my full log:
Send AARQ request 00 01 00 01 00 10 00 5F 60 5D A1 09 06 07 60 85 74 05 08 01 03 A6 0A 04 08 00 00 00 00 00 00 00 00 8A 02 07 80 8B 07 60 85 74 05 08 02 05 AC 12 80 10 74 26 2C 29 52 41 14 37 26 34 66 36 28 5E 32 59 BE 23 04 21 21 1F 30 00 00 00 00 02 88 DA CE 66 E9 BC 96 F3 4A DC E4 8E 4D 79 C8 75 EE 4D C4 B0 9B 68 6D 55 8F
Info: Receive-Send Waiting Time: 5 sn.
TX: 15:17:37 00 01 00 01 00 10 00 5F 60 5D A1 09 06 07 60 85 74 05 08 01 03 A6 0A 04 08 00 00 00 00 00 00 00 00 8A 02 07 80 8B 07 60 85 74 05 08 02 05 AC 12 80 10 74 26 2C 29 52 41 14 37 26 34 66 36 28 5E 32 59 BE 23 04 21 21 1F 30 00 00 00 00 02 88 DA CE 66 E9 BC 96 F3 4A DC E4 8E 4D 79 C8 75 EE 4D C4 B0 9B 68 6D 55 8F
RX: 15:17:38 00 01 00 10 00 01 00 6B 61 69 A1 09 06 07 60 85 74 05 08 01 03 A2 03 02 01 00 A3 05 A1 03 02 01 0E A4 0A 04 08 45 44 4D 00 34 C4 B4 00 88 02 07 80 89 07 60 85 74 05 08 02 05 AA 12 80 10 64 35 6E 56 5C 0B 82 3A FA DD 9F 05 6E 5C 3A 89 BE 23 04 21 28 1F 30 00 00 00 00 41 91 9E 0F 8A 53 51 AF 9C 60 E4 0D D7 95 C1 48 81 5E 00 42 31 F4 AE BD 8C B4
Parsing AARE reply61 69 A1 09 06 07 60 85 74 05 08 01 03 A2 03 02 01 00 A3 05 A1 03 02 01 0E A4 0A 04 08 45 44 4D 00 34 C4 B4 00 88 02 07 80 89 07 60 85 74 05 08 02 05 AA 12 80 10 64 35 6E 56 5C 0B 82 3A FA DD 9F 05 6E 5C 3A 89 BE 23 04 21 28 1F 30 00 00 00 00 41 91 9E 0F 8A 53 51 AF 9C 60 E4 0D D7 95 C1 48 81 5E 00 42 31 F4 AE BD 8C B4
Info: Receive-Send Waiting Time: 5 sn.
TX: 15:17:38 00 01 00 01 00 10 00 33 CB 31 30 00 00 00 01 AD 00 18 30 08 88 72 95 5B 32 13 95 64 F4 56 88 C5 A8 01 35 8C 35 48 99 06 94 A4 7D 56 48 00 06 25 FA 73 B6 94 97 4A A1 ED D7 04 3A
RX: 15:17:40 00 01 00 10 00 01 00 2C CF 2A 30 00 00 00 01 9E CA 71 6D E1 8D FA A2 D6 D6 20 EF 8D 14 1A AF C4 06 74 20 B6 CE C2 F8 2A F2 47 56 AA 8E 2A 96 F4 34 97 A1 BC
Parsing AARE reply succeeded.
Read scalers and units from the device.
-------- Reading GXDLMSTokenGateway 0.0.19.40.0.255
Info: Receive-Send Waiting Time: 5 sn.
TX: 15:17:44 00 01 00 01 00 10 00 20 C8 1E 30 00 00 00 02 11 16 E1 9B 00 5D F6 BF 40 3C 13 C9 97 0C C1 EA 97 A3 03 B0 6E 0B 16 C4 94
! Received byte count:210
Final! Received byte count:210
RX: 15:17:46 00 01 00 10 00 01 00 23 CC 21 30 00 00 00 02 15 0B EA FB 8D D8 B6 5F 36 62 13 DC FA 94 D4 F0 9C D8 8A F6 C6 B4 D5 38 A9 A5 55 6A
Index: 2 Value: 69 57 79 80 97 00 39 16 51 69
Info: Receive-Send Waiting Time: 5 sn.
TX: 15:17:46 00 01 00 01 00 10 00 20 C8 1E 30 00 00 00 03 43 89 F2 64 1B EF 77 A3 2D 96 93 E9 8F 89 D0 B4 7B CD 12 93 7F 20 25 FB 5F
! Received byte count:255
Final! Received byte count:255
RX: 15:17:47 00 01 00 10 00 01 00 25 CC 23 30 00 00 00 03 83 2F 81 57 46 20 11 C5 7E 94 9F 41 61 6F FC 79 B5 3E 69 4C C9 96 DE 29 2D 5D C0 92 62 32
Index: 3 Value: 17/11/2022 13:10:09
Info: Receive-Send Waiting Time: 5 sn.
TX: 15:17:47 00 01 00 01 00 10 00 20 C8 1E 30 00 00 00 04 DB 40 9C 70 87 2C 1A 63 53 59 E8 48 55 37 68 BB F9 D4 31 36 FB 7D 0D 27 37
! Received byte count:301
Final! Received byte count:301
RX: 15:17:49 00 01 00 10 00 01 00 26 CC 24 30 00 00 00 04 19 E6 AD 50 2B A4 38 B4 92 74 DB 4B 14 FF B9 16 63 BB DA D4 46 8B 3A 29 DD D7 A3 8F 62 88 1B
Index: 4 Value: [☺iWy??9▬Qi]
Info: Receive-Send Waiting Time: 5 sn.
TX: 15:17:49 00 01 00 01 00 10 00 20 C8 1E 30 00 00 00 05 17 9C 72 A1 39 51 8E F8 DB 4F DC E8 9D DA 05 06 04 E6 B6 12 FC 60 4D 17 6D
! Received byte count:334
Final! Received byte count:334
RX: 15:17:50 00 01 00 10 00 01 00 19 CC 17 30 00 00 00 05 C2 37 6F 60 35 8B B2 B6 E8 24 65 45 0B E5 42 46 05 36
Index: 5 Value: Remote
Info: Receive-Send Waiting Time: 5 sn.
TX: 15:17:50 00 01 00 01 00 10 00 20 C8 1E 30 00 00 00 06 02 50 79 9E E0 70 40 EA 14 4D 5E A0 E4 95 41 6F EF C4 9A 80 93 B9 50 A2 AD
! Received byte count:373
Final! Received byte count:373
RX: 15:17:52 00 01 00 10 00 01 00 1F CC 1D 30 00 00 00 06 49 E3 33 31 E3 87 81 A3 4A FB E5 7C 6A C5 36 A1 A5 5D 72 80 22 C9 A3 CE
Index: 6 Value: TokenExecutionOk, 0000000001
========== Token Object token bytes: 64 2 16 36 41 89 19 131 148 114 ==========
Info: Receive-Send Waiting Time: 5 sn.
TX: 15:17:52 00 01 00 01 00 10 00 28 C9 26 30 00 00 00 07 E8 5F 85 F2 41 C2 2D 22 32 78 B7 23 62 A5 FB A7 BF 47 DF CA 49 97 A2 CA 44 B4 40 64 0F 8C FA 9F 13
! Received byte count:404
Final! Received byte count:404
RX: 15:17:53 00 01 00 10 00 01 00 17 CD 15 30 00 00 00 07 89 F9 C3 1F 8B 93 73 DE C0 95 19 A5 E7 1B F5 A1
Gurux.DLMS.GXDLMSException: Access Error : Device reports Read-Write denied.
at DLMSClient.DLMSReader.ReadDLMSPacket(Byte[] data, GXReplyData reply) in C:\Repos\DLMSClient\DLMSReader.cs:line 271
at DLMSClient.DLMSReader.ReadDataBlock(Byte[] data, GXReplyData reply) in C:\Repos\DLMSClient\DLMSReader.cs:line 118
at DLMSClient.DLMSReader.ReadDataBlock(Byte[][] data, GXReplyData reply) in C:\Repos\DLMSClient\DLMSReader.cs:line 163
at DLMSClient.DLMSReader.Write(GXDLMSObject it, Int32 attributeIndex) in C:\Repos\DLMSClient\DLMSReader.cs:line 106
at DLMSClient.Program.WriteCredit(String value) in C:\Repos\DLMSClient\Program.cs:line 572
Disconnecting from the meter.
Info: Receive-Send Waiting Time: 5 sn.
TX: 15:17:53 00 01 00 01 00 10 00 05 62 03 80 01 00
! Received byte count:417
Final! Received byte count:417
RX: 15:17:55 00 01 00 10 00 01 00 05 63 03 80 01 00
Hi Aaron,
Hi Aaron,
Get the latest version from Gurux.DLMS.Net. Enter method is added for the Token Gateway object.
You need to send the token to the meter like this:
GXDLMSTokenGateway tokenObject = (GXDLMSTokenGateway)dlmsObject;
_reader.ReadDataBlock(tokenObject.Enter(_settings.Client, HexStringToByteArray(value, null)), new GXReplyData());
BR,
Mikko
Hi Mikko,
Hi Mikko,
I tried it and it doesn't get an error. However, it doesn't effect the meter. And also it doesn't get an error (and returns true for read data block) even if I send an invalid token like 0341.
0000000001 | Remote | TokenExecutionOk | 17/11/2022 13:10:09 | System.Byte[]
Token Object token bytes: 85 24 34 88 102 114 144 8 146 105
Read
Read, Write
Info: Receive-Send Waiting Time: 5 sn.
TX: 17:32:21 00 01 00 01 00 10 00 2C CB 2A 30 00 00 00 07 EA 5F 85 F2 41 C2 2D 22 32 78 B7 23 63 A5 F7 F2 A7 76 AF AC C4 47 20 E4 E9 82 3D 52 65 CC 24 2A 1B 8F 91 27 68
RX: 17:32:22 00 01 00 10 00 01 00 21 CF 1F 30 00 00 00 07 8B F9 C3 1C BA 19 F3 17 BB D9 98 3F C6 A6 26 29 F0 AD 75 4B 38 64 02 B3 2A ED
ReadDataBlock Response = True
Hi,
Hi,
The meter returns OK. I believe that the reason is in your token and the meter returns an OK even if it's invalid.
The other app is sending token: 55182258667290089269
You try to send token:3639353737393830393730303339313635313639
Your token is an ASCII string (55182258667290089269). You need to convert your token from hex string to bytes, not with ASCII.GetBytes.
BR,
Mikko
Hi Mikko,
Hi Mikko,
I don't know where did you find the token (3639353737393830393730303339313635313639) but I do convert from hex string to bytes. I even used GXDLMSTranslator.HexToBytes(token) but it didn't change anything.
I have written in the logs my Token Object token bytes: 85 24 34 88 102 114 144 8 146 105
Hi Mikko,
Hi Mikko,
Thank you so much for your help! After your say, I realized that the meter wants Ascii to get bytes.
So I changed it to like this and it worked.
_reader.ReadDataBlock(tokenObject.Enter(_settings.Client, ASCIIEncoding.ASCII.GetBytes(token)), new GXReplyData());
Hi hhkx,
Hi hhkx,
I also have a project to enter a token to power metter. May I know the brand of your power meter? and how do you get the password, AuthenticationKey and BlockCipherKey. Is that from power supplier?
Thanks
Hi araneta,
Hi araneta,
It is a customized meter. So I think you should check with your meter's manufacturer.