jlama / powertagd

15 stars 7 forks source link

[Question] Cannot compile under Debian 12 #14

Closed m00str closed 10 months ago

m00str commented 10 months ago

Hey, i dont know if the issue is on my side, but i can't figure out how to compile either this repo or the other forked repos that have MQTT support of some sorts.

My plan is to run the powertagd directly on Proxmox, but i just cant compile it. The error is the following:

root@proxmox:~/powertagd/src# make cc -g -O1 -fno-omit-frame-pointer -Wall -Wno-unused-function -c -o ash.o ash.c In file included from ash.c:12: util.h:153:13: error: static declaration of ‘arc4random_buf’ follows non-static declaration 153 | static void arc4random_buf(void buf, size_t nbytes) | ^~~~~~ In file included from ash.c:5: /usr/include/stdlib.h:542:13: note: previous declaration of ‘arc4random_buf’ with type ‘void(void , size_t)’ {aka ‘void(void , long unsigned int)’} 542 | extern void arc4random_buf (void buf, size_t __size) | ^~~~~~ util.h:159:17: error: static declaration of ‘arc4random’ follows non-static declaration 159 | static uint32_t arc4random(void) | ^~~~~~ /usr/include/stdlib.h:538:19: note: previous declaration of ‘arc4random’ with type ‘uint32_t(void)’ {aka ‘unsigned int(void)’} 538 | extern __uint32_t arc4random (void) | ^~~~~~ make: *** [Makefile:38: ash.o] Error 1

I already tried to compile other forks but there are a lot of other references missing (cJSON or mosquitto on @SeanHood or @fdamm fork)

jlama commented 10 months ago

Looks like the arc4random functions were added in a recent glibc. As a workaround you can simply delete the 2 arc4random functions in src/util.h (starting at line 153).

m00str commented 10 months ago

Oh god i was struggling for so long... It immediately worked.

I'll try to comission my powertag and if that works, i'll get to relaying the information to my Home Assistant.

Thanks for the incredibly quick help!

m00str commented 10 months ago

Just to close this issue:

So thanks again :)

Just a quick question: since i couldn't build the other forks that seemed to tackle integrating the data into Home Assistant i'd probably stick to this repo. I'll try to use my already working influxdb for relaying the data. That meens i would need to also build the [powertag2influx.go] file, correct?

jlama commented 10 months ago

You're welcome.

InfluxDB support is now built-in, powertag2influx.go is not needed anymore. I probably need to update the README...

powertagd -d /dev/ttyACM0 -o influxdb --url http://192.168.1.1:8086 --org XXX --bucket XXX --token XXX
m00str commented 10 months ago

Awesome, the built in InfluxDB connection works like a charm. The values are inverted imo (drawing power returns negative values), the powertagctl command doesn't really do anything (it tries to set the direction to downstream every time and exits without an error) but that's honestly no big deal, I'll just invert it on the HA side. Thanks for the help and thanks for your work on this repo!

m00str commented 10 months ago

-

jlama commented 10 months ago

Yeah the toggling of power direction is not supported by all PowerTags. However, negative values for received current is correct.