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. 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 8 months ago

Hi,

Hi,

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

BR,
Mikko

Bill

4 years 8 months ago

Hi Mikko:

Hi Mikko:

It still not work.

:com_method section2 failed. 12

Bill

Profile picture for user Kurumi

Kurumi

4 years 8 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 8 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 8 months ago

Hi,

Hi,

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

BR,
Mikko

Ferdinand

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