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. Set/Write OctetString Type Objects

Set/Write OctetString type objects

By Mahaveer , 2 July, 2024
Forums
Gurux.Net

Hi Team,

I am writing value to Last Token Recharge Time: 0.0.94.96.22.255 in meter with data (02/07/2024 10:30:40 AM) which is with data type OctetString, but I am getting an error as
Access Error : Device reports a inconsistent Class or object.

I am using below code for write value.

GXReplyData reply = new GXReplyData();
GXDLMSObject obj = Client.Objects.FindByLN(ObjectType.Data, "0.0.94.96.22.255");
((GXDLMSData)obj).Value = "02/07/2024 10:30:40 AM";
ReadDataBlock(Client.Write(obj, 2), reply);

Can you please guide me to set the value in a given object, here the datatype is OctetString and the value in datetime format. I also tried to set with datetime datatype, array, byte. but nothing is working and getting the same error as above.

Thanks

Profile picture for user Kurumi

Kurumi

2 years ago

Hi, At first, read the value…

Hi,

At first, read the value. It will update the data type. Then try to write the value back to the meter. When it works you can update the new date time like this:

((GXDLMSData)obj).Value = new GXDateTime("02/07/2024 10:30:40 AM");

BR,
Mikko

Mahaveer

2 years ago

Hi Kurumi, Thanks for your…

Hi Kurumi,

Thanks for your response and now it's working fine.

Can you please guide me one thing in c# using gurux library how can we convert datetime value to OctetString.

I want to convert this [07/02/2024 06:43:30 AM]
to
"07 E7 0C 18 FF 00 00 00 FF 01 4A FF"

Regards,
Mahaveer Prajapati

Profile picture for user Kurumi

Kurumi

2 years ago

Hi, You can use GXDateTime…

Hi,

You can use GXDateTime.ToHex method for that.

BR,
Mikko

Mahaveer

2 years ago

Thanks a lot Kurumi for your…

Thanks a lot Kurumi for your quick response.
I tried your given code and it's working as I was expecting.

  • Create new account
  • Reset your password

Hire Us!

Latest Releases

  • Mon, 07/27/2026 - 12:37
    gurux.dlms.cpp 9.0.2607.2701
  • Thu, 07/23/2026 - 16:19
    gurux.dlms.java 4.0.96
  • Thu, 07/09/2026 - 14:34
    Gurux.DLMS.Python 1.0.201
  • Fri, 06/26/2026 - 16:32
    Gurux.Service 3.0.2606.2601
  • Wed, 06/24/2026 - 08:36
    Gurux.DLMS.Python 1.0.200

New forum topics

  • Service not known error on gprs communication
  • Help Needed: Interfacing Saral 100 Energy Meter with Microcontroller via RS232
  • Connecting Meter to Agent via serial
  • Reading block profile with Compact array
  • DLMS server - serving multiple similar datasets gathered from multiple meters across distinct logical addresses
More
RSS feed
Privacy FAQ GXDN Issues Contact
Follow Gurux on Twitter Follow Gurux on Linkedin