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

5 years 1 month ago

Hi,

Hi,

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

BR,
Mikko

Bill

5 years 1 month ago

Hi Mikko:

Hi Mikko:

It still not work.

:com_method section2 failed. 12

Bill

Profile picture for user Kurumi

Kurumi

5 years 1 month 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

5 years 1 month 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

5 years 1 month ago

Hi,

Hi,

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

BR,
Mikko

Ferdinand

4 years 12 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 12 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

  • Tue, 10/13/2026 - 12:00
    gurux.dlms.java 4.0.97
  • Tue, 09/22/2026 - 14:02
    Gurux.DLMS.Net 9.0.2609.2201
  • Mon, 09/21/2026 - 10:18
    Gurux.DLMS.Net 9.0.2609.2101
  • Wed, 08/26/2026 - 09:04
    Gurux.DLMS.Python 1.0.203
  • Mon, 08/17/2026 - 11:28
    Gurux.DLMS.Python 1.0.202

New forum topics

  • GXObisValueItem entries without MaskSize appear to be interpreted as bit flags
  • CheckedListBox incorrectly selects GXObisValueItem Value=0 for non-zero values
  • UIValueType=TextBox is rendered as CheckedListBox when Values are defined
  • Displaying mapped UInt8 values as read-only text in GXDLMSDirector
  • Python example can't read date from meter using WRAPPER connection
More

Who's new

  • MiguelC
  • Hichem Nasraoui
  • Matt_Plumer
  • King Won
  • APFC TEAM1
RSS feed
Privacy FAQ GXDN Issues Contact
Follow Gurux on Twitter Follow Gurux on Linkedin