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

Checked if the write operation has been successfull.

parent 9ac50207
No related branches found
No related tags found
1 merge request!2Checked if the write operation has been successfull.
......@@ -349,11 +349,11 @@ uint8_t CModelCarDriverBase::get_id(void)
std::list<std::string> events;
events.push_back(this->new_info_event_id);
this->send_request(ID_ARD_ACT_REQUEST,0,NULL);
try{
this->send_request(ID_ARD_ACT_REQUEST,0,NULL);
this->event_server->wait_all(events,100);
}
catch(CEventTimeoutException &e){
catch(...){
return -1;
}
......@@ -362,7 +362,7 @@ uint8_t CModelCarDriverBase::get_id(void)
void CModelCarDriverBase::send_request(uint8_t id, uint8_t data_length, uint8_t *data)
{
uint8_t req_frame_size=sizeof(uint8_t)+sizeof(uint8_t)+sizeof(TTimeStampUnion)+data_length+sizeof(uint16_t),stuffed_frame_size;
uint8_t req_frame_size=sizeof(uint8_t)+sizeof(uint8_t)+sizeof(TTimeStampUnion)+data_length+sizeof(uint16_t),stuffed_frame_size,num_written;
uint16_t crc_value;
uint8_t *frame=NULL,*stuffed_frame=NULL;
......@@ -376,10 +376,12 @@ void CModelCarDriverBase::send_request(uint8_t id, uint8_t data_length, uint8_t
this->stuff_frame(frame,req_frame_size,&stuffed_frame,stuffed_frame_size);
this->port_mutex.enter();
this->serial_port->write(stuffed_frame,stuffed_frame_size);
num_written=this->serial_port->write(stuffed_frame,stuffed_frame_size);
this->port_mutex.exit();
delete[] stuffed_frame;
delete[] frame;
if(num_written!=stuffed_frame_size)
throw CException(_HERE_,"Failed to send request");
}
void CModelCarDriverBase::stuff_frame(uint8_t *frame_in, uint8_t size_in, uint8_t **frame_out, uint8_t & size_out)
......
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