Changeset 6bd7144 in thomson for elec/CrO2/software/device_bekit.cpp
- Timestamp:
- Jan 22, 2013, 6:25:57 PM (11 years ago)
- Branches:
- main
- Children:
- 65a4aad
- Parents:
- e017851
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
elec/CrO2/software/device_bekit.cpp
re017851 r6bd7144 13 13 #include <USBKit.h> 14 14 15 class DeviceScanner: public BUSBRoster 16 { 17 public: 18 DeviceScanner(uint32_t vid, uint32_t pid, const char* vendor, const char* product); 19 20 // BUSBRoster 21 status_t DeviceAdded(BUSBDevice* device); 22 void DeviceRemoved(BUSBDevice* device); 23 24 BUSBDevice* handle; 25 private: 26 uint32_t vid, pid; 27 const char* vendor, *product; 28 }; 15 29 16 30 // Gets the device instance. Throws an error message if something bad happens. … … 18 32 { 19 33 if (instance == NULL) { 20 instance = new HaikuDevice(); 34 DeviceScanner* scanner = new DeviceScanner(vid, pid, vendor, product); 35 36 while(scanner->handle == NULL); // FIXME don't hog CPU, and timeout 37 //throw "Device not found. Is the USB cable plugged correctly?"; 38 39 // We have our device, don't need the roster anymore. 40 delete scanner; 41 42 instance = new HaikuDevice(scanner->handle); 21 43 } 22 44 … … 25 47 26 48 27 HaikuDevice::HaikuDevice( ) throw(const char*)49 HaikuDevice::HaikuDevice(BUSBDevice* handle) throw(const char*) 28 50 { 29 // At this point, either we have found a device and handle is pointing to it, 30 // or we failed and handle is NULL. 31 if (!handle) 32 throw "Device not found. Is the USB cable plugged correctly?"; 51 this->handle = handle; 33 52 } 34 53 … … 67 86 68 87 69 status_t HaikuDevice::DeviceAdded(BUSBDevice* device) 88 DeviceScanner::DeviceScanner(uint32_t vid, uint32_t pid, const char* vendor, const char* product) 89 : vid(vid) 90 , pid(pid) 91 , vendor(vendor) 92 , product(product) 93 { 94 } 95 96 97 status_t DeviceScanner::DeviceAdded(BUSBDevice* device) 70 98 { 71 99 if (handle != NULL) { … … 94 122 95 123 96 void HaikuDevice::DeviceRemoved(BUSBDevice* device)124 void DeviceScanner::DeviceRemoved(BUSBDevice* device) 97 125 { 98 126 // This is only called for devices we accepted in DeviceAdded. We accept
Note:
See TracChangeset
for help on using the changeset viewer.