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. Arduino IDE Read TokenGateway Data

Arduino IDE read TokenGateway data

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 Bill , 23 September, 2021
Forums
DLMSDirector

Hello,

I use Gurux to get token gateway code and it works.

Now I`m trying to use Arduino IDE to get token data,but I got something error.
Here is my Arduino code:

gxTokenGateway objToken;
unsigned char token[20] = {0x31, 0x37, 0x36, 0x32, 0x32, 0x34, 0x34, 0x39, 0x37, 0x30, 0x36, 0x31, 0x31, 0x35, 0x30, 0x34, 0x39, 0x32, 0x35, 0x30};
gxByteBuffer bb;
BYTE_BUFFER_INIT(&bb);
if ((ret = bb_setUInt8(&bb, DLMS_DATA_TYPE_OCTET_STRING)) == 0 &&
(ret = hlp_setObjectCount(sizeof(token), &bb)) == 0 &&
(ret = bb_set(&bb, token, sizeof(token))) == 0)
{
}
dlmsVARIANT params;
var_init(&params);
var_setInt8(&params, 0);
var_addOctetString(&params, &bb);
var_addBytes(&params, token, sizeof(token));
cosem_init(BASE(objToken), DLMS_OBJECT_TYPE_TOKEN_GATEWAY, "0.0.19.40.0.255");
com_method(BASE(objToken), 1, &params);
data = bb_toHexString(&objToken.token);
obj_toString(BASE(objToken), &data);
GXTRACE(PSTR("Ori token : "), data);
obj_clear(BASE(objToken));
free(data);

Response:

:com_method section2 failed. 12
:Ori token : Index: 2 Value:

What`s wrong with my code?
My Arduino IC specification is Mega2560

Bill

Image
Profile picture for user Kurumi

Kurumi

4 years 12 months ago

Hi,

Hi,

Try to remove this line:
var_setInt8(&params, 0);

BR,
Mikko

Bill

4 years 11 months ago

Hi Mikko:

Hi Mikko:

It still not work.

:com_method section2 failed. 12

Bill

Profile picture for user Kurumi

Kurumi

4 years 11 months ago

Hi,

Hi,

Your code looks correct. Can you get a trace from the bytes send so I can check what might be the problem?

BR,
Mikko

Bill

4 years 11 months ago

Hi Mikko:

Hi Mikko:

I sent an email to you.
Please help me to check my collected data.

Bill

Profile picture for user Kurumi

Kurumi

4 years 11 months ago

Hi,

Hi,

I was not receiving it. Can you share it on textbin.net?

BR,
Mikko

Ferdinand

4 years 10 months ago

Hi Mikko,

Hi Mikko,

I also have the same problem with Bill.
Can you help me with this problem ?

Ferdinand

Profile picture for user Kurumi

Kurumi

4 years 10 months ago

Hi Ferdinand,

Hi Ferdinand,

Can you create a new topic and share sent bytes, so I can check what is the problem.

BR,
Mikko

  • Create new account
  • Reset your password

Hire Us!

Latest Releases

  • Wed, 08/26/2026 - 09:04
    Gurux.DLMS.Python 1.0.203
  • Mon, 08/17/2026 - 11:28
    Gurux.DLMS.Python 1.0.202
  • Mon, 08/17/2026 - 09:47
    gurux.dlms.cpp 9.0.2608.1701
  • Mon, 08/17/2026 - 09:25
    gurux.dlms.c 9.0.2608.1701
  • Mon, 07/27/2026 - 12:37
    gurux.dlms.cpp 9.0.2607.2701

New forum topics

  • Security vulnerability report — request for a private contact (GuruxDLMS.c / ANSI C)
  • Topic: Insufficient Memory Error When Reading Class 7 Profile Generic Objects
  • SN ReadResponse returns all-null values when response spans multiple HDLC frames
  • Gurux.Serial.Android 3.0.6 – CH340 (HL-340) USB-Serial Adapter Not Working,
  • Trying to talk to a L&G E360 meter (Using Python Gurux)
More

Who's new

  • Anaglyfos Trading CC
  • cyby
  • Metin Onan
  • ssv007
  • 3nzol3dur
RSS feed
Privacy FAQ GXDN Issues Contact
Follow Gurux on Twitter Follow Gurux on Linkedin