Submitted by: kautism
patch #9893: [PATCH] Reader reads ftdi handle after main thread close it * ft245r.c: Wait until reader thread has been stopped before closing FTDI git-svn-id: svn://svn.savannah.nongnu.org/avrdude/trunk/avrdude@1434 81a1dc3b-b13d-400b-aceb-764788c761c2
This commit is contained in:
parent
ae24d7a284
commit
c34fb88844
|
@ -1,3 +1,9 @@
|
||||||
|
2020-03-11 Joerg Wunsch <j.gnu@uriah.heep.sax.de>
|
||||||
|
|
||||||
|
Submitted by: kautism
|
||||||
|
patch #9893: [PATCH] Reader reads ftdi handle after main thread close it
|
||||||
|
* ft245r.c: Wait until reader thread has been stopped before closing FTDI
|
||||||
|
|
||||||
2020-03-11 Joerg Wunsch <j.gnu@uriah.heep.sax.de>
|
2020-03-11 Joerg Wunsch <j.gnu@uriah.heep.sax.de>
|
||||||
|
|
||||||
Fix compiler warnings
|
Fix compiler warnings
|
||||||
|
|
1
NEWS
1
NEWS
|
@ -68,6 +68,7 @@ Current:
|
||||||
patch #8444: Proposal for modifications in -B and -U command options managment (partially)
|
patch #8444: Proposal for modifications in -B and -U command options managment (partially)
|
||||||
patch #9735: spelling error fix: psuedo -> pseudo
|
patch #9735: spelling error fix: psuedo -> pseudo
|
||||||
patch #9728: Fix UsbTiny programmer
|
patch #9728: Fix UsbTiny programmer
|
||||||
|
patch #9893: [PATCH] Reader reads ftdi handle after main thread close it
|
||||||
|
|
||||||
* Internals:
|
* Internals:
|
||||||
- New avrdude.conf keyword "family_id", used to verify SIB attributes
|
- New avrdude.conf keyword "family_id", used to verify SIB attributes
|
||||||
|
|
12
ft245r.c
12
ft245r.c
|
@ -681,14 +681,22 @@ cleanup_no_usb:
|
||||||
|
|
||||||
|
|
||||||
static void ft245r_close(PROGRAMMER * pgm) {
|
static void ft245r_close(PROGRAMMER * pgm) {
|
||||||
|
int retry_times = 0;
|
||||||
if (handle) {
|
if (handle) {
|
||||||
// I think the switch to BB mode and back flushes the buffer.
|
// I think the switch to BB mode and back flushes the buffer.
|
||||||
ftdi_set_bitmode(handle, 0, BITMODE_SYNCBB); // set Synchronous BitBang, all in puts
|
ftdi_set_bitmode(handle, 0, BITMODE_SYNCBB); // set Synchronous BitBang, all in puts
|
||||||
ftdi_set_bitmode(handle, 0, BITMODE_RESET); // disable Synchronous BitBang
|
ftdi_set_bitmode(handle, 0, BITMODE_RESET); // disable Synchronous BitBang
|
||||||
ftdi_usb_close(handle);
|
ftdi_usb_close(handle);
|
||||||
ftdi_deinit (handle);
|
while(pthread_cancel(readerthread) && retry_times < 100) {
|
||||||
pthread_cancel(readerthread);
|
retry_times++;
|
||||||
|
usleep(100);
|
||||||
|
}
|
||||||
|
if (retry_times >= 100) {
|
||||||
|
avrdude_message(MSG_INFO, "Too many retry to close reader thread\n");
|
||||||
|
}
|
||||||
|
|
||||||
pthread_join(readerthread, NULL);
|
pthread_join(readerthread, NULL);
|
||||||
|
ftdi_deinit (handle);
|
||||||
free(handle);
|
free(handle);
|
||||||
handle = NULL;
|
handle = NULL;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue