Example scanning the IEEE1394 (firewire) bus and looking for cameras
- Author
- MIP
#include <getopt.h>
#include <VideoSource/VideoSource_MDcam.hh>
#include <iostream>
#include <fstream>
using namespace std;
using namespace BIAS;
void usage()
{
cout <<"Usage: Scan1394Bus [options] filename"<<endl;
cout <<"Options: "<<endl;
cout <<" -a : append to file instead of overwrite"<<endl;
cout <<" -b N : scan bus number N instead of 0"<<endl;
}
int main(int argc, char *argv[])
{
ofstream ofs;
char *filename;
bool append = false;
char c;
while (argc >1)
{
c = getopt(argc,argv,"ab:");
if (c == -1) break;
switch (c)
{
case 'a':
append = true;
break;
case 'b':
break;
default:
usage();
exit(1);
}
}
if ( (argc -optind) >0)
filename = argv[optind];
else {
usage();
exit(1);
}
if (append)
ofs.open(filename,ios::app);
else
ofs.open(filename);
if ( !ofs ) {
perror(filename);
exit(1);
}
ofs.close();
return 0;
}