SDM120C icon indicating copy to clipboard operation
SDM120C copied to clipboard

-m output with different ID

Open jeanmarc77 opened this issue 9 years ago • 9 comments

Hello,

Is it possible to have different IDs for import/export/total meters with the -m output ? (like IMP, EXP, TOT) The data could eventually mess-up since each meters should have a unique ID.

Thanks

jeanmarc77 avatar Dec 12 '15 05:12 jeanmarc77

Hi jeanmarc, please try my fork version (not yet merged in main from gianfrdp), it already includes this feature.

https://github.com/The-Drake/SDM120C

The-Drake avatar Dec 12 '15 08:12 The-Drake

Hi Drake,

Thanks for your reply. I had trouble to compile your version.

I have like gianfrdp version to add into the make file. export PKG_CONFIG_PATH=/usr/lib/pkgconfig:/usr/local/lib/pkgconfig export LD_LIBRARY_PATH=/lib:/usr/lib:/usr/local/lib

[root@i3 SDM120Cdrk]# make gcc -c -o sdm120c.o sdm120c.c -O2 -Wall -g pkg-config --cflags libmodbus sdm120c.c: Dans la fonction ‘tv_diff’: sdm120c.c:188:5: attention : implicit declaration of function ‘timersub’ [-Wimplicit-function-declaration] timersub(t1, t2, &res); ^ sdm120c.c: Dans la fonction ‘getCurTime’: sdm120c.c:212:28: erreur: storage size of ‘tz’ isn’t known static struct timezone tz; ^ sdm120c.c:217:5: attention : implicit declaration of function ‘gettimeofday’ [-Wimplicit-function-declaration] gettimeofday(&_t, &tz); ^ sdm120c.c:212:28: attention : unused variable ‘tz’ [-Wunused-variable] static struct timezone tz; ^ sdm120c.c: Dans la fonction ‘main’: sdm120c.c:1271:37: attention : format ‘%lu’ expects argument of type ‘long unsigned int’, but argument 4 has type ‘uint32_t {alias unsigned int}’ [-Wformat=] fprintf(stderr, "%s: -j Response timeout (%lu) out of range, 0-500.\n",programName,resp_timeout); ^ sdm120c.c:1278:37: attention : format ‘%lu’ expects argument of type ‘long unsigned int’, but argument 4 has type ‘uint32_t {alias unsigned int}’ [-Wformat=] fprintf(stderr, "%s: -y Byte timeout (%lu) out of range, 1-500.\n",programName,byte_timeout); ^ Makefile:9 : la recette pour la cible « sdm120c.o » a échouée make: *** [sdm120c.o] Erreur 1

On Sat, Dec 12, 2015 at 9:03 AM, The-Drake [email protected] wrote:

Hi jeanmarc, please try my fork version (not yet merged in main from gianfrdp), it already includes this feature.

https://github.com/The-Drake/SDM120C

— Reply to this email directly or view it on GitHub https://github.com/gianfrdp/SDM120C/issues/6#issuecomment-164124265.

jeanmarc77 avatar Dec 12 '15 08:12 jeanmarc77

Please try this fix in file sdm120c.c:

#include <sys/types.h> #include <sys/file.h> -#include <time.h> +#include <sys/time.h>

+#include <time.h> #include <stdlib.h> #include <stdio.h> #include <stdarg.h>

The-Drake avatar Dec 12 '15 09:12 The-Drake

Sorry but include what ? ;)

jeanmarc77 avatar Dec 12 '15 10:12 jeanmarc77

Ops, sorry... :)

 #include <sys/types.h>
 #include <sys/file.h>
-#include <time.h>
+#include <sys/time.h>

+#include <time.h>
 #include <stdlib.h>
 #include <stdio.h>
 #include <stdarg.h>

The-Drake avatar Dec 12 '15 10:12 The-Drake

Thanks, I had few warnings (see bellow) and i have to export LD_RUN_PATH=/usr/local/lib I am trying your version, so far it work ;)

