Skip to main content
Home
for DLMS smart meters

Main navigation

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

Breadcrumb

  1. Home
  2. Arduino Code Issue

Arduino code issue

By technoshell, 8 June, 2025
Forums
Gurux.DLMS

I am using Arduino client code on ESP32 to read meter in MR mode with LLS.
I downloaded the latest version of Arduino and using MR association with encryption. I get a message on terminal as

<HT> :Start application<HT> :Start reading<HT> :Invocation Counter: 1793<HT> :com_initializeConnection SUCCEEDED 0<HT> :com_read failed. 285<HT> :Logical Device NameIndex: 2 Value: <LF>
<HT> :com_read failed. 285<HT> :com_read failed. 285<HT> :ClockIndex: 2 Value: 01/01/1970 00:00:00 UTC+00:00<LF>
Index: 3 Value: 0<LF>
Index: 4 Value: 0<LF>
Index: 5 Value: 01/01/1970 00:00:00 UTC+00:00<LF>
Index: 6 Value: 01/01/1970 00:00:00 UTC+00:00<LF>
Index: 7 Value: 0<LF>
Index: 8 Value: 0<LF>
Index: 9 Value: 0<LF>

Invocation counter is correct. Can you help me let know why is com_read() failing.?

I am using the following code.

void setup() {
pinMode(2, OUTPUT);
digitalWrite(2, HIGH);
//Serial 2 is used to send trace.
Serial2.begin(115200, SERIAL_8N1, RXD2, TXD2);
while(!Serial2);
delay(100);
GXTRACE(GET_STR_FROM_EEPROM("Start application"), NULL);
BYTE_BUFFER_INIT(&frameData);
//Set frame capacity.
bb_capacity(&frameData, 128);
Client.init(true, 32, 1, DLMS_AUTHENTICATION_LOW, "NCCMSELL", DLMS_INTERFACE_TYPE_HDLC);
//Un-comment this if you want to set system title, block cipher key or authentication key.

Client.SetSecurity(DLMS_SECURITY_AUTHENTICATION_ENCRYPTION);
//TODO: Change logical name of the frame counter if it's used to com_readAllObjects.
gxByteBuffer bb;
bb_Init(&bb);
bb_addHexString(&bb, "3132333435363738");
Client.SetSystemTitle(&bb);
bb_clear(&bb);
bb_addHexString(&bb, "4E43434D534544434C637279705F454E");
Client.SetAuthenticationKey(&bb);
bb_clear(&bb);
bb_addHexString(&bb, "4E43434D534544434C637279705F454E");
Client.SetBlockCipherKey(&bb);
bb_clear(&bb);

Serial.begin(9600); // Optical Probe
while (!Serial) {
; // wait for serial port to connect. Needed for native USB port only
}
GXTRACE(GET_STR_FROM_EEPROM("Start reading"), NULL);
//TODO: Change logical name of the frame counter if it's used.
int ret = com_readAllObjects("0.0.43.1.2.255"); //Invocation counter for MR association
com_close();
}

void loop()
{

}

technoshell

1 week 5 days ago

Good Morning Sir, Can you…

Good Morning Sir, Can you please help here.

Profile picture for user Kurumi

Kurumi

1 week 5 days ago

Hi, It looks like the…

Hi,

It looks like the Logical Device Name read failed for some reason. I can't solve this without the hex trace.

BR,
Mikko

technoshell

1 week 4 days ago

Good Morning Sir, Can you…

Good Morning Sir, Can you advise how to take a hex dump. Is there a flag that can be enabled to produce the hex dump on debug port?

Profile picture for user Kurumi

Kurumi

1 week 4 days ago

Hi, If you have two serial…

Hi,

If you have two serial ports, you can send the hex trace to the other serial port.

BR,
Mikko

technoshell

1 week 3 days ago

Good Morning Sir, I added a…

Good Morning Sir,

