Skip to main content
Home
for DLMS smart meters
Open source solutions for DLMS smart metering

Main navigation

  • Home
  • Products
  • About us
  • Open Source
  • Community
  • Forum
  • Downloads
User account menu
  • Log in

Breadcrumb

  1. Home
  2. Forums
  3. Gxbytebuffer Exception

gxbytebuffer exception

Forum Rules

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.

By harvey , 14 July, 2020
Forums
Gurux.DLMS

Good morning,

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.

So I ask you for your advice.

Profile picture for user Kurumi

Kurumi

5 years 11 months ago

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

harvey

5 years 10 months ago

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

Profile picture for user Kurumi

Kurumi

5 years 10 months ago

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

harvey

5 years 10 months ago

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)

Profile picture for user Kurumi

Kurumi

5 years 10 months ago

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

  • Create new account
  • Reset your password

Hire Us!

Latest Releases

  • Tue, 06/09/2026 - 11:16
    gurux.dlms.java 4.0.95
  • Tue, 06/09/2026 - 10:03
    Gurux.DLMS.Python 1.0.199
  • Mon, 06/08/2026 - 13:39
    gurux.dlms.cpp 9.0.2606.0801
  • Mon, 06/01/2026 - 10:15
    gurux.dlms.cpp 9.0.2606.0101
  • Thu, 05/28/2026 - 16:06
    gurux.dlms.java 4.0.94

New forum topics

  • Error reading L&G Meter
  • Pass a TCP Client to GXNet
  • Australian EDMI Mk10D (Essential Energy area)
  • Strange mix of data notificiation vs get response
  • DLMS Connection
More

Who's new

  • Tuanhgg
  • Adel
  • charnon
  • Paddles
  • Miguel Ángel
RSS feed
Privacy FAQ GXDN Issues Contact
Follow Gurux on Twitter Follow Gurux on Linkedin