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. Not Able To Read One Byte Data, If Terminator Is 0x03

Not able to read one byte data, if terminator is 0x03

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 erdeepakcs , 9 March, 2017
Forums
Gurux.Serial

Hello sir,

i am trying to read one byte of data which is 0x03, i have assign terminator for received parameter is 0x03.

Gurux.Common.ReceiveParameters<byte[]> p = new ReceiveParameters<byte[]>
{
Eop = 0x03,
WaitTime =2000,
};

Profile picture for user Kurumi

Kurumi

9 years 3 months ago

Not able to read one byte data, if terminator is 0x03

Hi,

Try this.
Eop = (byte)0x03,

In default values are Int32 in C#.

BR,

Mikko

erdeepakcs

9 years 3 months ago

In reply to Not able to read one byte data, if terminator is 0x03 by Kurumi

hello sir

actually i have made a function for receiving the data. I forget to mention that i am using Eop=(byte)0x03 by passing it into the method. I am using Gurux.Common.dll and Gurux.Serial.dll
Below the code for receiving function.

public byte[] ReadDataPacket(byte[] data, int tryCount, byte eop)
{
if (data == null)
{
return null;
}
int pos = 0;
bool succeeded = false;
Gurux.Common.ReceiveParameters<byte[]> p = new ReceiveParameters<byte[]>
{
Eop = eop,
WaitTime =2000,
};
lock (Form1.gxSerial1.Synchronous)
{
if (data != null)
{
Form1.gxSerial1.Send(data);
}
System.Threading.Thread.Sleep(100);
while (!succeeded && pos != 3)
{
succeeded = Form1.gxSerial1.Receive(p);
if (!succeeded)
{
//Try to read again...
if (++pos != tryCount)
{
//If Eop is not set read one byte at time.
if (p.Eop == null)
{
p.Count = 1;
}
System.Diagnostics.Debug.WriteLine("Data send failed. Try to resend " + pos.ToString() + "/3");
Form1.gxSerial1.Send(data);
continue;
}
string err = "Failed to receive reply from the device in given time.";
throw new Exception(err);
}
}

}
return p.Reply;
}

Profile picture for user Kurumi

Kurumi

9 years 3 months ago

Not able to read one byte data, if terminator is 0x03

Hi,

Are you sure that your meter is sending 0x03?
Do you try to read IEC meter?

BR,

Mikko

erdeepakcs

9 years 3 months ago

In reply to Not able to read one byte data, if terminator is 0x03 by Kurumi

hi sir

yes, meter is sending 0x03, It is a NON-DLMS.

Profile picture for user Kurumi

Kurumi

9 years 3 months ago

Not able to read one byte data, if terminator is 0x03

Hi,

We made a test and it's working without problems.
We was using IEC 62056-21 (AKA 61107) meter that sends 0x3 as end char.

Make sure that your wait time is enough and meter is sending 0x3.

BR,

Mikko

erdeepakcs

9 years 3 months ago

In reply to Not able to read one byte data, if terminator is 0x03 by Kurumi

hello sir

Thanks sir, issue is resolved for 1 byte, now i am able to read data which is 0x03.
But now i am facing a another issue when the terminator byte 0x03 occurs in the mid of data, then i didn't get the full data in output.

This is output data which i should get in the output
02 00 00 03 E7 EA 03

but i am getting output
02 00 00 03
last three byte has been left out due to 0x03 terminator byte occurs in mid of data.

How can i solve this issue if terminator byte occurs in the mid of data as data part.

Profile picture for user Kurumi

Kurumi

9 years 3 months ago

terminator in the middle of data packet

Hi,

You need to check is all data received. There is no way to check this because media component do not know message structure.

If there is more data left call, set count or eop and call Receive method again until all data is received.

BR,

Mikko

erdeepakcs

9 years 2 months ago

hi sir

Then i want to know that, how this thing is manage in DLMS, because 0x7E is terminator there, if 0x7E comes in the mid of data, how complete data comes at receiver end.

Profile picture for user Kurumi

Kurumi

9 years 2 months ago

terminator in the middle of data packet

Hi,

We are using GetData to parse received data. Method returns is packet fully received.

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