X-Git-Url: http://git.zerfleddert.de/cgi-bin/gitweb.cgi/hmcfgusb/blobdiff_plain/d5cdafda04202a4a6e2793ab250d1fecf7ad9bcf..0edcd7f291b728aee5e0c99434d2d8d9d81f6af6:/flash-ota.c diff --git a/flash-ota.c b/flash-ota.c index 2b6e75e..fdd5936 100644 --- a/flash-ota.c +++ b/flash-ota.c @@ -207,7 +207,7 @@ int send_hm_message(struct ota_dev *dev, struct recv_data *rdata, uint8_t *msg) break; case DEVICE_TYPE_CULFW: { - char buf[128]; + char buf[256]; int i; memset(buf, 0, sizeof(buf)); @@ -227,14 +227,14 @@ int send_hm_message(struct ota_dev *dev, struct recv_data *rdata, uint8_t *msg) } if (msg[CTL] & 0x20) { - int cnt = 10; + int cnt = 3; int pfd; do { errno = 0; pfd = culfw_poll(dev->culfw, 1); if ((pfd < 0) && errno) { if (errno != ETIMEDOUT) { - perror("\n\nhmcfgusb_poll"); + perror("\n\nculfw_poll"); exit(EXIT_FAILURE); } } @@ -242,6 +242,11 @@ int send_hm_message(struct ota_dev *dev, struct recv_data *rdata, uint8_t *msg) break; } } while(cnt--); + + if (cnt == -1) { + fprintf(stderr, "\nMissing ACK!\n"); + return 0; + } } } break; @@ -445,8 +450,8 @@ int main(int argc, char **argv) printf("Waiting for device with serial %s\n", serial); while (1) { + errno = 0; switch (dev.type) { - errno = 0; case DEVICE_TYPE_CULFW: pfd = culfw_poll(dev.culfw, 1); break; @@ -654,7 +659,7 @@ int main(int argc, char **argv) } if ((pfd < 0) && errno) { if (errno != ETIMEDOUT) { - perror("\n\nhmcfgusb_poll"); + perror("\n\npoll"); exit(EXIT_FAILURE); } }