add separate influxdb test and usb test modes
This commit is contained in:
parent
4e7ae2bb25
commit
26c3dda8ea
25
howard.c
25
howard.c
|
@ -311,37 +311,44 @@ int main(int argc, char *argv[]) {
|
|||
char retbuf[BUFLEN];
|
||||
int res;
|
||||
int i;
|
||||
enum mode_enum { M_PROBE, M_TEST } mode = M_PROBE;
|
||||
enum mode_enum { M_PROBE, M_TEST, M_TESTDB } mode = M_PROBE;
|
||||
hid_device *dev = NULL;
|
||||
|
||||
// handle args
|
||||
for (i=1; i<argc;i++) {
|
||||
if (!strcmp(argv[i], "-t")) {
|
||||
if (!strcmp(argv[i], "-T")) {
|
||||
mode = M_TESTDB;
|
||||
} else if (!strcmp(argv[i], "-t")) {
|
||||
mode = M_TEST;
|
||||
}
|
||||
}
|
||||
influx_init("gridbug.nethack.net", "haven", "", "");
|
||||
|
||||
if (mode == M_TEST) {
|
||||
if (mode == M_TESTDB) {
|
||||
printf("running ping...\n");
|
||||
influx_ping(retbuf);
|
||||
}
|
||||
exit(1);
|
||||
}
|
||||
|
||||
if (hid_init()) {
|
||||
perror("hid_init()");
|
||||
err("Failed to initialise hidapi.");
|
||||
exit(1);
|
||||
}
|
||||
dev = hid_open(MIC_VID, MIC_PID, NULL);
|
||||
|
||||
if (mode == M_TEST) {
|
||||
if (dev) {
|
||||
info("Found Benestar USB sound meter (vendor 0x%04hx, product 0x%04hx).", MIC_VID, MIC_PID);
|
||||
exit(0);
|
||||
}
|
||||
}
|
||||
|
||||
if (!dev) {
|
||||
err("Benestar USB sound meter not found (vendor 0x%04hx, product 0x%04hx).", MIC_VID, MIC_PID);
|
||||
exit(1);
|
||||
}
|
||||
|
||||
if (mode == M_TEST) {
|
||||
info("Found Benestar USB sound meter (vendor 0x%04hx, product 0x%04hx).", MIC_VID, MIC_PID);
|
||||
exit(0);
|
||||
}
|
||||
|
||||
// get current reading
|
||||
res = hid_write(dev, capture_cmd, 9);
|
||||
|
||||
|
|
Loading…
Reference in New Issue