mirror of
https://github.com/f4exb/sdrangel.git
synced 2024-11-25 09:18:54 -05:00
Perseus: corrected startup sequence to restart full enumeration sequence if firmware is missing initially. Fixes cold start flawed init sequence
This commit is contained in:
parent
ee7c2cee0d
commit
6cbee2070f
@ -33,3 +33,21 @@ DevicePerseus& DevicePerseus::instance()
|
||||
return inst;
|
||||
}
|
||||
|
||||
void DevicePerseus::scan()
|
||||
{
|
||||
// If some firmware was not downloaded at time of enumeration interface will break later
|
||||
// so in this case we re initialize the library, clear the scan results and scan again
|
||||
if (!internal_scan())
|
||||
{
|
||||
qDebug("DevicePerseus::scan: re-init library and scan again");
|
||||
m_scan.clear();
|
||||
perseus_exit();
|
||||
m_nbDevices = perseus_init();
|
||||
internal_scan();
|
||||
}
|
||||
}
|
||||
|
||||
bool DevicePerseus::internal_scan()
|
||||
{
|
||||
return m_scan.scan(m_nbDevices);
|
||||
}
|
||||
|
@ -25,7 +25,7 @@ class DEVICES_API DevicePerseus
|
||||
{
|
||||
public:
|
||||
static DevicePerseus& instance();
|
||||
void scan() { m_scan.scan(m_nbDevices); }
|
||||
void scan();
|
||||
void getSerials(std::vector<std::string>& serials) const { m_scan.getSerials(serials); }
|
||||
int getSequenceFromSerial(const std::string& serial) const { return m_scan.getSequenceFromSerial(serial); }
|
||||
|
||||
@ -36,6 +36,7 @@ protected:
|
||||
~DevicePerseus();
|
||||
|
||||
private:
|
||||
bool internal_scan();
|
||||
int m_nbDevices;
|
||||
DevicePerseusScan m_scan;
|
||||
};
|
||||
|
@ -20,26 +20,40 @@
|
||||
#include <QtGlobal>
|
||||
|
||||
|
||||
void DevicePerseusScan::scan(int nbDevices)
|
||||
bool DevicePerseusScan::scan(int nbDevices)
|
||||
{
|
||||
if (nbDevices == 0) {
|
||||
if (nbDevices == 0)
|
||||
{
|
||||
qInfo("DevicePerseusScan::scan: no Perseus devices");
|
||||
return;
|
||||
return true;
|
||||
}
|
||||
|
||||
bool done = true;
|
||||
perseus_descr *descr;
|
||||
eeprom_prodid prodid;
|
||||
|
||||
for (int deviceIndex = 0; deviceIndex < nbDevices; deviceIndex++)
|
||||
{
|
||||
if ((descr = perseus_open(deviceIndex)) == 0) {
|
||||
qCritical("DevicePerseusScan::scan: open error: %s", perseus_errorstr());
|
||||
if ((descr = perseus_open(deviceIndex)) == 0)
|
||||
{
|
||||
qCritical("DevicePerseusScan::scan: device #%d open error: %s", deviceIndex, perseus_errorstr());
|
||||
perseus_close(descr);
|
||||
continue;
|
||||
}
|
||||
|
||||
if (perseus_firmware_download(descr, 0) < 0) {
|
||||
qCritical("DevicePerseusScan::scan: firmware download error: %s", perseus_errorstr());
|
||||
if (descr->firmware_downloaded)
|
||||
{
|
||||
qDebug("DevicePerseusScan::scan: device #%d firmware is already downloaded", deviceIndex);
|
||||
}
|
||||
else
|
||||
{
|
||||
qDebug("DevicePerseusScan::scan: device #%d firmware is not yet downloaded", deviceIndex);
|
||||
done = false;
|
||||
}
|
||||
|
||||
if (perseus_firmware_download(descr, 0) < 0)
|
||||
{
|
||||
qCritical("DevicePerseusScan::scan: device #%d firmware download error: %s", deviceIndex, perseus_errorstr());
|
||||
perseus_close(descr);
|
||||
continue;
|
||||
}
|
||||
@ -48,8 +62,9 @@ void DevicePerseusScan::scan(int nbDevices)
|
||||
qInfo("DevicePerseusScan::scan: device #%d firmware downloaded", deviceIndex);
|
||||
}
|
||||
|
||||
if (perseus_get_product_id(descr,&prodid) < 0) {
|
||||
qCritical("DevicePerseusScan::scan: get product id error: %s", perseus_errorstr());
|
||||
if (perseus_get_product_id(descr,&prodid) < 0)
|
||||
{
|
||||
qCritical("DevicePerseusScan::scan: device #%d get product id error: %s", deviceIndex, perseus_errorstr());
|
||||
perseus_close(descr);
|
||||
continue;
|
||||
}
|
||||
@ -65,6 +80,14 @@ void DevicePerseusScan::scan(int nbDevices)
|
||||
perseus_close(descr);
|
||||
}
|
||||
}
|
||||
|
||||
return done;
|
||||
}
|
||||
|
||||
void DevicePerseusScan::clear()
|
||||
{
|
||||
m_scans.clear();
|
||||
m_serialMap.clear();
|
||||
}
|
||||
|
||||
const std::string* DevicePerseusScan::getSerialAt(unsigned int index) const
|
||||
|
@ -35,7 +35,8 @@ public:
|
||||
int m_sequence;
|
||||
};
|
||||
|
||||
void scan(int nbDevices);
|
||||
bool scan(int nbDevices); //!< false if one device had its firmware not yet downloaded
|
||||
void clear();
|
||||
int getNbActiveDevices() const { return m_scans.size(); }
|
||||
const std::string* getSerialAt(unsigned int index) const;
|
||||
uint16_t getSerialNumberAt(unsigned int index) const ;
|
||||
|
Loading…
Reference in New Issue
Block a user