Hello there,
please could you help me with Gurux.DLMS.c on Arduino IDE? I already read all posts on this topic, used git (master) version, my Arduino IDE is 1.8.16. I'm trying to compile on ESP32, no way :-(
Board selected: ESP32 Dev Module, Library: esp32 1.0.6
sketch/sketch_oct30a.ino.cpp.o:(.literal._Z5setupv+0x8): undefined reference to `bb_Init'
sketch/sketch_oct30a.ino.cpp.o:(.literal._Z5setupv+0xc): undefined reference to `bb_capacity'
sketch/sketch_oct30a.ino.cpp.o: In function `setup()':
/home/andrea/Arduino/sketch_oct30a/sketch_oct30a.ino:7: undefined reference to `bb_Init'
/home/andrea/Arduino/sketch_oct30a/sketch_oct30a.ino:8: undefined reference to `bb_capacity'
libraries/GXDLMSClient/GXDLMSClient.cpp.o:(.literal._ZN12GXDLMSClient4initEbii19DLMS_AUTHENTICATIONPKc19DLMS_INTERFACE_TYPE+0x0): undefined reference to `cl_init'
libraries/GXDLMSClient/GXDLMSClient.cpp.o: In function `GXDLMSClient::init(bool, int, int, DLMS_AUTHENTICATION, char const*, DLMS_INTERFACE_TYPE)':
/home/andrea/Arduino/libraries/GXDLMSClient/GXDLMSClient.cpp:284: undefined reference to `cl_init'
collect2: error: ld returned 1 exit status
exit status 1
I created a folder with the GXDLMSClient client (in ~/Arduino/libraries/GXDLMSClient) with:
ArduinoIgnore.h
client.ino
GXDLMSClient.cpp
GXDLMSClient.h
include
src
Ah ok, just trying I think I understood. I managed to compile transferring all files into my sketch folder (I have to be honest, I don't like it very much...).
There are tons of warning like this:
In file included from /home/andrea/Arduino/sketch_oct30a/src/converters.c:57:0:
/home/andrea/Arduino/sketch_oct30a/src/converters.c: In function 'obj_typeToString2':
/home/andrea/Arduino/sketch_oct30a/include/helpers.h:61:32: warning: implicit declaration of function 'PSTR' [-Wimplicit-function-declaration]
#define GET_STR_FROM_EEPROM(x) PSTR(x)
^
/home/andrea/Arduino/sketch_oct30a/src/converters.c:107:15: note: in expansion of macro 'GET_STR_FROM_EEPROM'
ret = GET_STR_FROM_EEPROM("");
^
/home/andrea/Arduino/sketch_oct30a/src/converters.c:107:13: warning: assignment makes pointer from integer without a cast [-Wint-conversion]
ret = GET_STR_FROM_EEPROM("");
^
/home/andrea/Arduino/sketch_oct30a/src/converters.c:110:13: warning: assignment makes pointer from integer without a cast [-Wint-conversion]
ret = GET_STR_FROM_EEPROM("Data");
PS: I tried also to compile the example client.ino (renaming to GXDLMSClient.ino)
But it fails with:
sketch/src/converters.c.o:(.literal.obj_typeToString2+0x118): undefined reference to `PSTR'
sketch/src/converters.c.o: In function `obj_typeToString2':
/home/andrea/Arduino/GXDLMSClient/src/converters.c:2573: undefined reference to `PSTR'
sketch/src/converters.c.o: In function `obj_getUnitAsString':
/home/andrea/Arduino/GXDLMSClient/src/converters.c:2573: undefined reference to `PSTR'
/home/andrea/Arduino/GXDLMSClient/src/converters.c:2573: undefined reference to `PSTR'
sketch/src/date.c.o: In function `time_toString':
/home/andrea/Arduino/GXDLMSClient/src/date.c:751: undefined reference to `PSTR'
sketch/src/date.c.o:/home/andrea/Arduino/GXDLMSClient/src/date.c:751: more undefined references to `PSTR' follow
collect2: error: ld returned 1 exit status
exit status 1
I'm glad that you solved this. I'm interested in this pgmspace include error.
What additional Board Manager URS you are using?
Can you select "File" and "Preferences" and add your Board Manager URS here?
Hi Mikko,
luckily I'm not experiencing compilation or linking errors anymore. I succeed in connecting to the bridge (using the serial numer to obtain the HDLC server address, as I already do in python), I succeed in reading the association view... then, I cannot read registers or data or profile :-( Always "com_read failed. 3".
Note that using an USB serial adapter on my PC, with the same client parameters and serial parameters, I can read the meter (and L+G E650).
(if you prefer I can open another dedicated topic)
logicalReferencing is 0 cause L+G E650 will works only in SN mode.
In your example you don't call com_initializeConnection, You try to read objects without establishing the connection for the meter and it fails because of that. You must first connect to the meter before you can read anything.
Oh, ok. Actually I added it as from your example and I obtain SUCCEED, but I always receive ":com_read failed. 3" from com_read(). Might be it has something to do with associations, cause I'm using SN?
You are right. You need to set the short name for each object. Because short names might be anything, you need to read them for example with GXDLMSDirector, and then update the short name.
All meter manufacturers are moving from short name to logical name referencing because it's easier.
You don't read the association view to find out what is the short name.
Ok!!! Thank you again Mikko! I succeed to read the register! (rdn.base.shortName=40400)
The C++ version could be a solution to manage the readings with AV as in Python? (assuming that is possibile to compile it in Arduino IDE and assuming that it could works in ~350KB of remaining RAM...)
Just forgotten, but it's only
Just forgotten, but it's only a typo I think...
I had to change:
#include "include/gxObjects.h"
to
#include "include/gxobjects.h"
in GXDLMSClient.cpp and GXDLMSClient.h.
Ah ok, just trying I think I
Ah ok, just trying I think I understood. I managed to compile transferring all files into my sketch folder (I have to be honest, I don't like it very much...).
There are tons of warning like this:
In file included from /home/andrea/Arduino/sketch_oct30a/src/converters.c:57:0:
/home/andrea/Arduino/sketch_oct30a/src/converters.c: In function 'obj_typeToString2':
/home/andrea/Arduino/sketch_oct30a/include/helpers.h:61:32: warning: implicit declaration of function 'PSTR' [-Wimplicit-function-declaration]
#define GET_STR_FROM_EEPROM(x) PSTR(x)
^
/home/andrea/Arduino/sketch_oct30a/src/converters.c:107:15: note: in expansion of macro 'GET_STR_FROM_EEPROM'
ret = GET_STR_FROM_EEPROM("");
^
/home/andrea/Arduino/sketch_oct30a/src/converters.c:107:13: warning: assignment makes pointer from integer without a cast [-Wint-conversion]
ret = GET_STR_FROM_EEPROM("");
^
/home/andrea/Arduino/sketch_oct30a/src/converters.c:110:13: warning: assignment makes pointer from integer without a cast [-Wint-conversion]
ret = GET_STR_FROM_EEPROM("Data");
...I'll go ahead with my attempt... ;-)
PS: I tried also to compile
PS: I tried also to compile the example client.ino (renaming to GXDLMSClient.ino)
But it fails with:
sketch/src/converters.c.o:(.literal.obj_typeToString2+0x118): undefined reference to `PSTR'
sketch/src/converters.c.o: In function `obj_typeToString2':
/home/andrea/Arduino/GXDLMSClient/src/converters.c:2573: undefined reference to `PSTR'
sketch/src/converters.c.o: In function `obj_getUnitAsString':
/home/andrea/Arduino/GXDLMSClient/src/converters.c:2573: undefined reference to `PSTR'
/home/andrea/Arduino/GXDLMSClient/src/converters.c:2573: undefined reference to `PSTR'
sketch/src/date.c.o: In function `time_toString':
/home/andrea/Arduino/GXDLMSClient/src/date.c:751: undefined reference to `PSTR'
sketch/src/date.c.o:/home/andrea/Arduino/GXDLMSClient/src/date.c:751: more undefined references to `PSTR' follow
collect2: error: ld returned 1 exit status
exit status 1
Ok, managed to compile :-)
Ok, managed to compile :-)
Previosly I had to comment out:
#include <avr/pgmspace.h>
to avoid compilation errors. I simply replaced with:
#include <pgmspace.h>
and now also your example client can complile and link!
Hi Andrea,
Hi Andrea,
I'm glad that you solved this. I'm interested in this pgmspace include error.
What additional Board Manager URS you are using?
Can you select "File" and "Preferences" and add your Board Manager URS here?
BR,
Mikko
Hi,
Hi,
Thanks for pointing this out. This is fixed to the latest version.
BR,
Mikko
Hi Mikko,
Hi Mikko,
here is the boards I use:
arduino (AVR)
chipKIT
esp32
esp8266
STM32
Best regards,
Andrea
Hi,
Hi,
Can you add board URL here so we can test with the same board.
It's something like:
http://dan.drown.org/stm32duino/package_STM32duino_index.json
You can find if you select "File" and "Preferences".
BR,
Mikko
Hi Mikko,
Hi Mikko,
here is my Additional Board manager URLs:
https://dl.espressif.com/dl/package_esp32_index.json
https://arduino.esp8266.com/stable/package_esp8266com_index.json
https://raw.githubusercontent.com/stm32duino/BoardManagerFiles/master/S…
https://dan.drown.org/stm32duino/package_STM32duino_index.json
https://raw.githubusercontent.com/chipKIT32/chipKIT-core/master/package…
so I already have that url.
BR,
Andrea
Hi Andrea,
Hi Andrea,
Thank you for this info. I'll install the same packages and try if I can your error happened so we can fix the compile error.
BR,
Mikko
Hi Mikko,
Hi Mikko,
luckily I'm not experiencing compilation or linking errors anymore. I succeed in connecting to the bridge (using the serial numer to obtain the HDLC server address, as I already do in python), I succeed in reading the association view... then, I cannot read registers or data or profile :-( Always "com_read failed. 3".
Note that using an USB serial adapter on my PC, with the same client parameters and serial parameters, I can read the meter (and L+G E650).
(if you prefer I can open another dedicated topic)
logicalReferencing is 0 cause L+G E650 will works only in SN mode.
RS485Serial.begin(config.serialBaud, config.serialConfig, RS485RxPin, RS485TxPin);
(9600 8N1, readDLMSPacket and com_readSerialPort modified to use RS485Serial and DE/*RE pin)
BYTE_BUFFER_INIT(&frameData);
bb_capacity(&frameData, 128);
DLMSClient.init(logicalReferencing, 0x10, DLMSClient.GetServerAddress(1, (serialNumber % 10000 + 1000), 4), DLMS_AUTHENTICATION_NONE, NULL, DLMS_INTERFACE_TYPE_HDLC);
com_getAssociationView();
char *data = NULL;
gxData ldn;
cosem_init(BASE(ldn), DLMS_OBJECT_TYPE_DATA, "0.0.42.0.0.255");
ret = com_read(BASE(ldn), 2);
obj_toString(BASE(ldn), &data);
GXTRACE(GET_STR_FROM_EEPROM("Logical Device Name"), data);
obj_clear(BASE(ldn));
free(data);
gxClock clock1;
cosem_init(BASE(clock1), DLMS_OBJECT_TYPE_CLOCK, "0.0.1.0.0.255");
ret = com_read(BASE(clock1), 3);
ret = com_read(BASE(clock1), 2);
obj_toString(BASE(clock1), &data);
GXTRACE(GET_STR_FROM_EEPROM("Clock"), data);
obj_clear(BASE(clock1));
free(data);
gxRegister rdn;
cosem_init(BASE(rdn), DLMS_OBJECT_TYPE_REGISTER, "1.1.14.7.0.255");
com_read(BASE(rdn), 2);
obj_toString(BASE(rdn), &data);
GXTRACE(GET_STR_FROM_EEPROM("Freq"), data);
obj_clear(BASE(rdn));
free(data);
gxProfileGeneric pg;
cosem_init(BASE(pg), DLMS_OBJECT_TYPE_PROFILE_GENERIC,"0.0.99.98.0.255");
com_read(BASE(pg), 2);
obj_toString(BASE(pg), &data);
GXTRACE(GET_STR_FROM_EEPROM("Load profile"), data);
obj_clear(BASE(pg));
free(data);
14:47:58.140 -> rst:0x1 (POWERON_RESET),boot:0x17 (SPI_FAST_FLASH_BOOT)
14:47:58.140 -> configsip: 0, SPIWP:0xee
14:47:58.140 -> clk_drv:0x00,q_drv:0x00,d_drv:0x00,cs0_drv:0x00,hd_drv:0x00,wp_drv:0x00
14:47:58.140 -> mode:DIO, clock div:1
14:47:58.140 -> load:0x3fff0018,len:4
14:47:58.140 -> load:0x3fff001c,len:1216
14:47:58.140 -> ho 0 tail 12 room 4
14:47:58.140 -> load:0x40078000,len:10944
14:47:58.140 -> load:0x40080400,len:6388
14:47:58.140 -> entry 0x400806b4
14:47:58.372 -> RS485 BAUD: 9600
14:47:58.372 -> RS485 MODE: SERIAL_8N1
14:47:58.372 -> LAN MAC address: 24 6F 28 43 70 A7
14:47:58.902 -> LAN IP address: 10.1.1.254
14:47:58.935 -> 26702
14:47:58.935 -> TX 7E A0 0A 00 02 A0 9D 21 93 7C 49 7E
14:47:59.001 -> RX
14:47:59.001 -> TX 7E A0 2E 00 02 A0 9D 21 10 1A F3 E6 E6 00 60 1D A1 09 06 07 60 85 74 05 08 01 02 BE 10 04 0E 01 00 00 00 06 5F 1F 04 00 1C 03 20 FF FF 80 AB 7E
14:47:59.200 -> RX
======= // cutted off // ========
14:48:07.780 -> TX 7E A0 14 00 02 A0 9D 21 14 23 8A E6 E6 00 05 01 02 00 08 60 1F 7E
14:48:07.846 -> RX
14:48:07.846 -> :com_read failed. 3 :Logical Device NameIndex: 2 Value:
14:48:07.846 -> TX 7E A0 14 00 02 A0 9D 21 36 33 88 E6 E6 00 05 01 02 00 10 A9 83 7E
14:48:07.912 -> RX
14:48:07.912 -> :com_read failed. 3TX 7E A0 14 00 02 A0 9D 21 58 4B 02 E6 E6 00 05 01 02 00 08 60 1F 7E
14:48:08.012 -> RX
14:48:08.012 -> :com_read failed. 3 :ClockIndex: 2 Value: 01/01/1970 00:00:00 UTC+00:00
14:48:08.045 -> Index: 3 Value: 0
14:48:08.045 -> Index: 4 Value: 0
14:48:08.045 -> Index: 5 Value: 01/01/1970 00:00:00 UTC+00:00
14:48:08.045 -> Index: 6 Value: 01/01/1970 00:00:00 UTC+00:00
14:48:08.045 -> Index: 7 Value: 0
14:48:08.045 -> Index: 8 Value: 0
14:48:08.045 -> Index: 9 Value: 0
14:48:08.045 -> TX 7E A0 14 00 02 A0 9D 21 7A 5B 00 E6 E6 00 05 01 02 00 08 60 1F 7E
14:48:08.111 -> RX
14:48:08.111 -> :com_read failed. 3 :FreqIndex: 3 Value: Scaler: 1 Unit: Year
14:48:08.144 -> Index: 2 Value:
14:48:08.277 -> TX 7E A0 14 00 02 A0 9D 21 BE 73 80 E6 E6 00 05 01 02 00 08 60 1F 7E
14:48:08.343 -> RX
14:48:08.343 -> :com_read failed. 3 :Load profileIndex: 2 Value: [
14:48:08.376 -> ]
14:48:08.376 -> Index: 3 Value: []
14:48:08.376 -> Index: 4 Value: 0
14:48:08.376 -> Index: 5 Value: 0
14:48:08.376 -> Index: 6 Value:
14:48:08.376 -> Index: 7 Value: 0
14:48:08.376 -> Index: 8 Value: 0
14:48:08.376 -> TX 7E A0 0A 00 02 A0 9D 21 53 70 8F 7E
14:48:08.442 -> RX
Hi,
Hi,
In your example you don't call com_initializeConnection, You try to read objects without establishing the connection for the meter and it fails because of that. You must first connect to the meter before you can read anything.
BR,
Mikko
Oh, ok. Actually I obtained
Oh, ok. Actually I added it as from your example and I obtain SUCCEED, but I always receive ":com_read failed. 3" from com_read(). Might be it has something to do with associations, cause I'm using SN?
ret = com_initializeConnection();
if(ret != DLMS_ERROR_CODE_OK) {
GXTRACE_INT(GET_STR_FROM_EEPROM("com_initializeConnection failed"), ret);
return ret;
}
GXTRACE_INT(GET_STR_FROM_EEPROM("com_initializeConnection SUCCEEDED"), ret);
Hi,
Hi,
You are right. You need to set the short name for each object. Because short names might be anything, you need to read them for example with GXDLMSDirector, and then update the short name.
All meter manufacturers are moving from short name to logical name referencing because it's easier.
You don't read the association view to find out what is the short name.
BR,
Mikko
Hi,
Hi,
just tried with:
cosem_init(BASE(rdn), DLMS_OBJECT_TYPE_REGISTER, "40400");
com_read(BASE(rdn), 2);
obj_toString(BASE(rdn), &data);
GXTRACE(GET_STR_FROM_EEPROM("Freq"), data);
obj_clear(BASE(rdn));
...with the same results, "com_read failed. 3" :-(
Anyway it's so strange, in Python I can succesfully use:
obj = objs.findByLN(False, _GXCommon.toLogicalName('1.1.14.7.0.255'))
values = obj.getValues()
Just for completeness:
1.1.14.7.0.255 = 40400 it's the Frequency
and about objs:
list_ = list()
objs = self.client.objects.getObjects([ObjectType.DATA, ObjectType.CLOCK, ObjectType.REGISTER, ObjectType.EXTENDED_REGISTER, ObjectType.DEMAND_REGISTER])
for obj in objs:
list_.append((obj, 2))
ut = time.time()
self.readList(list_)
...
BR,
Andrea
Hi Andrea,
Hi Andrea,
Try like this:
cosem_init(BASE(rdn), DLMS_OBJECT_TYPE_REGISTER, "1.1.14.7.0.255");
rdn.shorName = 40400;
You read association view in python so short names are available. In C code you don't read the association view.
BR,
Mikko
BR,
Mikko
Ok!!! Thank you again Mikko!
Ok!!! Thank you again Mikko! I succeed to read the register! (rdn.base.shortName=40400)
The C++ version could be a solution to manage the readings with AV as in Python? (assuming that is possibile to compile it in Arduino IDE and assuming that it could works in ~350KB of remaining RAM...)
BR,
Andrea
Hi,
Hi,
ANSI C++ works in the same way. I don't believe that RAM is the problem. You can try with ANSI C if you can't fit app to the Flash.
Add define DLMS_IGNORE_XML_TRANSLATOR. It will ignore DLMS translator and I believe that you don't need it. You can use it to convert data to XML.
BR,
Mikko
please give me the code for…
please give me the code for esp32 and the libraries .
To interface with the L&T meter.
Hi, Please, create a new…
Hi,
Please, create a new topic if you have a new question. You can get the source code from here:
https://github.com/Gurux/GuruxDLMS.c/tree/master/Arduino_IDE
BR,
Mikko
Thanks
Thanks