40 #define PGN_MAX 16777216
61 int main(
int argc,
char *argv[]) {
65 char *usage =
"Usage: %1$s datfile\n"
71 while ((go = getopt(argc, argv,
"")) != -1) {
74 log_error(&state,
"Unknown option `-%c'", optopt);
80 if (argc - optind != 1) {
86 fprintf(stderr, usage, argv[0]);
90 FILE *nf = fopen(argv[optind],
"r");
93 log_error(&state,
"Unable to open input file \"%s\"", argv[optind]);
98 bool processing =
true;
103 while (processing || hw > 18) {
104 if (processing && (hw <
BUFSIZE)) {
105 ssize_t ret = fread(&(buf[hw]),
sizeof(uint8_t),
BUFSIZE - hw, nf);
107 log_error(&state,
"Unable to read data from input");
114 log_info(&state, 2,
"End of file reached");
124 if (!processing && end == 0) {
137 if ((hw - end) > 0) {
138 memmove(buf, &(buf[end]), hw - end);
145 memset(&(buf[hw]), 0,
BUFSIZE - hw);
147 log_info(&state, 0,
"%d messages successfully read from file", count);
148 fprintf(stdout,
"\nPGN \tCount\n");
149 for (
int i = 0; i <
PGN_MAX; i++) {
int main(int argc, char *argv[])
#define PGN_MAX
Largest possible PGN value.
#define BUFSIZE
Allocated read buffer size.
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.
uint32_t PGN
24 bit PGN identifier
uint8_t * data
Message payload.
Program state and logging information.
int verbose
Current log verbosity (console output)
bool started
Indicates startup completed.
#define GIT_VERSION_STRING
Git version description.