2020-09-10 01:44:10 -04:00
|
|
|
#include <stdio.h>
|
|
|
|
#include <stdlib.h>
|
|
|
|
#include <string.h>
|
|
|
|
|
2020-09-14 23:24:11 -05:00
|
|
|
#include <patty/ax25.h>
|
2020-09-10 01:44:10 -04:00
|
|
|
#include <patty/bin/kiss.h>
|
|
|
|
|
2020-09-13 16:56:10 -04:00
|
|
|
int patty_bin_kiss_config(int argc,
|
|
|
|
char **argv,
|
|
|
|
patty_kiss_tnc_info *info,
|
|
|
|
patty_error *e) {
|
2020-09-10 01:44:10 -04:00
|
|
|
int i;
|
|
|
|
|
2020-09-13 16:56:10 -04:00
|
|
|
memset(info, '\0', sizeof(*info));
|
2020-09-10 01:44:10 -04:00
|
|
|
|
|
|
|
info->flags |= PATTY_KISS_TNC_DEVICE;
|
|
|
|
info->device = argv[0];
|
|
|
|
|
|
|
|
for (i=1; i<argc; i++) {
|
|
|
|
if (strcmp(argv[i], "crtscts") == 0) {
|
|
|
|
info->flags |= PATTY_KISS_TNC_FLOW;
|
|
|
|
info->flow = PATTY_KISS_TNC_FLOW_CRTSCTS;
|
|
|
|
} else if (strcmp(argv[i], "xonxoff") == 0) {
|
|
|
|
info->flags |= PATTY_KISS_TNC_FLOW;
|
|
|
|
info->flow = PATTY_KISS_TNC_FLOW_XONXOFF;
|
|
|
|
} else if (argv[i][0] >= '0' && argv[i][0] <= '9') {
|
|
|
|
info->flags |= PATTY_KISS_TNC_BAUD;
|
2021-02-21 19:50:52 -05:00
|
|
|
info->baud = atoi(argv[i]);
|
2020-09-10 01:44:10 -04:00
|
|
|
} else {
|
2020-09-13 16:56:10 -04:00
|
|
|
patty_error_fmt(e, "Invalid KISS TNC device parameter '%s'",
|
|
|
|
argv[i]);
|
2020-09-10 01:44:10 -04:00
|
|
|
|
|
|
|
goto error_invalid_device_setting;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
|
|
|
|
error_invalid_device_setting:
|
|
|
|
return -1;
|
|
|
|
}
|