52 int main(
int argc,
char *argv[]) {
56 char *usage =
"Usage: %1$s [-v] [-q] datfile\n"
57 "\t-v\tIncrease verbosity\n"
58 "\t-q\tDecrease verbosity\n"
64 while ((go = getopt(argc, argv,
"vq")) != -1) {
73 log_error(&state,
"Unknown option `-%c'", optopt);
79 if (argc - optind != 1) {
85 fprintf(stderr, usage, argv[0]);
89 FILE *nf = fopen(argv[optind],
"r");
92 log_error(&state,
"Unable to open input file \"%s\"", argv[optind]);
97 bool processing =
true;
102 while (processing || hw > 18) {
103 if (processing && (hw <
BUFSIZE)) {
104 ssize_t ret = fread(&(buf[hw]),
sizeof(uint8_t),
BUFSIZE - hw, nf);
106 log_error(&state,
"Unable to read data from input");
113 log_info(&state, 2,
"End of file reached");
120 log_info(&state, 2,
"%d=>%d: PGN %d, Priority %d", nm->
src, nm->
dst,
162 log_info(&state, 3,
"%zu bytes read, failed to decode message", end);
163 if (!processing && end == 0) {
176 if ((hw - end) > 0) {
177 memmove(buf, &(buf[end]), hw - end);
184 memset(&(buf[hw]), 0,
BUFSIZE - hw);
186 log_info(&state, 0,
"%d messages successfully read from file", count);
int main(int argc, char *argv[])
#define BUFSIZE
Allocated read buffer size.
void n2k_basic_print(const n2k_act_message *n)
Print basic PGN details to standard output.
void n2k_128267_print(const n2k_act_message *n)
Print PGN 128267 (Water depth) to standard output.
void n2k_129029_print(const n2k_act_message *n)
Print PGN 129029 (GNSS Position) to standard output.
void n2k_130311_print(const n2k_act_message *n)
Print PGN 130311 (Environmental data) to standard output.
void n2k_129026_print(const n2k_act_message *n)
Print PGN 129026 (Course and Speed) to standard output.
void n2k_129025_print(const n2k_act_message *n)
Print PGN 129025 (Device position) to standard output.
void n2k_130306_print(const n2k_act_message *n)
Print PGN 130306 (Wind speed and direction) to standard output.
void n2k_60928_print(const n2k_act_message *n)
Print PGN 60928 (Address claim) to standard output.
void n2k_127250_print(const n2k_act_message *n)
Print PGN 127250 (Vessel Heading) to standard output.
void n2k_127251_print(const n2k_act_message *n)
Print PGN 127251 (Rate of Turn) to standard output.
void n2k_127257_print(const n2k_act_message *n)
Print PGN 127257 (Device orientation) to standard output.
void n2k_129033_print(const n2k_act_message *n)
Print PGN 129033 (Date and Time) to standard output.
bool n2k_act_from_bytes(const uint8_t *in, const size_t len, n2k_act_message **msg, size_t *pos, bool debug)
Convert a series of recieved bytes from ACT gateway devices into a message representation.
void log_info(const program_state *s, const int level, const char *format,...)
Output formatted information message at a given level.
void log_error(const program_state *s, const char *format,...)
Output formatted error message.
uint8_t priority
N2K Message priority value.
uint32_t PGN
24 bit PGN identifier
uint8_t * data
Message payload.
uint8_t dst
Message destination.
uint8_t src
Message source.
Program state and logging information.
int verbose
Current log verbosity (console output)
bool started
Indicates startup completed.
#define GIT_VERSION_STRING
Git version description.