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 10 months ago

Hi,

Hi,

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

BR,
Mikko

Bill

4 years 10 months ago

Hi Mikko:

Hi Mikko:

It still not work.

:com_method section2 failed. 12

Bill

Profile picture for user Kurumi

Kurumi

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

Hi,

Hi,

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

BR,
Mikko

Ferdinand

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

  • 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
  • Mon, 06/15/2026 - 08:52
    gurux.dlms.c 9.0.2606.1501

New forum topics

  • Service not known error on gprs communication
  • 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
More

Who's new

  • ksFhuuipOxKrxk…
  • sherylrk3
  • OLaneHycle
  • LxfgLnoisbruoL…
  • SunbetLith
RSS feed
Privacy FAQ GXDN Issues Contact
Follow Gurux on Twitter Follow Gurux on Linkedin