+ DPRINTF("writing %zd bytes due to %d following reads in %d chunks or full buffer\n", writepos-writebuf, nread, num);
+ jtagkey_latency(BULK_LATENCY);
+
+ targ.num = writepos-pos;
+ targ.buf = readbuf;
+ pthread_create(&reader_thread, NULL, &jtagkey_reader, &targ);
+
+ while (pos < writepos) {
+ len = writepos-pos;
+
+ if (len > USBBUFSIZE)
+ len = USBBUFSIZE;
+
+ DPRINTF("combined write of %d/%zd\n",len,writepos-pos);
+ ftdi_write_data(&ftdic, pos, len);
+ pos += len;
+ }
+ pthread_join(reader_thread, NULL);