I added a bit of code to get the trace in the int readDLMSPacket(gxByteBuffer* data, gxReplyData* reply) sub-routine.
The code looks like this
// Read DLMS Data frame from the device.
int readDLMSPacket(
gxByteBuffer* data,
gxReplyData* reply)

{
char* hex;
int resend = 0, ret = DLMS_ERROR_CODE_OK;
if (data->size == 0)
{
return DLMS_ERROR_CODE_OK;
}
reply->complete = 0;
frameData.size = 0;
frameData.position = 0;

//Send Trace
hex = bb_toHexString(data);
GXTRACE("TX:", hex);
GXTRACE("\n", NULL);
free(hex);
//Send data.
if ((ret = Serial.write(data->data, data->size)) != data->size)
{
//If failed to write all bytes.
GXTRACE(GET_STR_FROM_EEPROM("Failed to write all data to the serial port.\n"), NULL);
}

//Loop until packet is complete.
do
{
if ((ret = com_readSerialPort(0x7E)) != 0)
{
if (ret == DLMS_ERROR_CODE_RECEIVE_FAILED && resend == RESEND_COUNT)
{
return DLMS_ERROR_CODE_SEND_FAILED;
}
++resend;
GXTRACE_INT(GET_STR_FROM_EEPROM("Data send failed. Try to resend."), resend);
if ((ret = Serial.write(data->data, data->size)) != data->size)
{
//If failed to write all bytes.
GXTRACE(GET_STR_FROM_EEPROM("Failed to write all data to the serial port.\n"), NULL);
}
}
ret = Client.GetData(&frameData, reply);
if (ret != 0 && ret != DLMS_ERROR_CODE_FALSE)
{
break;
}
} while (reply->complete == 0);
hex=bb_toHexString(&frameData);
GXTRACE("RX:", hex);
GXTRACE("\n", NULL);
return ret;
}

On the debug Serial Terminal I get the following dump

