int CQboduinoDriver::getVersion(std::string board, int& board_number, int& version) { CComando comand=comandosSet_.version; std::vector<dataUnion> data, sent; int code=sendComand(board,comand,data,sent); if (code<0) return code; board_number=(int)data[0].b; version=(int)data[1].b; return code; }
BYTE sendSavePower(void) { BYTE i; BYTE buffer[5]; sendComand(save_power_cmd, 7); if(!getBuffer(buffer, 5)) return 0; for(i = 0; i<5; i++) if(buffer[i]!= save_power_rcv[i]) return 0; return 1; }
BYTE sendZoomSize(void) { BYTE i; BYTE buffer[5]; #ifdef ZOOM_SIZE sendComand(zoom_size_cmd, 6); #endif if(!getBuffer(buffer, 5)) return 0; for(i = 0; i<5; i++) if(buffer[i]!= zoom_size_rcv[i]) return 0; return 1; }
// reset cmr BYTE sendReset(void){ BYTE buffer[50]; WORD i = 0; UART1PutROMString("start\n"); sendComand(reset_cmd, 5); getCommand(buffer,10); for( i =0; i<4; i++){ if(buffer[i]!= reset_rcv[i]) return 0; } UART1PutROMString("end"); return 1; }
int CQboduinoDriver::lockAndSendComand(std::string board, CComando& comand, std::vector<dataUnion>& response, std::vector<dataUnion>& data) { int code=-3; if(boards_.count(board)==0) return -2; if(board.compare("base")==0 && sending_data_mutex_.timed_lock(boost::posix_time::millisec(500))) { code=sendComand(board,comand,response,data); sending_data_mutex_.unlock(); return code; } else code=-3; if(board.compare("head")==0 && sending_data_head_mutex_.timed_lock(boost::posix_time::millisec(500))) { code=sendComand(board,comand,response,data); sending_data_head_mutex_.unlock(); return code; } else code=-3; std::cout << "Mutex timeout" << std::endl; return code; }
BYTE setBaudRate(void) { BYTE i; BYTE buffer[5]; sendComand(set_bps_cmd, 7); if(!getBuffer(buffer, 5)) return 0; for(i = 0; i<5; i++) if(buffer[i]!= set_bps_rcv[i]) return 0; return 1; }
BYTE sendStopPhoto(void){ BYTE i; BYTE buffer[5]; sendComand(stop_photo_cmd, 5); if(!getCommand(buffer, 5)) return 0; for(i = 0; i<5; i++) if(buffer[i]!=stop_photo_rcv[i]){ return 0; } return 1; }
BYTE sendCompressRate(void){ BYTE i; BYTE buffer[5]; sendComand(compress_rate_cmd, 9); if(!getCommand(buffer, 5)) return 0; for(i = 0; i<5; i++){ if(buffer[i]!= compress_rate_rcv[i]){ return 0; } } return 1; }
BYTE sendStartPhoto(void){ BYTE buffer[5]; BYTE i = 0; sendComand(start_photo_cmd, 10); if(!getCommand(buffer, 5)) return 0; for(i = 0; i<5; i++){ if(buffer[i]!= start_photo_rcv[i]){ return 0; } } return 1; }
BYTE sendPhotoSize(void) { BYTE i; BYTE buffer[5]; sendComand(photo_size_cmd, 10); if(!getCommand(buffer, 5)){ return 0; } for(i = 0; i<5; i++) if(buffer[i] !=photo_size_rcv[i]){ return 0; } return 1; }
BYTE sendGetLength(void){ BYTE buffer[7]; BYTE i = 0; sendComand(read_len_cmd, 5); if(!getCommand(buffer, 9)) return 0; for(i = 0; i<7; i++){ if(buffer[i]!=read_len_rcv[i]){ return 0; } } setPhotoLen(buffer[7], buffer[8]); for(i = 0; i<9; i++){ } return 1; }