Aruna
reporter.cpp
Go to the documentation of this file.
1 //
2 // Created by noeel on 15-04-20.
3 //
4 
5 #include "aruna/sis/reporter.h"
6 #include "aruna/comm.h"
7 #include "aruna/sis/watcher.h"
8 #include "aruna/log.h"
9 
10 using namespace aruna;
11 
12 namespace {
15 }
18 // TODO error check
19  log_channel = new log::channel_t("SIS report");
20  return comm_channel->register_err;
21 }
22 
24 // encode status
25  auto* buffer = static_cast<uint8_t *>(malloc(status->get_encode_size()));
26  status->encode(buffer);
27  err_t send_err = comm_channel->send(watcher::port, buffer, status->get_encode_size(), true);
28  if ((uint8_t) send_err)
29  log_channel->error("failed to send SIS report to watcher: %s", err_to_char.at(send_err));
30  free(buffer);
31 }
Definition: comm.cpp:14
const std::map< err_t, char * > err_to_char
Definition: arunaTypes.h:54
err_t start()
start reporter to report all SIS activiry to the watcher over comm channels
Definition: reporter.cpp:16
status_t status
stores the comm status
Definition: comm.cpp:40
virtual uint8_t get_encode_size()
Definition: sisTypes.h:45
err_t send(port_t to_port, uint8_t *data, size_t data_size, bool wait_for_ack=false)
Definition: comm.cpp:513
comm::channel_t * comm_channel
Definition: reporter.cpp:13
virtual void encode(uint8_t *buffer)
Definition: sisTypes.h:49
endpoint type of a comm channel
Definition: commTypes.h:150
int error(const char *format,...)
log error message
Definition: log.cpp:90
status that is to be reported to the watcher
Definition: sisTypes.h:36
void alert(status_t *status)
alert watcher with given status_t
Definition: reporter.cpp:23
static const comm::port_t port
Definition: reporter.h:15