Skip to content

Commit d460a51

Browse files
committed
res_smdr_whozz: Add more detailed error logging.
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.
1 parent 447c8bc commit d460a51

File tree

1 file changed

+5
-0
lines changed

1 file changed

+5
-0
lines changed

res/res_smdr_whozz.c

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -178,6 +178,7 @@ static int unloading = 0;
178178
#define SERIAL_READ_STRING(buf, siz, pollfirst) { \
179179
bufres = serial_getline(pfd, pollfirst, buf, siz); \
180180
if (bufres <= 0) { \
181+
ast_log(LOG_WARNING, "Failed to read string from serial port\n"); \
181182
return -1; \
182183
} \
183184
/* These can end in CR, but since we have a LF after, it's okay */ \
@@ -216,6 +217,7 @@ static const char *state_str_func(enum line_state state)
216217

217218
static int serial_getline(struct pollfd *pfd, int pollfirst, char *restrict buf, size_t len)
218219
{
220+
const char *bufstart = buf;
219221
size_t total = 0;
220222
for (;;) {
221223
ssize_t bufres = 1;
@@ -248,6 +250,7 @@ static int serial_getline(struct pollfd *pfd, int pollfirst, char *restrict buf,
248250
buf += bufres;
249251
len -= bufres;
250252
if (len <= 0) {
253+
ast_log(LOG_ERROR, "Buffer exhausted before complete line could be read? (read so far: '%s')\n", bufstart);
251254
return -1;
252255
}
253256
}
@@ -883,11 +886,13 @@ static int serial_monitor(void *varg)
883886
}
884887
} while (!unloading && serial_sync(&pfd));
885888
if (unloading) {
889+
ast_debug(3, "Unload requested before initialization could complete\n");
886890
return -1;
887891
}
888892
}
889893

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

0 commit comments

Comments
 (0)