[root@i3 SDM120Cdrk]# make gcc -c -o sdm120c.o sdm120c.c -O2 -Wall -g pkg-config --cflags libmodbus sdm120c.c: In function ‘main’: sdm120c.c:1273:37: warning: format ‘%lu’ expects argument of type ‘long unsigned int’, but argument 4 has type ‘uint32_t {aka unsigned int}’ [-Wformat=] fprintf(stderr, "%s: -j Response timeout (%lu) out of range, 0-500.\n",programName,resp_timeout); ^ sdm120c.c:1280:37: warning: format ‘%lu’ expects argument of type ‘long unsigned int’, but argument 4 has type ‘uint32_t {aka unsigned int}’ [-Wformat=] fprintf(stderr, "%s: -y Byte timeout (%lu) out of range, 1-500.\n",programName,byte_timeout); ^ gcc -o sdm120c sdm120c.o -O2 -Wall -g pkg-config --libs libmodbus chmod 4711 sdm120c [root@i3 SDM120Cdrk]# ./sdm120c ./sdm120c: error while loading shared libraries: libmodbus.so.5: cannot open shared object file: No such file or directory [root@i3 SDM120Cdrk]# export LD_RUN_PATH=/usr/local/lib [root@i3 SDM120Cdrk]# make make: 'sdm120c' is up to date. [root@i3 SDM120Cdrk]# [root@i3 SDM120Cdrk]# ./sdm120c ./sdm120c: error while loading shared libraries: libmodbus.so.5: cannot open shared object file: No such file or directory [root@i3 SDM120Cdrk]# make clean rm -f *.o sdm120c [root@i3 SDM120Cdrk]# [root@i3 SDM120Cdrk]# make gcc -c -o sdm120c.o sdm120c.c -O2 -Wall -g pkg-config --cflags libmodbus sdm120c.c: In function ‘main’: sdm120c.c:1273:37: warning: format ‘%lu’ expects argument of type ‘long unsigned int’, but argument 4 has type ‘uint32_t {aka unsigned int}’ [-Wformat=] fprintf(stderr, "%s: -j Response timeout (%lu) out of range, 0-500.\n",programName,resp_timeout); ^ sdm120c.c:1280:37: warning: format ‘%lu’ expects argument of type ‘long unsigned int’, but argument 4 has type ‘uint32_t {aka unsigned int}’ [-Wformat=] fprintf(stderr, "%s: -y Byte timeout (%lu) out of range, 1-500.\n",programName,byte_timeout); ^ gcc -o sdm120c sdm120c.o -O2 -Wall -g pkg-config --libs libmodbus chmod 4711 sdm120c [root@i3 SDM120Cdrk]#

On Sat, Dec 12, 2015 at 11:20 AM, The-Drake [email protected] wrote:

Ops, sorry... :)

#include <sys/types.h> #include <sys/file.h> -#include <time.h> +#include <sys/time.h>

+#include <time.h> #include <stdlib.h> #include <stdio.h> #include <stdarg.h>

— Reply to this email directly or view it on GitHub https://github.com/gianfrdp/SDM120C/issues/6#issuecomment-164136756.

jeanmarc77 avatar Dec 12 '15 12:12 jeanmarc77

Warnings should be fixed now. Please try v1.3.5.2.

The-Drake avatar Dec 12 '15 14:12 The-Drake

Perfect. thanks

[root@i3 SDM120Cdrk]# make gcc -c -o sdm120c.o sdm120c.c -O2 -Wall -g pkg-config --cflags libmodbus gcc -o sdm120c sdm120c.o -O2 -Wall -g pkg-config --libs libmodbus chmod 4711 sdm120c

jeanmarc77 avatar Dec 12 '15 15:12 jeanmarc77

Fixed with latest merge in this repo too.

The-Drake avatar Jan 24 '16 12:01 The-Drake