gianfrdp / SDM120C

sdm120c ModBus Mini Smart Meter
GNU General Public License v2.0
73 stars 37 forks source link

-m output with different ID #6

Open jeanmarc77 opened 8 years ago

jeanmarc77 commented 8 years ago

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

The-Drake commented 8 years ago

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

jeanmarc77 commented 8 years ago

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 notifications@github.com 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.

The-Drake commented 8 years ago

Please try this fix in file sdm120c.c:

include <sys/types.h>

include <sys/file.h>

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

+#include

include

include

include

jeanmarc77 commented 8 years ago

Sorry but include what ? ;)

The-Drake commented 8 years ago

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>
jeanmarc77 commented 8 years ago

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 notifications@github.com wrote:

Ops, sorry... :)

include <sys/types.h>

include <sys/file.h>

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

+#include

include

include

include

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

The-Drake commented 8 years ago

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

jeanmarc77 commented 8 years ago

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

The-Drake commented 8 years ago

Fixed with latest merge in this repo too.