diff options
Diffstat (limited to '')
-rw-r--r-- | modbuslog.c | 18 |
1 files changed, 9 insertions, 9 deletions
diff --git a/modbuslog.c b/modbuslog.c index d664c2f..db40244 100644 --- a/modbuslog.c +++ b/modbuslog.c @@ -69,7 +69,7 @@ char *mac_address() { int main(int argc, char *argv[]) { - const char *configfile = "modbuslog.cfg"; + const char *configfile = "/etc/modbuslog.cfg"; int DEBUG = 0; int k; @@ -212,7 +212,7 @@ int main(int argc, char *argv[]) { char filename[50]; - sprintf(filename, "%s_%04i_%02i_%02i_%02i_%02i_%02i.log", + sprintf(filename, "/var/modbuslog/%s_%04i_%02i_%02i_%02i_%02i_%02i.log", mac_address(), midnight.tm_year + 1900, midnight.tm_mon + 1, midnight.tm_mday, midnight.tm_hour, midnight.tm_min, midnight.tm_sec); @@ -233,7 +233,7 @@ int main(int argc, char *argv[]) { FILE *filehandle = fopen(filename, "a+"); - int registervalue = 0; + int16_t registervalue = 0; int p; for (p = 0; p < numregisters; p++) { @@ -261,18 +261,18 @@ int main(int argc, char *argv[]) { struct tm lc = *localtime(&unixtime_min); - int intervalvalue; - FILE *intervalfile = fopen("interval.txt", "w+"); - fscanf(intervalfile, "%d", &intervalvalue); - intervalvalue++; - fprintf(intervalfile, "%d", intervalvalue); + int intervalid; + FILE *intervalfile = fopen("/var/modbuslog/interval.txt", "w+"); + fscanf(intervalfile, "%d", &intervalid); + intervalid++; + fprintf(intervalfile, "%d", intervalid); fclose(intervalfile); fprintf( filehandle, "%i|%04i%02i%02i|%02i%02i%02i|%04i%02i%02i|%02i%02i%02i|%i|%i|%i\n", - intervalvalue,utc.tm_year + 1900, utc.tm_mon + 1, utc.tm_mday, + intervalid,utc.tm_year + 1900, utc.tm_mon + 1, utc.tm_mday, utc.tm_hour, utc.tm_min, utc.tm_sec, lc.tm_year + 1900, lc.tm_mon + 1, lc.tm_mday, lc.tm_hour, lc.tm_min, lc.tm_sec, slaveid, startaddress, registervalue); |