unix: don't use usb_hid_write from usb_hid_read for PING/PONG

pull/25/head
Pavol Rusnak 7 years ago
parent fea8d53b85
commit 3098dc8447
No known key found for this signature in database
GPG Key ID: 91F3B339B9A02A3D

@ -105,8 +105,10 @@ int usb_hid_read(uint8_t iface_num, uint8_t *buf, uint32_t len) {
slen = sl;
static const char *ping_req = "PINGPING";
static const char *ping_resp = "PONGPONG";
if (r == strlen(ping_req) && memcmp(ping_req, buf, strlen(ping_req)) == 0) {
ensure(usb_hid_write(0, (const uint8_t *)ping_resp, strlen(ping_resp)), "usb_hid_write");
if (r == strlen(ping_req) && 0 == memcmp(ping_req, buf, strlen(ping_req))) {
if (slen > 0) {
sendto(sock, ping_resp, strlen(ping_resp), MSG_DONTWAIT, (const struct sockaddr *)&si_other, slen);
}
return 0;
}
return r;

Loading…
Cancel
Save