Allow messages to have arbitrary offsets in the bxf parser in case we have lingering buffered data.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38
diff --git a/driver-bitfury.c b/driver-bitfury.c
index 93313ab..b26ec8a 100644
--- a/driver-bitfury.c
+++ b/driver-bitfury.c
@@ -399,6 +399,7 @@ static void *bxf_get_results(void *userdata)
bxf_update_work(bitfury, info);
while (likely(!bitfury->shutdown)) {
+ char *msg;
int err;
if (unlikely(bitfury->usbinfo.nodev))
@@ -413,14 +414,18 @@ static void *bxf_get_results(void *userdata)
if (!err)
continue;
- if (!strncmp(buf, "submit", 6))
- parse_bxf_submit(bitfury, info, buf);
- else if (!strncmp(buf, "temp", 4))
- parse_bxf_temp(bitfury, info, buf);
- else {
- applog(LOG_DEBUG, "%s %d: Unrecognised string %s",
- bitfury->drv->name, bitfury->device_id, buf);
+ msg = strstr(buf, "submit");
+ if (msg) {
+ parse_bxf_submit(bitfury, info, msg);
+ continue;
+ }
+ msg = strstr(buf, "temp");
+ if (msg) {
+ parse_bxf_temp(bitfury, info, msg);
+ continue;
}
+ applog(LOG_DEBUG, "%s %d: Unrecognised string %s",
+ bitfury->drv->name, bitfury->device_id, buf);
}
out:
return NULL;