Skip to content
Snippets Groups Projects
Commit a98b4f48 authored by Sergi Hernandez's avatar Sergi Hernandez
Browse files

Solved a problem with the input arguments. The input arguments are checked...

Solved a problem with the input arguments. The input arguments are checked before being used to avoid errors.
parent 5553bfe6
No related branches found
No related tags found
No related merge requests found
......@@ -61,29 +61,32 @@ int main(int argc, char *argv[])
ftdi_config.latency_timer = 16;
try{
std::cout << (*ftdi_server) << std::endl;
if(ftdi_server->get_num_devices()>0)
{
while(ftdi_device==NULL && count>0)
std::cout << (*ftdi_server) << std::endl;
if(ftdi_server->get_num_devices()>0)
{
try{
ftdi_device=ftdi_server->get_device(ftdi_server->get_serial_number(atoi(argv[1])));
}catch(CException &e){
std::cout << e.what() << std::endl;
count--;
while(ftdi_device==NULL && count>0)
{
try{
if(argc>=2)
ftdi_device=ftdi_server->get_device(ftdi_server->get_serial_number(atoi(argv[1])));
else
ftdi_device=ftdi_server->get_device(ftdi_server->get_serial_number(0));
}catch(CException &e){
std::cout << e.what() << std::endl;
count--;
}
}
if(count==0)
std::cout << "Device not available" << std::endl;
else
{
ftdi_device->config(&ftdi_config);
std::cout << (*ftdi_device) << std::endl;
ftdi_device->close();
}
}
if(count==0)
std::cout << "Device not available" << std::endl;
else
{
ftdi_device->config(&ftdi_config);
std::cout << (*ftdi_device) << std::endl;
ftdi_device->close();
}
}
if(ftdi_device!=NULL)
delete ftdi_device;
if(ftdi_device!=NULL)
delete ftdi_device;
}catch(CException &e){
std::cout << e.what() << std::endl;
}
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment