X-Git-Url: http://developer.intra2net.com/git/?p=libftdi;a=blobdiff_plain;f=ftdipp%2Fftdi.cpp;h=167325a413452fc2d91ab4bff3049b0bc85d101f;hp=5e45dce3fd71a9f76d03c365ee25a5cc0507bd99;hb=b25d91651338fdf323bcfae5f66d47fec69819f7;hpb=2d790e377ad5f1c61b38436aa3d5a201c9184028 diff --git a/ftdipp/ftdi.cpp b/ftdipp/ftdi.cpp index 5e45dce..167325a 100644 --- a/ftdipp/ftdi.cpp +++ b/ftdipp/ftdi.cpp @@ -2,11 +2,11 @@ ftdi.cpp - C++ wraper for libftdi ------------------- begin : Mon Oct 13 2008 - copyright : (C) 2008 by Marek Vavruša + copyright : (C) 2008-2013 by Marek Vavruša / libftdi developers email : opensource@intra2net.com and marek@vavrusa.com ***************************************************************************/ /* -Copyright (C) 2008 by Marek Vavruša +Copyright (C) 2008-2013 by Marek Vavruša / libftdi developers The software in this package is distributed under the GNU General Public License version 2 (with a special exception described below). @@ -132,6 +132,7 @@ int Context::open(struct libusb_device *dev) int Context::close() { d->open = false; + d->dev = 0; return ftdi_usb_close(d->ftdi); } @@ -316,6 +317,11 @@ int Context::get_strings() int Context::get_strings_and_reopen() { + if ( d->dev == 0 ) + { + d->dev = libusb_get_device(d->ftdi->usb_dev); + } + // Get device strings (closes device) int ret=get_strings(); if (ret < 0) @@ -613,13 +619,10 @@ List::iterator List::erase(iterator beg, iterator end) return d->list.erase(beg, end); } -List* List::find_all(int vendor, int product) +List* List::find_all(Context &context, int vendor, int product) { struct ftdi_device_list* dlist = 0; - struct ftdi_context ftdi; - ftdi_init(&ftdi); - ftdi_usb_find_all(&ftdi, &dlist, vendor, product); - ftdi_deinit(&ftdi); + ftdi_usb_find_all(context.context(), &dlist, vendor, product); return new List(dlist); }