<HT> :Start application<HT> :Start reading<HT> :TX:7E A0 07 03 21 93 0F 01 7E<HT> :<LF>
<HT> :RX:7E A0 20 21 03 73 73 98 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<HT> :<LF>
<HT> :TX:7E A0 2B 03 21 10 FB AF E6 E6 00 60 1D A1 09 06 07 60 85 74 05 08 01 01 BE 10 04 0E 01 00 00 00 06 5F 1F 04 00 40 1E 1D FF FF E7 25 7E<HT> :<LF>
<HT> :RX: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 00 00 10 02 EE 00 07 A6 F3 7E<HT> :<LF>
<HT> :TX:7E A0 19 03 21 32 6F D8 E6 E6 00 C0 01 C1 00 01 00 00 2B 01 02 FF 02 00 0B B6 7E<HT> :<LF>
<HT> :RX:7E A0 15 21 03 52 5D 8A E6 E7 00 C4 01 C1 00 06 00 00 07 31 7F 75 7E<HT> :<LF>
<HT> :Invocation Counter: 1841<HT> :TX:7E A0 23 03 21 54 03 4E E6 E6 00 62 15 80 01 00 BE 10 04 0E 01 00 00 00 06 5F 1F 04 00 40 1E 1D 02 EE CE 40 7E<HT> :<LF>
<HT> :RX:7E A0 0B 21 03 63 B4 C7 63 00 E3 B3 7E<HT> :<LF>
<HT> :TX:7E A0 07 03 21 53 03 C7 7E<HT> :<LF>
<HT> :RX:7E A0 20 21 03 73 73 98 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<HT> :<LF>
<HT> :TX:7E A0 07 03 41 93 5A 64 7E<HT> :<LF>
<HT> :RX: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<HT> :<LF>
<HT> :TX:7E A0 63 03 41 10 C1 39 E6 E6 00 60 55 A1 09 06 07 60 85 74 05 08 01 03 A6 0A 04 08 31 32 33 34 35 36 37 38 8A 02 07 80 8B 07 60 85 74 05 08 02 01 AC 0A 80 08 4E 43 43 4D 53 45 4C 4C BE 23 04 21 21 1F 30 00 00 07 32 58 F9 3B 61 A2 68 60 3A C8 6C 3A 8E B6 DC 87 27 14 2F 29 5A 22 27 38 75 B9 E7 41 B2 7E<HT> :<LF>
<HT> :RX:7E A0 56 41 03 30 7E FC E6 E7 00 61 48 A1 09 06 07 60 85 74 05 08 01 03 A2 03 02 01 00 A3 05 A1 03 02 01 00 A4 0A 04 08 43 52 59 00 00 11 83 A5 BE 23 04 21 28 1F 30 00 00 07 32 11 1E 1E 6C 79 1E 78 5B 3F 93 9A 0B 66 BF C7 E3 43 4C 3B 22 E3 61 7D 42 16 06 58 75 7E<HT> :<LF>
<HT> :com_initializeConnection SUCCEEDED 0<HT> :TX:7E A0 2C 03 41 32 9F 9F E6 E6 00 C8 1E 30 00 00 07 33 B7 96 74 D7 23 65 91 6E 2E BA 76 13 02 78 26 80 1F D7 6E ED 08 2A 0E DC 3D 6C 77 7E<HT> :<LF>
<HT> :RX:7E A0 29 41 03 52 D6 54 E6 E7 00 CC 1B 20 00 00 07 33 F1 1D D5 8F F2 B5 ED 62 D6 2E 32 8E BC 80 E4 73 B8 65 2D C2 BB 32 F4 51 7E<HT> :<LF>
<HT> :com_read failed. 285<HT> :Logical Device NameIndex: 2 Value: <LF>
<HT> :TX:7E A0 2C 03 41 54 AF 99 E6 E6 00 C8 1E 30 00 00 07 34 E9 B4 B0 75 EB 65 1D 4C AA B5 B9 43 2A 0F 10 ED E6 AD EB F2 61 EC 14 87 C6 FD 17 7E<HT> :<LF>
<HT> :RX:7E A0 1A 41 03 74 DD 79 E6 E7 00 CC 0C 20 00 00 07 34 9A 7B CF 84 EB 0D F9 27 4A 7E<HT> :<LF>
<HT> :com_read failed. 285<HT> :TX:7E A0 2C 03 41 76 BF 9B E6 E6 00 C8 1E 30 00 00 07 35 07 62 50 60 03 C6 B1 12 FC 29 12 02 58 1A D6 BC CB 0C 77 39 17 DC C3 B2 DB C3 CA 7E<HT> :<LF>
<HT> :RX:7E A0 25 41 03 96 CA 43 E6 E7 00 CC 17 20 00 00 07 35 E4 DA AE 93 07 BE DD DB 6A 09 FD C8 5C AF DF 0D 39 8D 2D 95 7E<HT> :<LF>
<HT> :com_read failed. 285<HT> :ClockIndex: 2 Value: 01/01/1970 00:00:00 UTC+00:00<LF>
Index: 3 Value: 0<LF>
Index: 4 Value: 0<LF>
Index: 5 Value: 01/01/1970 00:00:00 UTC+00:00<LF>
Index: 6 Value: 01/01/1970 00:00:00 UTC+00:00<LF>
Index: 7 Value: 0<LF>
Index: 8 Value: 0<LF>
Index: 9 Value: 0<LF>
<HT> :TX:7E A0 36 03 41 98 C0 8A E6 E6 00 62 28 80 01 00 BE 23 04 21 21 1F 30 00 00 07 36 0D EE 0A 5D 41 CE 1B 42 80 FC 0C 7D 8C 42 18 1A 35 26 8A AD 0A 34 F5 9B 8D B7 97 AB 7E<HT> :<LF>
<HT> :RX:7E A0 0B 41 03 63 F9 C2 63 00 E3 B3 7E<HT> :<LF>
<HT> :TX:7E A0 07 03 41 53 56 A2 7E<HT> :<LF>
<HT> :RX: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<HT> :<LF>

