Page Menu
Home
c4science
Search
Configure Global Search
Log In
Files
F120671977
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
Sun, Jul 6, 04:29
Size
1 KB
Mime Type
text/x-c
Expires
Tue, Jul 8, 04:29 (2 d)
Engine
blob
Format
Raw Data
Handle
27226683
Attached To
R6621 SBCP High-Level Driver
main.cpp
View Options
/**
* \file main.cpp
*
* \date Sep 25, 2012
* \author Alexandre Tuleu
*/
#include <iostream>
#include <libsbcp/utils/HexaByte.h>
#include <libsbcp-tool/argstream.h>
#include <libsbcp/utils/Config.h>
int main(int argc, char ** argv){
sbcp::HexaByte klass;
argstream as(argc,argv);
std::string busName("default");
bool listAll(false);
as >> parameter('c',"class",klass,"class to scan for",false)
>> parameter('b',"bus",busName,"bus to scan",false)
>> option("list-all-bus",listAll,"list all available SBCP bus.")
>> help();
as.defaultErrorHandling();
sbcp::Config config;
config.LoadAllFiles();
if(listAll){
typedef sbcp::BusesConfigSection::ListOfSubsection ListOfBus;
const ListOfBus & buses = config.BusDefinitions().SubSections();
std::cout << buses.size() << " bus available : ";
for(ListOfBus::const_iterator b = buses.begin();
b != buses.end();
++b){
if(b != buses.begin()){
std::cout << ", ";
}
std::cout << b->first;
}
std::cout << std::endl;
return 0;
}
std::tr1::shared_ptr<sbcp::Bus> bus = config.BusDefinitions().Bus(busName).OpenBus(12,1);
if(!klass.IsInitialized()){
std::cout << "Please enter a class :" << std::flush;
std::cin >> klass;
}
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.AsByte(),i)){
foundDevices.push_back(i);
}
}
if(foundDevices.empty()){
std::cout << std::endl << "No devices " << klass << " found." << std::endl;
return 0;
}
std::cout << std::endl << " Found devices" << klass << " :" << 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