summaryrefslogtreecommitdiff
path: root/heartbeatclient.c
diff options
context:
space:
mode:
Diffstat (limited to 'heartbeatclient.c')
-rw-r--r--heartbeatclient.c30
1 files changed, 15 insertions, 15 deletions
diff --git a/heartbeatclient.c b/heartbeatclient.c
index e3b9e8e..162660b 100644
--- a/heartbeatclient.c
+++ b/heartbeatclient.c
@@ -71,9 +71,9 @@ int process_serial(read_buffer_t* buffer, int serial_fd, u_int32_t* time, int le
if(buffer->offset > 0 && buffer->buf[buffer->offset-1] == '\r')
buffer->buf[buffer->offset-1] = 0;
- if(strlen(buffer->buf)) {
+ if(strlen((char *)(buffer->buf))) {
log_printf(INFO, "heartbeat: '%s'", buffer->buf);
- *time = 0;
+ *time = 0;
if(led_pipe_fd >= 0) {
char buf = '1';
ret = write(led_pipe_fd, &buf, 1);
@@ -81,7 +81,7 @@ int process_serial(read_buffer_t* buffer, int serial_fd, u_int32_t* time, int le
log_printf(WARNING, "write to led process pipe returned with error: %s", strerror(errno));
}
}
-
+
buffer->offset = 0;
return 0;
}
@@ -160,7 +160,7 @@ int main_loop(int serial_fd, int cmd_fd, int led_pipe_fd, options_t* opt)
if(FD_ISSET(sig_fd, &tmpfds))
if(signal_handle())
return_value = 1;
-
+
if(reset_flag) {
active = 1;
time = 0;
@@ -205,14 +205,14 @@ int led_process(int pipe_fd, int led_fd)
log_printf(ERROR, "led_process: read returned with error: %s", strerror(errno));
break;
}
-
+
buf = '1';
ret = write(led_fd, &buf, 1);
if(ret == -1 && errno != EAGAIN) {
log_printf(ERROR, "led_process: write returned with error: %s", strerror(errno));
break;
}
-
+
timeout.tv_sec = 0;
timeout.tv_usec = 100000;
ret = select(0, NULL, NULL, NULL, &timeout);
@@ -220,7 +220,7 @@ int led_process(int pipe_fd, int led_fd)
log_printf(ERROR, "led_process: select returned with error: %s", strerror(errno));
break;
}
-
+
buf = '0';
ret = write(led_fd, &buf, 1);
if(ret == -1 && errno != EAGAIN) {
@@ -236,7 +236,7 @@ int start_led_process(options_t* opt)
int pipefd[2];
int led_fd;
pid_t cpid;
-
+
led_fd = open(opt->led_filename_, O_WRONLY);
if(led_fd < 0) {
log_printf(ERROR, "led_process: open() failed: %s", strerror(errno));
@@ -248,7 +248,7 @@ int start_led_process(options_t* opt)
close(led_fd);
return -2;
}
-
+
cpid = fork();
if (cpid == -1) {
log_printf(ERROR, "led_process: fork() failed: %s", strerror(errno));
@@ -257,7 +257,7 @@ int start_led_process(options_t* opt)
close(led_fd);
return -2;
}
-
+
if (cpid == 0) {
close(pipefd[1]);
return led_process(pipefd[0], led_fd);
@@ -306,7 +306,7 @@ int main(int argc, char* argv[])
case -4: fprintf(stderr, "this log target is only allowed once: '%s', exitting\n", tmp->string_); break;
default: fprintf(stderr, "syntax error near: '%s', exitting\n", tmp->string_); break;
}
-
+
options_clear(&opt);
log_close();
exit(ret);
@@ -384,7 +384,7 @@ int main(int argc, char* argv[])
cmd_fd = connect_command_socket(opt.command_sock_);
if(cmd_fd < 0)
ret = 3;
- else {
+ else {
serial_fd = open(opt.serial_dev_, O_RDWR | O_NOCTTY);
if(serial_fd < 0)
ret = 2;
@@ -395,14 +395,14 @@ int main(int argc, char* argv[])
else
ret = main_loop(serial_fd, cmd_fd, led_pipe_fd, &opt);
}
- }
+ }
if(ret == 2 || ret == 3) {
- if(ret == 2)
+ if(ret == 2)
log_printf(ERROR, "%s error, trying to reopen in 5 seconds..", opt.serial_dev_);
if(ret == 3)
log_printf(ERROR, "socket error, trying to reconnect in 5 seconds..");
-
+
if(cmd_fd > 0)
close(cmd_fd);
if(serial_fd > 0)