Page Menu
Home
c4science
Search
Configure Global Search
Log In
Files
F121916379
main.cpp
No One
Temporary
Actions
Download File
Edit File
Delete File
View Transforms
Subscribe
Mute Notifications
Award Token
Subscribers
None
File Metadata
Details
File Info
Storage
Attached
Created
Mon, Jul 14, 19:53
Size
1 KB
Mime Type
text/x-c
Expires
Wed, Jul 16, 19:53 (2 d)
Engine
blob
Format
Raw Data
Handle
27412911
Attached To
R6621 SBCP High-Level Driver
main.cpp
View Options
/**
* \file main.cpp
*
* \date Sep 25, 2012
* \author Alexandre Tuleu
*/
#include <libsbcp-tool/argstream.h>
#include <libsbcp-tool/Config.h>
const static unsigned int UnitializedByte = 0x0f00;
int main(int argc, char ** argv){
unsigned int klass = UnitializedByte;
argstream as(argc,argv);
as >> parameter('c',"class",klass,"class to scan for",false)
>> help();
as.defaultErrorHandling();
std::tr1::shared_ptr<sbcp::Bus> bus = sbcp::Config::Instance().CreateBusFromStdFile();
if(klass == UnitializedByte){
std::cout << "Please enter a class :" << std::flush;
std::cin >> klass;
}
if(klass > 0xff){
std::ostringstream os;
os << "Unvalid device class 0x" << std::hex << klass;
throw std::runtime_error(os.str());
}
std::cout << "Scanning for devices ...." << std::flush;
std::vector<unsigned int> foundDevices;
foundDevices.reserve(255);
for(unsigned int i = 0 ; i < 256; ++i){
if(bus->SearchForDevice(klass,i)){
foundDevices.push_back(i);
}
}
if(foundDevices.empty()){
std::cout << std::endl << "No devices found." << std::endl;
return 0;
}
std::cout << " Found devices :" << std::hex;
for(std::vector<unsigned int>::const_iterator id = foundDevices.begin();
id != foundDevices.end();
++id){
std::cout << " 0x" << *id;
}
std::cout << std::endl;
return 0;
}
Event Timeline
Log In to Comment