I have issue with gxbytebuffer class in C++ Gurux branch on the CLIENT side. Steps for reproduction are listed below.
1. I use ciphering as is shown in the example here on your website (for client and server):
1.1. SERVER:
CGXByteBuffer tmp;
LNServer->GetCiphering()->SetSecurity(DLMS_SECURITY_ENCRYPTION);
GXHelpers::HexToBytes(m_thisDevice.devConfig.sysTitle, tmp);
LNServer->GetCiphering()->SetSystemTitle(tmp);
GXHelpers::HexToBytes(m_thisDevice.devConfig.blockCipherKey, tmp);
LNServer->GetCiphering()->SetBlockCipherKey(tmp);
GXHelpers::HexToBytes(m_thisDevice.devConfig.authenticationKey, tmp);
LNServer->GetCiphering()->SetAuthenticationKey(tmp);
1.2. CLIENT
CGXByteBuffer tmp;
cl->GetCiphering()->SetSecurity(dev->devConfig.security);
GXHelpers::HexToBytes(dev->devConfig.sysTitle, tmp);
cl->GetCiphering()->SetSystemTitle(tmp);
GXHelpers::HexToBytes(dev->devConfig.blockCipherKey, tmp);
cl->GetCiphering()->SetBlockCipherKey(tmp);
GXHelpers::HexToBytes(dev->devConfig.authenticationKey, tmp);
cl->GetCiphering()->SetAuthenticationKey(tmp);
2. During closing connecting I obtain this exception - Access violation writing.
Because to the function
int CGXByteBuffer::Set(const void* pSource, unsigned long count)
is passed negative value to the "count" var, so "count" is:
(maximal value for unsigned int) - (-count)
so this line
memcpy(m_Data + m_Size, pSource, count);
throws exception.
Now I list route to this exception (first line is function from C++ example available on your git):
1. int CGXCommunication::Close()
2. int CGXDLMSClient::ReleaseRequest(std::vector<CGXByteBuffer>& packets)
3. int CGXDLMS::GetLnMessages(CGXDLMSLNParameters& p, std::vector<CGXByteBuffer>& messages)
4. int CGXDLMS::GetLNPdu(CGXDLMSLNParameters& p, CGXByteBuffer& reply)
5. Line 960(second iteration): int CGXByteBuffer::Set(CGXByteBuffer* data, unsigned long index, unsigned long count)
6. int CGXByteBuffer::Set(const void* pSource, unsigned long count)
I have tried bunch of different settings and always same error. So I am desperate because It seems to be deep-core DLMS engine issue so I have no clue what is going on there. I have been only capable of detecting problem but I do not know why there is negative value passed to unsigned variable.
The reason is usually that meter is returning invalid data. Can you read the meter with GXDLMSDirector and add send and received bytes here. I need decrypted bytes that are received in a release. I can verify this.
DIRECTOR LOG: everything seems OK for connect and subsequent disconnect (tested multiple times). So I am confused even more. But maybe it indicates there is issue in my C++ implementation of the CLIENT.
You are not using a ciphered connection with GXDLMSDirector. With C++ you have set ciphered connection. Can you read the meter with GXDLMSDirector using a ciphered connection?
Connection using ciphering fails. One of your parameters in the "Secured Connections" tab is wrong.
Check them. I can't help you with this because one of the parameters is wrong and it depends from the meter. You need to consult this for the meter vendor.
Hi,
Hi,
The reason is usually that meter is returning invalid data. Can you read the meter with GXDLMSDirector and add send and received bytes here. I need decrypted bytes that are received in a release. I can verify this.
BR,
Mikko
DIRECTOR LOG: everything
DIRECTOR LOG: everything seems OK for connect and subsequent disconnect (tested multiple times). So I am confused even more. But maybe it indicates there is issue in my C++ implementation of the CLIENT.
GXDLMSDirector 8.2.2006.0401
Log created 11:34:42
11:34:57 Initializing Network connection.
11:34:58 Send SNRM request.
7E A0 20 03 21 93 7D D9 81 80 14 05 02 04 00 06 02 04 00 07 04 00 00 00 04 08 04 00 00 00 04 7C 44 7E
11:34:58
7E A0 1E 21 03 73 C3 7A 81 80 12 05 01 80 06 01 80 07 04 00 00 00 01 08 04 00 00 00 01 53 3B 7E
11:34:58 Parsing UA reply succeeded.
11:34:58 Send AARQ request.
7E A0 30 03 21 10 4F AC E6 E6 00 60 22 A1 09 06 07 60 85 74 05 08 01 01 A9 03 02 01 33 BE 10 04 0E 01 00 00 00 06 5F 1F 04 00 00 1E 1D FF FF 9B 7C 7E
11:34:58
7E A0 37 21 03 30 6C 7C E6 E7 00 61 29 A1 09 06 07 60 85 74 05 08 01 01 A2 03 02 01 00 A3 05 A1 03 02 01 00 BE 10 04 0E 08 00 06 5F 1F 04 00 B8 78 00 04 00 00 07 24 7F 7E
11:34:58 Parsing AARE reply succeeded.
11:35:16 Disconnect request
11:35:16 Disconnect request
7E A0 07 03 21 53 03 C7 7E
11:35:16
7E A0 1E 21 03 73 C3 7A 81 80 12 05 01 80 06 01 80 07 04 00 00 00 01 08 04 00 00 00 01 53 3B 7E
12:46:48 Initializing Network connection.
12:46:49 Send SNRM request.
7E A0 20 03 21 93 7D D9 81 80 14 05 02 04 00 06 02 04 00 07 04 00 00 00 04 08 04 00 00 00 04 7C 44 7E
12:46:49
7E A0 1E 21 03 73 C3 7A 81 80 12 05 01 80 06 01 80 07 04 00 00 00 01 08 04 00 00 00 01 53 3B 7E
12:46:49 Parsing UA reply succeeded.
12:46:49 Send AARQ request.
7E A0 30 03 21 10 4F AC E6 E6 00 60 22 A1 09 06 07 60 85 74 05 08 01 01 A9 03 02 01 33 BE 10 04 0E 01 00 00 00 06 5F 1F 04 00 00 1E 1D FF FF 9B 7C 7E
12:46:49
7E A0 37 21 03 30 6C 7C E6 E7 00 61 29 A1 09 06 07 60 85 74 05 08 01 01 A2 03 02 01 00 A3 05 A1 03 02 01 00 BE 10 04 0E 08 00 06 5F 1F 04 00 B8 78 00 04 00 00 07 24 7F 7E
12:46:49 Parsing AARE reply succeeded.
12:46:59 Disconnect request
12:46:59 Disconnect request
7E A0 07 03 21 53 03 C7 7E
12:46:59
7E A0 1E 21 03 73 C3 7A 81 80 12 05 01 80 06 01 80 07 04 00 00 00 01 08 04 00 00 00 01 53 3B 7E
Hi,
Hi,
You are not using a ciphered connection with GXDLMSDirector. With C++ you have set ciphered connection. Can you read the meter with GXDLMSDirector using a ciphered connection?
BR,
Mikko
I am sorry I forgot set
I am sorry I forgot set security to "Encryption" in DIRECTOR. Here is log:
GXDLMSDirector 8.2.2007.0602
Log created 09:24:05
09:24:10 Initializing Network connection.
09:24:11 Send SNRM request.
7E A0 0A 00 24 02 33 21 93 F2 96 7E
09:24:11
7E A0 21 21 00 24 02 33 73 AD 16 81 80 12 05 01 80 06 01 80 07 04 00 00 00 01 08 04 00 00 00 01 53 3B 7E
09:24:11 Parsing UA reply succeeded.
09:24:11 Send AARQ request.
7E A0 5F 00 24 02 33 21 10 0D A2 E6 E6 00 60 4E A1 09 06 07 60 85 74 05 08 01 03 A6 0A 04 08 AB CD EF 12 13 EF 12 13 8A 02 07 80 8B 07 60 85 74 05 08 02 00 BE 28 04 26 21 24 20 00 00 00 00 11 6A CE 2C AA 3D CA 7E A7 4E 59 1E F5 ED 81 0A 91 2D 19 77 68 E3 61 0B E4 13 26 4B F7 72 0B BA D0 7E
09:24:11
7E A0 34 21 00 24 02 33 30 58 23 E6 E7 00 61 23 A1 09 06 07 60 85 74 05 08 01 03 A2 03 02 01 01 A3 05 A1 03 02 01 01 A4 0A 04 08 AB CD EF 12 13 EF 12 13 9C CE 7E
09:24:11 Disconnect request
09:24:11
7E A0 21 21 00 24 02 33 73 AD 16 81 80 12 05 01 80 06 01 80 07 04 00 00 00 01 08 04 00 00 00 01 53 3B 7E
Gurux.DLMS.GXDLMSException: Connection is permanently rejected. No reason is given.
at GXDLMSDirector.GXDLMSDevice.InitializeConnection()
at GXDLMSDirector.MainForm.Connect(Object sender, GXAsyncWork work, Object[] parameters)
Hi,
Hi,
Connection using ciphering fails. One of your parameters in the "Secured Connections" tab is wrong.
Check them. I can't help you with this because one of the parameters is wrong and it depends from the meter. You need to consult this for the meter vendor.
BR,
Mikko