Please help to identify the failure of Logical Device Name read if this data is correct or advise the correct code snippet to get the correct dump.

Best Regards

Profile picture for user Kurumi

Kurumi

1 week 3 days ago

Hi, You start to communicate…

Hi,

You start to communicate using AuthenticationEncryption, but the meter returns only encrypted data. The authentication tag is missing, and the received data is not accepted. Ask the meter manufacturer if there is a firmware update available.

BR,
Mikko

technoshell

1 week 3 days ago

Thank you Sir, I ran the…

Thank you Sir,

I ran the Gurux Python on the same meter and it shows correct loginal name with no errors.
Here is the dump. Arduino code should also produce the same result. Any advise if I am missing anything.?

PS D:\KIGG\GURUX-06-06-2025\Gurux.DLMS.Python-master\Gurux.DLMS.Client.Example.python> python main.py -S COM7:9600:8None1 -c 32 -a Low -P NCCMSELL -C Encryption -T 4142434445464748 -A 4E43434D534544434C637279705F454E -B 4E43434D534544434C637279705F454E -v 0.0.43.1.2.255 -d India -t Verbose
gurux_dlms version: 1.0.181
gurux_net version: 1.0.22
gurux_serial version: 1.0.21
Authentication: 1
ClientAddress: 0x20
ServerAddress: 0x1
Standard: 1
Security: 32
System title: 41 42 43 44 45 46 47 48
Authentication key: 4E 43 43 4D 53 45 44 43 4C 63 72 79 70 5F 45 4E
Block cipher key: 4E 43 43 4D 53 45 44 43 4C 63 72 79 70 5F 45 4E
TX: 12:52:57 7E A0 07 03 21 93 0F 01 7E
RX: 12:52:57 7E A0 20 21 03 73 73 98 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:52:57 7E A0 2B 03 21 10 FB AF E6 E6 00 60 1D A1 09 06 07 60 85 74 05 08 01 01 BE 10 04 0E 01 00 00 00 06 5F 1F 04 00 40 1E 5D FF FF 91 23 7E
RX: 12:52: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 00 00 10 02 EE 00 07 A6 F3 7E
TX: 12:52:58 7E A0 19 03 21 32 6F D8 E6 E6 00 C0 01 C1 00 01 00 00 2B 01 02 FF 02 00 0B B6 7E
RX: 12:52:58 7E A0 15 21 03 52 5D 8A E6 E7 00 C4 01 C1 00 06 00 00 07 43 EA 25 7E
Invocation counter: 1860
DisconnectRequest
TX: 12:52:58 7E A0 07 03 21 53 03 C7 7E
RX: 12:52:58 7E A0 20 21 03 73 73 98 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:52:58 7E A0 07 03 41 93 5A 64 7E
RX: 12:52:58 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:52:58 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 41 42 43 44 45 46 47 48 8A 02 07 80 8B 07 60 85 74 05 08 02 01 AC 0A 80 08 4E 43 43 4D 53 45 4C 4C BE 17 04 15 21 13 20 00 00 07 44 71 AB C4 B4 8D 04 90 CF 84 E4 33 E3 A8 BD A8 E8 7E
RX: 12:52:59 7E A0 4A 41 03 30 EB A8 E6 E7 00 61 3C A1 09 06 07 60 85 74 05 08 01 03 A2 03 02 01 00 A3 05 A1 03 02 01 00 A4 0A 04 08 43 52 59 00 00 11 83 A5 BE 17 04 15 28 13 20 00 00 07 44 5A 1C 8D 50 DA 3A 7F 9E 02 7E C5 27 CE 4E 45 EF 7E
Decrypted PDU: C0 01 C1 00 01 00 00 2A 00 00 FF 02 00
<GetRequest>
<GetRequestNormal>
<InvokeIdAndPriority Value="C1" />
<AttributeDescriptor>
<ClassId Value="0001" />
<InstanceId Value="00002A0000FF" />
<AttributeId Value="02" />
</AttributeDescriptor>
</GetRequestNormal>
</GetRequest>

TX: 12:52:59 7E A0 20 03 41 32 AB 08 E6 E6 00 C8 12 20 00 00 07 45 64 F4 18 8F 42 A1 9C 40 09 66 2A 44 18 69 44 7E
Decrypted PDU: C4 01 C1 00 0A 10 43 52 59 30 30 30 30 4D 48 31 31 34 37 38 31 33
<GetResponse>
<GetResponseNormal>
<InvokeIdAndPriority Value="C1" />
<Result>
<Data>
<String Value="CRY0000MH1147813" />
</Data>
</Result>
</GetResponseNormal>
</GetResponse>

RX: 12:52:59 7E A0 29 41 03 52 D6 54 E6 E7 00 CC 1B 20 00 00 07 45 67 6C 28 60 3C 20 93 09 41 4C 40 3A CD 6C 5D 25 13 A6 14 6F 61 94 BC 68 7E
CRY0000MH1147813
DisconnectRequest
TX: 12:52:59 7E A0 11 03 41 54 D2 5E E6 E6 00 62 03 80 01 00 BD 9B 7E
RX: 12:52:59 7E A0 0B 41 03 63 F9 C2 63 00 E3 B3 7E
TX: 12:52:59 7E A0 07 03 41 53 56 A2 7E
RX: 12:52:59 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

Profile picture for user Kurumi

Kurumi

1 week 3 days ago

Hi, You are using Encryption…

Hi,

You are using Encryption in Python and DLMS_SECURITY_AUTHENTICATION_ENCRYPTION in ANSI C.

You need to fix that.

BR,
Mikko

technoshell

1 week 3 days ago

You are right sir. I…

You are right sir. I corrected to DLMS_SECURITY_ENCRYPTION and now I am able to read Data Objects correctly like Make , Serial Number. But when I use Data type as register the com_read fails and the dump is like this

