probe.h
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 <vector>
00028 #include <iosfwd>
00029 #include <stdint.h>
00030
00031 namespace Barry {
00032
00033 struct BXEXPORT ProbeResult
00034 {
00035 Usb::DeviceIDType m_dev;
00036 unsigned char m_interface;
00037 uint32_t m_pin;
00038 Usb::EndpointPair m_ep;
00039 Usb::EndpointPair m_epModem;
00040 uint8_t m_zeroSocketSequence;
00041 std::string m_description;
00042
00043 ProbeResult()
00044 : m_dev(0), m_interface(0), m_pin(0), m_zeroSocketSequence(0)
00045 {}
00046 void DumpAll(std::ostream &os) const;
00047 bool HasIpModem() const { return m_epModem.IsComplete(); }
00048 };
00049
00050 BXEXPORT std::ostream& operator<< (std::ostream &os, const ProbeResult &pr);
00051
00052
00053 class BXEXPORT Probe
00054 {
00055 std::vector<ProbeResult> m_results;
00056
00057 std::vector<std::string> m_fail_msgs;
00058 int m_fail_count;
00059
00060 BXLOCAL bool CheckSize(const Data &data, unsigned int required);
00061 BXLOCAL bool ParsePIN(const Data &data, uint32_t &pin);
00062 BXLOCAL bool ParseDesc(const Data &data, std::string &desc);
00063
00064 protected:
00065 void ProbeMatching(int vendor, int product,
00066 const char *busname, const char *devname);
00067 void ProbeDevice(Usb::DeviceIDType devid);
00068 bool ProbePair(Usb::Device &dev, const Usb::EndpointPair &ep,
00069 uint32_t &pin, std::string &desc, uint8_t &zeroSocketSequence);
00070 bool ProbeModem(Usb::Device &dev, const Usb::EndpointPair &ep);
00071
00072 public:
00073 Probe(const char *busname = 0, const char *devname = 0);
00074
00075 int GetCount() const { return m_results.size(); }
00076 int GetFailCount() const { return m_fail_count; }
00077
00078 const std::string& GetFailMsg(int index) const { return m_fail_msgs[index]; }
00079 const ProbeResult& Get(int index) const { return m_results[index]; }
00080
00081 int FindActive(uint32_t pin = 0) const;
00082
00083 };
00084
00085
00086 }
00087
00088 #endif
00089