Go to the documentation of this file.00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022 #ifndef __BARRY_PROBE_H__
00023 #define __BARRY_PROBE_H__
00024
00025 #include "dll.h"
00026 #include "usbwrap.h"
00027 #include "pin.h"
00028 #include <vector>
00029 #include <iosfwd>
00030 #include <stdint.h>
00031
00032 namespace Barry {
00033
00034 class Probe;
00035
00036 struct BXEXPORT ProbeResult
00037 {
00038 friend class Probe;
00039
00040 Usb::DeviceIDType m_dev;
00041 unsigned char m_interface;
00042 Barry::Pin m_pin;
00043 Usb::EndpointPair m_ep;
00044 Usb::EndpointPair m_epModem;
00045
00046
00047
00048
00049
00050
00051 bool m_needClearHalt;
00052
00053
00054
00055
00056
00057
00058
00059 bool m_needSetAltInterface;
00060 uint8_t m_zeroSocketSequence;
00061 std::string m_description;
00062
00063
00064
00065 std::string m_cfgDeviceName;
00066
00067 private:
00068
00069
00070 ProbeResult()
00071 : m_dev(0), m_interface(0), m_pin(0)
00072 , m_needClearHalt(false), m_needSetAltInterface(false)
00073 , m_zeroSocketSequence(0)
00074 {}
00075
00076 public:
00077 void DumpAll(std::ostream &os) const;
00078 bool HasIpModem() const { return m_epModem.IsComplete(); }
00079
00080 bool operator==(const Barry::Pin &pin) const
00081 {
00082 return m_pin == pin;
00083 }
00084 };
00085
00086 BXEXPORT std::ostream& operator<< (std::ostream &os, const ProbeResult &pr);
00087
00088
00089 class BXEXPORT Probe
00090 {
00091 public:
00092 typedef std::vector<ProbeResult> Results;
00093
00094 private:
00095 Results m_results;
00096
00097 std::vector<std::string> m_fail_msgs;
00098 int m_fail_count;
00099
00100 bool m_epp_override;
00101 Usb::EndpointPair m_epp;
00102
00103 BXLOCAL bool CheckSize(const Data &data, unsigned int required);
00104 BXLOCAL bool ParsePIN(const Data &data, uint32_t &pin);
00105 BXLOCAL bool ParseDesc(const Data &data, std::string &desc);
00106
00107 protected:
00108 void ProbeMatching(int vendor, int product,
00109 const char *busname, const char *devname);
00110 void ProbeDevice(Usb::DeviceIDType devid);
00111 void ProbeDeviceEndpoints(Usb::Device &dev, Usb::EndpointDiscovery &ed, ProbeResult &result);
00112 bool ProbePair(Usb::Device &dev, const Usb::EndpointPair &ep,
00113 uint32_t &pin, std::string &desc, uint8_t &zeroSocketSequence,
00114 bool &needClearHalt);
00115 bool ProbeModem(Usb::Device &dev, const Usb::EndpointPair &ep);
00116
00117 public:
00118 Probe(const char *busname = 0, const char *devname = 0,
00119 const Usb::EndpointPair *epp = 0);
00120
00121 const Results& GetResults() const { return m_results; }
00122
00123 int GetCount() const { return m_results.size(); }
00124 int GetFailCount() const { return m_fail_count; }
00125
00126 const std::string& GetFailMsg(int index) const { return m_fail_msgs.at(index); }
00127 const ProbeResult& Get(int index) const { return m_results.at(index); }
00128
00129 int FindActive(Barry::Pin pin = 0) const;
00130
00131 static int FindActive(const Results &results, Barry::Pin pin = 0);
00132 static int Find(const Results &results, Barry::Pin pin = 0);
00133 };
00134
00135
00136 }
00137
00138 #endif
00139