12-06-2025 17:00:34.296 [RX] - Start Application<HT> :TX:7E A0 07 03 21 93 0F 01 7E<HT> :<LF>
<HT> :RX:7E A0 20 21 03 73 73 98 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<HT> :<LF>
<HT> :TX:7E A0 2B 03 21 10 FB AF E6 E6 00 60 1D A1 09 06 07 60 85 74 05 08 01 01 BE 10 04 0E 01 00 00 00 06 5F 1F 04 00 40 1E 1D FF FF E7 25 7E<HT> :<LF>
<HT> :RX: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 00 00 10 02 EE 00 07 A6 F3 7E<HT> :<LF>
<HT> :TX:7E A0 19 03 21 32 6F D8 E6 E6 00 C0 01 C1 00 01 00 00 2B 01 02 FF 02 00 0B B6 7E<HT> :<LF>
<HT> :RX:7E A0 15 21 03 52 5D 8A E6 E7 00 C4 01 C1 00 06 00 00 08 25 12 A0 7E<HT> :<LF>
<HT> :Invocation Counter: 2085<HT> :TX:7E A0 23 03 21 54 03 4E E6 E6 00 62 15 80 01 00 BE 10 04 0E 01 00 00 00 06 5F 1F 04 00 40 1E 1D 02 EE CE 40 7E<HT> :<LF>
<HT> :RX:7E A0 0B 21 03 63 B4 C7 63 00 E3 B3 7E<HT> :<LF>
<HT> :TX:7E A0 07 03 21 53 03 C7 7E<HT> :<LF>
<HT> :RX:7E A0 20 21 03 73 73 98 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<HT> :<LF>
<HT> :TX:7E A0 07 03 41 93 5A 64 7E<HT> :<LF>
<HT> :RX: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<HT> :<LF>
<HT> :TX: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 31 32 33 34 35 36 37 38 8A 02 07 80 8B 07 60 85 74 05 08 02 01 AC 0A 80 08 4E 43 43 4D 53 45 4C 4C BE 17 04 15 21 13 20 00 00 08 26 5A 02 41 90 8D 1D DB A4 0C A0 B7 5B 8F 1F 74 18 7E<HT> :<LF>
<HT> :RX:7E A0 4A 41 03 30 EB A8 E6 E7 00 61 3C A1 09 06 07 60 85 74 05 08 01 03 A2 03 02 01 00 A3 05 A1 03 02 01 00 A4 0A 04 08 43 52 59 00 00 11 83 A5 BE 17 04 15 28 13 20 00 00 08 26 03 2F 1C A6 0F 0E B3 46 10 8B A2 F6 C9 EE C3 9C 7E<HT> :<LF>
<HT> :TX:7E A0 20 03 41 32 AB 08 E6 E6 00 C8 12 20 00 00 08 27 6B 85 5B EE 60 DB D2 8B D2 87 70 83 86 CF 76 7E<HT> :<LF>
<HT> :RX:7E A0 1D 41 03 52 C8 6A E6 E7 00 CC 0F 20 00 00 08 27 1D A1 11 BE 3F 5A 7E 8E 68 63 4E 46 7E<HT> :<LF>
<HT> :TX:7E A0 20 03 41 54 9B 0E E6 E6 00 C8 12 20 00 00 08 28 BC 01 79 64 8D FA 7D CE AF 5C 82 D5 77 AF 73 7E<HT> :<LF>
<HT> :RX:7E A0 1C 41 03 74 47 32 E6 E7 00 CC 0E 20 00 00 08 28 87 F3 69 B8 87 33 70 A2 A6 00 AC 7E<HT> :<LF>
<HT> :com_read failed. 2580.000000 KWh<HT> :TX:7E A0 2A 03 41 76 25 D0 E6 E6 00 62 1C 80 01 00 BE 17 04 15 21 13 20 00 00 08 29 7E 1A D0 1A FA 72 79 2F 13 AB E7 50 AA 6D 0E 2F 7E<HT> :<LF>
<HT> :RX:7E A0 0B 41 03 63 F9 C2 63 00 E3 B3 7E<HT> :<LF>
<HT> :TX:7E A0 07 03 41 53 56 A2 7E<HT> :<LF>
<HT> :RX: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<HT> :<LF>

The code used was

int com_readActive()
{
int ret;
char str[50];
char* data = NULL;
float scale;
float active_energy,reactive_energy,apparent_energy;
//Initialize connection.
ret = com_initializeConnection();
if (ret != DLMS_ERROR_CODE_OK)
{
GXTRACE_INT(PSTR("F"), ret);

return ret;
}

gxRegister reg1;

cosem_init(BASE(reg1), DLMS_OBJECT_TYPE_REGISTER, "1.0.1.8.0.255"); // OBis for Cum Active Energy (Imp)
com_read(BASE(reg1), 3); // Read Scaler and Units
com_read(BASE(reg1), 2); // Read Value

active_energy= var_toInteger(&reg1.value) *pow(10, reg1.scaler); // Read Active Energy Value by using var_toInteger()
sprintf(str, "%f KWh", active_energy);
Serial2.print(str);
obj_clear(BASE(reg1));
free(data);
com_close();

}

Request you to help with this error.

Thank You and Regards

technoshell

6 days 11 hours ago

Good Morning Sir, Could you…

Good Morning Sir,

Could you take a look at this latest issue where I am able to read the data objects but not register objects using ciper.?

Thank You

Profile picture for user Kurumi

Kurumi

6 days 6 hours ago

Hi, Your meter is returning…

Hi,

Your meter is returning float value and you don't need to convert it to an integer.
Change this line:

active_energy= var_toInteger(&reg1.value) *pow(10, reg1.scaler);

to this:

active_energy= reg1.value.fltVal *pow(10, reg1.scaler);

BR,
Mikko

technoshell

6 days 4 hours ago

Thank You Sir, I will do the…

Thank You Sir,

I tried but there is a error like this
error: 'dlmsVARIANT' {aka 'struct tagdlmsVARIANT'} has no member named 'fltVal'
1112 | active_energy=reg1.value.fltVal * pow(10, reg1.scaler);

Please advise

I also tried to check the type of data using reg1.value.vt but
Thank you and best regards

Here is the hex dump

Start Application<HT> :Start reading<HT> :TX:7E A0 07 03 21 93 0F 01 7E<HT> :<LF>
<HT> :RX:7E A0 20 21 03 73 73 98 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<HT> :<LF>
<HT> :TX:7E A0 2B 03 21 10 FB AF E6 E6 00 60 1D A1 09 06 07 60 85 74 05 08 01 01 BE 10 04 0E 01 00 00 00 06 5F 1F 04 00 40 1E 1D FF FF E7 25 7E<HT> :<LF>
<HT> :RX: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 00 00 10 02 EE 00 07 A6 F3 7E<HT> :<LF>
<HT> :TX:7E A0 19 03 21 32 6F D8 E6 E6 00 C0 01 C1 00 01 00 00 2B 01 02 FF 02 00 0B B6 7E<HT> :<LF>
<HT> :RX:7E A0 15 21 03 52 5D 8A E6 E7 00 C4 01 C1 00 06 00 00 08 CA EB BF 7E<HT> :<LF>
<HT> :Invocation Counter: 2250<HT> :TX:7E A0 23 03 21 54 03 4E E6 E6 00 62 15 80 01 00 BE 10 04 0E 01 00 00 00 06 5F 1F 04 00 40 1E 1D 02 EE CE 40 7E<HT> :<LF>
<HT> :RX:7E A0 0B 21 03 63 B4 C7 63 00 E3 B3 7E<HT> :<LF>
<HT> :TX:7E A0 07 03 21 53 03 C7 7E<HT> :<LF>
<HT> :RX:7E A0 20 21 03 73 73 98 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<HT> :<LF>
<HT> :TX:7E A0 07 03 41 93 5A 64 7E<HT> :<LF>
<HT> :RX: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<HT> :<LF>
<HT> :TX: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 31 32 33 34 35 36 37 38 8A 02 07 80 8B 07 60 85 74 05 08 02 01 AC 0A 80 08 4E 43 43 4D 53 45 4C 4C BE 17 04 15 21 13 20 00 00 08 CB 44 DA F2 81 A1 FC E2 A0 AD 77 84 3C F0 D2 96 10 7E<HT> :<LF>
<HT> :RX:7E A0 4A 41 03 30 EB A8 E6 E7 00 61 3C A1 09 06 07 60 85 74 05 08 01 03 A2 03 02 01 00 A3 05 A1 03 02 01 00 A4 0A 04 08 43 52 59 00 00 11 83 A5 BE 17 04 15 28 13 20 00 00 08 CB CF EC E8 5F B7 27 CB 56 93 83 29 50 16 08 7C 88 7E<HT> :<LF>
<HT> :com_initializeConnection SUCCEEDED 0<HT> :TX:7E A0 20 03 41 32 AB 08 E6 E6 00 C8 12 20 00 00 08 CC 80 0C 15 C2 19 94 4F CE 21 BF 58 8E 61 F6 57 7E<HT> :<LF>
<HT> :RX:7E A0 2F 41 03 52 4C 1F E6 E7 00 CC 21 20 00 00 08 CC A1 A6 C2 3C 97 D7 08 2A B8 A7 B6 DB 3E 9C 9D F9 3D 18 39 F6 02 3E 22 42 AE 6A 7C C0 A9 89 7E<HT> :<LF>
<HT> :Meter Make:Index: 2 Value: Sinhal Udyog Pvt. Ltd.<LF>
<HT> :TX:7E A0 20 03 41 54 9B 0E E6 E6 00 C8 12 20 00 00 08 CD 6F 04 CB 08 AD BC 39 51 C1 0B F6 D1 8C A3 B3 7E<HT> :<LF>
<HT> :RX:7E A0 1A 41 03 74 DD 79 E6 E7 00 CC 0C 20 00 00 08 CD 09 B3 CD 19 16 B5 D8 A0 4A 7E<HT> :<LF>
<HT> :TX:7E A0 20 03 41 76 8B 0C E6 E6 00 C8 12 20 00 00 08 CE EA CF 49 4B F3 AF F3 FC FF 70 ED 00 BE 0C 54 7E<HT> :<LF>
<HT> :RX:7E A0 25 41 03 96 CA 43 E6 E7 00 CC 17 20 00 00 08 CE BD 2E B0 29 6A E2 48 8B 5D 32 1C 57 E1 BF 66 BD 0E 1A 26 E1 7E<HT> :<LF>
<HT> :ClockIndex: 2 Value: 06/16/2025 20:19:34 UTC+05:30<LF>
Index: 3 Value: -330<LF>
Index: 4 Value: 0<LF>
Index: 5 Value: 01/01/1970 00:00:00 UTC+00:00<LF>
Index: 6 Value: 01/01/1970 00:00:00 UTC+00:00<LF>
Index: 7 Value: 0<LF>
Index: 8 Value: 0<LF>
Index: 9 Value: 0<LF>
<HT> :TX:7E A0 20 03 41 98 FB 02 E6 E6 00 C8 12 20 00 00 08 CF 8F 54 80 1A 04 5F 6E E0 16 07 96 EA 59 40 77 7E<HT> :<LF>
<HT> :RX:7E A0 1D 41 03 B8 9C 22 E6 E7 00 CC 0F 20 00 00 08 CF 4F 19 05 6F 72 B7 A5 D1 96 41 DB 7C 7E<HT> :<LF>
<HT> :TX:7E A0 20 03 41 BA EB 00 E6 E6 00 C8 12 20 00 00 08 D0 D4 96 FA 10 15 9B CF DB A9 AB 74 36 6A A2 75 7E<HT> :<LF>
<HT> :RX:7E A0 1C 41 03 DA 33 7E E6 E7 00 CC 0E 20 00 00 08 D0 C7 42 45 E2 3D 0F 43 BF C5 D7 66 7E<HT> :<LF>
<HT> :com_read failed. 258

