/* * File: main.cpp * Author: fede.tft * * Created on September 10, 2009, 10:50 AM */ #include #include #include #include "TimeoutSerial.h" #include "XModem.h" using namespace std; using namespace boost; typedef vector< string > split_vector_type; bool dataHandler(unsigned long blockNo, char* buffer, int size) { cout << "Block No. = " << blockNo << endl; for (int i=0 ; i::iterator t=SplitVec.begin(); t!=SplitVec.end(); ++t) { split_vector_type kv; split(kv, *t, is_any_of("="), token_compress_on); // cout << "kv[0]=" << kv[0] << endl; if (kv[0] == "temperature") temperature = stof(kv[1]); if (kv[0] == "humidity") humidity = stof(kv[1]); if (kv[0] == "pressure") pressure = stof(kv[1]); } if (pressure > 0.0) break; } cout << "teplota = " << temperature << endl; cout << "vlhkost = " << humidity << endl; cout << "tlak = " << pressure << endl; XModem modem(&serial,dataHandler); serial.writeString("capture\r\n"); sleep(1); line = serial.readStringUntil("\r\n"); cout << line << endl; line = serial.readStringUntil("\r\n"); cout << line << endl; line = serial.readStringUntil("\r\n"); cout << line << endl; line = serial.readStringUntil("\r\n"); cout << line << endl; // line = serial.readStringUntil("\r\n"); // cout << line << endl; serial.writeString("rb\r\n"); sleep(1); serial.readChar(1); serial.readChar(1); modem.receive(); sleep(1); serial.writeString("free\r\n"); serial.close(); } catch(boost::system::system_error& e) { cout<<"Error: "<