예제 #1
0
std::unique_ptr<std::iostream> SerialProvider::open(const FileName & filename){
	const PortInfo info = getPortInfo(filename);
	std::unique_ptr<serial::Serial> port( new serial::Serial( info.internalPortName,info.baudRate,
															serial::Timeout(),info.bytesize,info.parity,
															info.stopbits,info.flowcontrol ));
	if(!port->isOpen())
		throw std::runtime_error("SerialProvider::open: Could not open port: "+filename.toString());
	
	return std::unique_ptr<std::iostream> (new SerialIOStream(std::move(port)));
}
예제 #2
0
Cards_info::Cards_info(const CardsArgumentParser& argParser, const std::string& configFileName)
	: Pkginfo("cards info"),Pkgrepo(configFileName), m_argParser(argParser)
{
	if (m_argParser.isSet(CardsArgumentParser::OPT_ROOT))
		m_root=m_argParser.getOptionValue(CardsArgumentParser::OPT_ROOT);

	if (m_root.empty())
		m_root="/";
	else
		m_root=m_root+"/";
	if ((m_argParser.command() == CardsArgumentParser::CMD_INFO) ) {
		if (m_argParser.isSet(CardsArgumentParser::OPT_BINARIES)) {
			getBinaryPackageInfo(m_argParser.otherArguments()[0]);
		} else if (m_argParser.isSet(CardsArgumentParser::OPT_PORTS)) {
			getPortInfo(m_argParser.otherArguments()[0]);
		} else {
			m_details_mode=1;
			m_arg=m_argParser.otherArguments()[0];
			run();
		}
	}
	if ((m_argParser.command() == CardsArgumentParser::CMD_LIST) ) {
		if (m_argParser.isSet(CardsArgumentParser::OPT_BINARIES)) {
			getBinaryPackageList();
		} else if (m_argParser.isSet(CardsArgumentParser::OPT_PORTS)) {
			getPortsList();
		} else {
			m_installed_mode=1;
			run();
		}
	}
	if ((m_argParser.command() == CardsArgumentParser::CMD_QUERY) ) {
		m_owner_mode=1;
		m_arg=m_argParser.otherArguments()[0];
		run();
	}
	if ((m_argParser.command() == CardsArgumentParser::CMD_FILES) ) {
		m_list_mode=1;
		m_arg=m_argParser.otherArguments()[0];
		run();		
	}
	if ((m_argParser.command() == CardsArgumentParser::CMD_SEARCH) ) {
		search(m_argParser.otherArguments()[0]);
	}
}
예제 #3
0
bool SerialProvider::isFile(const FileName & filename){
	PortInfo info = getPortInfo(filename);
	
//	std::cout << "Port:" << info.internalPortName <<"\n";
	
	try{
		serial::Serial port( info.internalPortName );

		const bool b = port.isOpen();
		if(b)
			port.close();
//		std::cout << "IsOpen:" << b <<"\n";
		return b;
	}catch(const serial::IOException & e){
//		std::cout << "!"<< e.what() << "\n";
		return false;
	}
}