Profile picture for user Kurumi

Kurumi

5 days 11 hours ago

Hi, You don't read the…

Hi,

You don't read the register in your last trace, and it doesn't give any information.
Check if you have defined DLMS_IGNORE_FLOAT32 in your code.

BR,
Mikko

  • Log in or register to post comments
  • Create new account
  • Reset your password

Hire Us!

Latest Releases

  • Thu, 06/19/2025 - 09:33
    Gurux.DLMS.Python 1.0.185
  • Wed, 06/18/2025 - 15:11
    Gurux.DLMS.Python 1.0.184
  • Wed, 06/18/2025 - 10:05
    Gurux.DLMS.Python 1.0.183
  • Wed, 06/18/2025 - 09:06
    GXDLMSDirector 9.0.2506.1801
  • Wed, 06/18/2025 - 08:41
    Gurux.DLMS.Net 9.0.2506.1801

New forum topics

  • object list not get downloaded for firmware upgrade association
  • HLS GMAC L+G 570
  • Unable to read parameter values from Landis+Gyr E550 meter using GXDLMSDirector - NoAccess status
  • data.SetComplete(false); But all data recieved
  • Crash (endless loop)
More
RSS feed
Privacy FAQ GXDN Issues Contact
Follow Gurux on Twitter Follow Gurux on Linkedin