SDRAngel  4.11.5
Developer docs for <a href="https://github.com/f4exb/sdrangel">SDRangel<\a>, an Open Source Qt5 / OpenGL 3.0+ SDR and signal analyzer frontend to various hardware.
Classes | Public Member Functions | Private Attributes | List of all members
DevicePerseusScan Class Reference

#include <deviceperseusscan.h>

Classes

struct  DeviceScan
 

Public Member Functions

bool scan (int nbDevices)
 false if one device had its firmware not yet downloaded More...
 
void clear ()
 
int getNbActiveDevices () const
 
const std::string * getSerialAt (unsigned int index) const
 
uint16_t getSerialNumberAt (unsigned int index) const
 
int getSequenceAt (unsigned int index) const
 
int getSequenceFromSerial (const std::string &serial) const
 
void getSerials (std::vector< std::string > &serials) const
 

Private Attributes

std::vector< DeviceScanm_scans
 
std::map< std::string, DeviceScan * > m_serialMap
 

Detailed Description

Definition at line 29 of file deviceperseusscan.h.

Member Function Documentation

◆ clear()

void DevicePerseusScan::clear ( )

Definition at line 79 of file deviceperseusscan.cpp.

References m_scans, and m_serialMap.

Referenced by DevicePerseus::scan().

80 {
81  m_scans.clear();
82  m_serialMap.clear();
83 }
std::vector< DeviceScan > m_scans
std::map< std::string, DeviceScan * > m_serialMap
+ Here is the caller graph for this function:

◆ getNbActiveDevices()

int DevicePerseusScan::getNbActiveDevices ( ) const
inline

Definition at line 41 of file deviceperseusscan.h.

41 { return m_scans.size(); }
std::vector< DeviceScan > m_scans

◆ getSequenceAt()

int DevicePerseusScan::getSequenceAt ( unsigned int  index) const

Definition at line 103 of file deviceperseusscan.cpp.

References m_scans.

104 {
105  if (index < m_scans.size()) {
106  return m_scans[index].m_sequence;
107  } else {
108  return 0;
109  }
110 }
std::vector< DeviceScan > m_scans

◆ getSequenceFromSerial()

int DevicePerseusScan::getSequenceFromSerial ( const std::string &  serial) const

Definition at line 112 of file deviceperseusscan.cpp.

References m_serialMap.

113 {
114  std::map<std::string, DeviceScan*>::const_iterator it = m_serialMap.find(serial);
115  if (it == m_serialMap.end()) {
116  return -1;
117  } else {
118  return ((it->second)->m_sequence);
119  }
120 }
std::map< std::string, DeviceScan * > m_serialMap

◆ getSerialAt()

const std::string * DevicePerseusScan::getSerialAt ( unsigned int  index) const

Definition at line 85 of file deviceperseusscan.cpp.

References m_scans.

86 {
87  if (index < m_scans.size()) {
88  return &(m_scans[index].m_serial);
89  } else {
90  return 0;
91  }
92 }
std::vector< DeviceScan > m_scans

◆ getSerialNumberAt()

uint16_t DevicePerseusScan::getSerialNumberAt ( unsigned int  index) const

Definition at line 94 of file deviceperseusscan.cpp.

References m_scans.

95 {
96  if (index < m_scans.size()) {
97  return m_scans[index].m_serialNumber;
98  } else {
99  return 0;
100  }
101 }
std::vector< DeviceScan > m_scans

◆ getSerials()

void DevicePerseusScan::getSerials ( std::vector< std::string > &  serials) const

Definition at line 122 of file deviceperseusscan.cpp.

References m_scans.

123 {
124  std::vector<DeviceScan>::const_iterator it = m_scans.begin();
125  serials.clear();
126 
127  for (; it != m_scans.end(); ++it) {
128  serials.push_back(it->m_serial);
129  }
130 }
std::vector< DeviceScan > m_scans

◆ scan()

bool DevicePerseusScan::scan ( int  nbDevices)

false if one device had its firmware not yet downloaded

Definition at line 24 of file deviceperseusscan.cpp.

References m_scans, and m_serialMap.

Referenced by DevicePerseus::internal_scan().

25 {
26  if (nbDevices == 0)
27  {
28  qInfo("DevicePerseusScan::scan: no Perseus devices");
29  return true;
30  }
31 
32  bool done = true;
33  perseus_descr *descr;
34  eeprom_prodid prodid;
35 
36  for (int deviceIndex = 0; deviceIndex < nbDevices; deviceIndex++)
37  {
38  if ((descr = perseus_open(deviceIndex)) == 0)
39  {
40  qCritical("DevicePerseusScan::scan: device #%d open error: %s", deviceIndex, perseus_errorstr());
41  perseus_close(descr);
42  continue;
43  }
44 
45  if (perseus_firmware_download(descr, 0) < 0)
46  {
47  qCritical("DevicePerseusScan::scan: device #%d firmware download error: %s", deviceIndex, perseus_errorstr());
48  perseus_close(descr);
49  done = false;
50  continue;
51  }
52  else
53  {
54  qInfo("DevicePerseusScan::scan: device #%d firmware downloaded", deviceIndex);
55  }
56 
57  if (perseus_get_product_id(descr,&prodid) < 0)
58  {
59  qCritical("DevicePerseusScan::scan: device #%d get product id error: %s", deviceIndex, perseus_errorstr());
60  perseus_close(descr);
61  continue;
62  }
63  else
64  {
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];
68  std::stringstream ss;
69  ss << prodid.sn << "-" << std::hex << sigA << "-" << sigB << "-" << sigC;
70  m_scans.push_back({ss.str(), prodid.sn, deviceIndex});
71  m_serialMap[m_scans.back().m_serial] = &m_scans.back();
72  perseus_close(descr);
73  }
74  }
75 
76  return done;
77 }
std::vector< DeviceScan > m_scans
unsigned int uint32_t
Definition: rtptypes_win.h:46
std::map< std::string, DeviceScan * > m_serialMap
+ Here is the caller graph for this function:

Member Data Documentation

◆ m_scans

std::vector<DeviceScan> DevicePerseusScan::m_scans
private

◆ m_serialMap

std::map<std::string, DeviceScan*> DevicePerseusScan::m_serialMap
private

Definition at line 50 of file deviceperseusscan.h.

Referenced by clear(), getSequenceFromSerial(), and scan().


The documentation for this class was generated from the following files: