Skip to content

Commit

Permalink
res_smdr_whozz: Add more detailed error logging.
Browse files Browse the repository at this point in the history
Since initialization of the WHOZZ Calling? units can be finicky,
add more detailed error messages so the user has better visibility
into the actual issue, rather than just seeing a message that
the serial thread terminated.

Interestingly, as of now, it seems to be the case that the device
can be in a state where we cannot synchronize with it, but
establishing a serial connection using screen to the device works,
and then future attempts within res_smdr_whozz succeed normally.

While this hasn't been reconciled yet, the additional logging
should at least steer users in the right direction.
  • Loading branch information
InterLinked1 committed Jan 10, 2025
1 parent 447c8bc commit d460a51
Showing 1 changed file with 5 additions and 0 deletions.
5 changes: 5 additions & 0 deletions res/res_smdr_whozz.c
Original file line number Diff line number Diff line change
Expand Up @@ -178,6 +178,7 @@ static int unloading = 0;
#define SERIAL_READ_STRING(buf, siz, pollfirst) { \
bufres = serial_getline(pfd, pollfirst, buf, siz); \
if (bufres <= 0) { \
ast_log(LOG_WARNING, "Failed to read string from serial port\n"); \
return -1; \
} \
/* These can end in CR, but since we have a LF after, it's okay */ \
Expand Down Expand Up @@ -216,6 +217,7 @@ static const char *state_str_func(enum line_state state)

static int serial_getline(struct pollfd *pfd, int pollfirst, char *restrict buf, size_t len)
{
const char *bufstart = buf;
size_t total = 0;
for (;;) {
ssize_t bufres = 1;
Expand Down Expand Up @@ -248,6 +250,7 @@ static int serial_getline(struct pollfd *pfd, int pollfirst, char *restrict buf,
buf += bufres;
len -= bufres;
if (len <= 0) {
ast_log(LOG_ERROR, "Buffer exhausted before complete line could be read? (read so far: '%s')\n", bufstart);
return -1;
}
}
Expand Down Expand Up @@ -883,11 +886,13 @@ static int serial_monitor(void *varg)
}
} while (!unloading && serial_sync(&pfd));
if (unloading) {
ast_debug(3, "Unload requested before initialization could complete\n");
return -1;
}
}

if (set_settings(&pfd)) {
ast_log(LOG_ERROR, "Failed to initialize device with SMDR settings\n");
return -1;
}

Expand Down

0 comments on commit d460a51

Please sign in to comment.