ina260-zmq-publisher/src/logger/main.c
2023-07-14 22:03:40 +02:00

38 lines
No EOL
759 B
C

// Weather update client
// Connects SUB socket to tcp://localhost:5556
// Collects weather updates and finds avg temp in zipcode
#include <zmq.h>
#include <assert.h>
#include <time.h>
#include <stdlib.h>
#include <string.h>
#include <libgen.h>
#include <unistd.h>
void start(char *power_path);
int main (int argc, char *argv [])
{
if(argc != 2){
printf("Usage: %s <sysfs-path>",argv[0]);
exit(1);
}
// Extract bus id and ina260 chip address
char busid[10];
char chipaddr[10];
char *base=basename(argv[1]);
sscanf(base,"%[^-]-%[^-]",busid,chipaddr);
start("/home/loic/out.txt");
return 0;
}
void start(char *power_path){
if (access(power_path, F_OK) != 0){
printf("Could not read %s\n",power_path);
exit(2);
}
}