Beispiel #1
0
		FwVersionInfo get_version_info(BufferedIO& buffered_io) throw(boost::system::system_error,BufferedIO::TimeoutException) {
			std::string line;
			buffered_io.write("n");
			for(uint8_t tries = 10; tries != 0 && (line.empty() || line[0] != 'N'); tries--) {
				try {
					const auto data = buffered_io.readStringUntil(boost::posix_time::seconds(1), "\n");
					if(data.empty()) {
						buffered_io.write("n");
					} else {
						line = strip_carriage_return(data);
					}
				}catch(const BufferedIO::TimeoutException& e) {
					buffered_io.write("n");
				}
			}
			
			if(line.length() < 2 || line[0] != 'N') {
				return FwVersionInfo();
			}
			Json::Value reply;
			if(line.length() < 2 || line[0] != 'N' || !Json::Reader().parse(line.substr(2), reply)) {
				return FwVersionInfo();
			}
			return FwVersionInfo(reply);
		}
boolean read_line (i_o_block * file_to_read)

{if (file_to_read == NULL || file_to_read -> line == NULL || file_to_read -> pointer == NULL ||
     fgets (file_to_read -> line, file_to_read -> length_of_line, file_to_read -> pointer) == NULL)
   return FALSE;

 strip_carriage_return (file_to_read -> line);
 return TRUE;}
Beispiel #3
0
		ControlVariables get_control_variables(BufferedIO& buffered_io) throw(boost::system::system_error,BufferedIO::TimeoutException) {
			buffered_io.write("v");
			const std::string line = strip_carriage_return(buffered_io.readStringUntil(boost::posix_time::seconds(1),"\n"));
			Json::Value reply;
			if(line.length() <= 2 || line[0] != 'V' || !Json::Reader().parse(line.substr(2), reply)) {
				return ControlVariables();
			}
			return ControlVariables(reply);
		}