19 #include "perseus-sdr.h" 28 qInfo(
"DevicePerseusScan::scan: no Perseus devices");
36 for (
int deviceIndex = 0; deviceIndex < nbDevices; deviceIndex++)
38 if ((descr = perseus_open(deviceIndex)) == 0)
40 qCritical(
"DevicePerseusScan::scan: device #%d open error: %s", deviceIndex, perseus_errorstr());
45 if (perseus_firmware_download(descr, 0) < 0)
47 qCritical(
"DevicePerseusScan::scan: device #%d firmware download error: %s", deviceIndex, perseus_errorstr());
54 qInfo(
"DevicePerseusScan::scan: device #%d firmware downloaded", deviceIndex);
57 if (perseus_get_product_id(descr,&prodid) < 0)
59 qCritical(
"DevicePerseusScan::scan: device #%d get product id error: %s", deviceIndex, perseus_errorstr());
65 uint32_t sigA = (prodid.signature[5]<<16) + prodid.signature[4];
66 uint32_t sigB = (prodid.signature[3]<<16) + prodid.signature[2];
67 uint32_t sigC = (prodid.signature[1]<<16) + prodid.signature[0];
69 ss << prodid.sn <<
"-" << std::hex << sigA <<
"-" << sigB <<
"-" << sigC;
70 m_scans.push_back({ss.str(), prodid.sn, deviceIndex});
88 return &(
m_scans[index].m_serial);
97 return m_scans[index].m_serialNumber;
106 return m_scans[index].m_sequence;
114 std::map<std::string, DeviceScan*>::const_iterator it =
m_serialMap.find(serial);
118 return ((it->second)->m_sequence);
124 std::vector<DeviceScan>::const_iterator it =
m_scans.begin();
127 for (; it !=
m_scans.end(); ++it) {
128 serials.push_back(it->m_serial);
bool scan(int nbDevices)
false if one device had its firmware not yet downloaded
std::vector< DeviceScan > m_scans
void getSerials(std::vector< std::string > &serials) const
const std::string * getSerialAt(unsigned int index) const
std::map< std::string, DeviceScan * > m_serialMap
int getSequenceAt(unsigned int index) const
int getSequenceFromSerial(const std::string &serial) const
uint16_t getSerialNumberAt(unsigned int index) const