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

Solved the problems associated with some warning messages.

parent 55dcf380
No related branches found
No related tags found
No related merge requests found
...@@ -84,7 +84,11 @@ unsigned char CUSBI2C::get_revision(void) ...@@ -84,7 +84,11 @@ unsigned char CUSBI2C::get_revision(void)
else else
{ {
this->event_server->wait_first(events); this->event_server->wait_first(events);
read=this->comm_dev->read(&revision,1); if((read=this->comm_dev->read(&revision,1))!=1)
{
/* handle exceptions */
throw CUSBI2CException(_HERE_,"Error while receiving the answer from the converter");
}
} }
return revision; return revision;
...@@ -140,7 +144,11 @@ void CUSBI2C::set_gpio(gpio_pins pin, bool value) ...@@ -140,7 +144,11 @@ void CUSBI2C::set_gpio(gpio_pins pin, bool value)
else else
{ {
this->event_server->wait_first(events); this->event_server->wait_first(events);
read=this->comm_dev->read(&gpio_state,1); if((read=this->comm_dev->read(&gpio_state,1))!=1)
{
/* handle exceptions */
throw CUSBI2CException(_HERE_,"Error while receiving answer from the converter");
}
if(value==true) if(value==true)
gpio_state|=(0x01<<(pin+1)); gpio_state|=(0x01<<(pin+1));
else else
...@@ -155,7 +163,11 @@ void CUSBI2C::set_gpio(gpio_pins pin, bool value) ...@@ -155,7 +163,11 @@ void CUSBI2C::set_gpio(gpio_pins pin, bool value)
else else
{ {
this->event_server->wait_first(events); this->event_server->wait_first(events);
read=this->comm_dev->read(&gpio_state,1); if((read=this->comm_dev->read(&gpio_state,1))!=1)
{
/* handle exceptions */
throw CUSBI2CException(_HERE_,"Error while receiving answer from the converter");
}
} }
} }
} }
...@@ -184,7 +196,11 @@ bool CUSBI2C::get_gpio(gpio_pins pin) ...@@ -184,7 +196,11 @@ bool CUSBI2C::get_gpio(gpio_pins pin)
else else
{ {
this->event_server->wait_first(events); this->event_server->wait_first(events);
read=this->comm_dev->read(&gpio_state,1); if((read=this->comm_dev->read(&gpio_state,1))!=1)
{
/* handle exceptions */
throw CUSBI2CException(_HERE_,"Error while receiving answer from the converter");
}
if(gpio_state&(0x01<<(pin+1))) if(gpio_state&(0x01<<(pin+1)))
return true; return true;
else else
...@@ -211,7 +227,11 @@ short int CUSBI2C::get_analog(gpio_pins pin) ...@@ -211,7 +227,11 @@ short int CUSBI2C::get_analog(gpio_pins pin)
if(this->gpio_config[pin]==analog_input) if(this->gpio_config[pin]==analog_input)
{ {
events.push_back(this->rx_event_id); events.push_back(this->rx_event_id);
written=this->comm_dev->write(cmd,4); if((written=this->comm_dev->write(cmd,4))!=4)
{
/* handle exceptions */
throw CUSBI2CException(_HERE_,"Error while sending the command to the converter");
}
do{ do{
this->event_server->wait_first(events); this->event_server->wait_first(events);
read=this->comm_dev->read(&answer[total_read],4-total_read); read=this->comm_dev->read(&answer[total_read],4-total_read);
...@@ -248,7 +268,11 @@ void CUSBI2C::turn_led_on(void) ...@@ -248,7 +268,11 @@ void CUSBI2C::turn_led_on(void)
else else
{ {
this->event_server->wait_first(events); this->event_server->wait_first(events);
read=this->comm_dev->read(&gpio_state,1); if((read=this->comm_dev->read(&gpio_state,1))!=1)
{
/* handle exceptions */
throw CUSBI2CException(_HERE_,"Error while receiving answer from the converter");
}
gpio_state|=0x01; gpio_state|=0x01;
cmd[1]=0x10; cmd[1]=0x10;
cmd[2]=gpio_state; cmd[2]=gpio_state;
...@@ -260,7 +284,11 @@ void CUSBI2C::turn_led_on(void) ...@@ -260,7 +284,11 @@ void CUSBI2C::turn_led_on(void)
else else
{ {
this->event_server->wait_first(events); this->event_server->wait_first(events);
read=this->comm_dev->read(&gpio_state,1); if((read=this->comm_dev->read(&gpio_state,1))!=1)
{
/* handle exceptions */
throw CUSBI2CException(_HERE_,"Error while receiving answer from the converter");
}
} }
} }
} }
...@@ -281,7 +309,11 @@ void CUSBI2C::turn_led_off(void) ...@@ -281,7 +309,11 @@ void CUSBI2C::turn_led_off(void)
else else
{ {
this->event_server->wait_first(events); this->event_server->wait_first(events);
read=this->comm_dev->read(&gpio_state,1); if((read=this->comm_dev->read(&gpio_state,1))!=1)
{
/* handle exceptions */
throw CUSBI2CException(_HERE_,"Error while receiving answer from the converter");
}
gpio_state&=0xFE; gpio_state&=0xFE;
cmd[1]=0x10; cmd[1]=0x10;
cmd[2]=gpio_state; cmd[2]=gpio_state;
...@@ -293,7 +325,11 @@ void CUSBI2C::turn_led_off(void) ...@@ -293,7 +325,11 @@ void CUSBI2C::turn_led_off(void)
else else
{ {
this->event_server->wait_first(events); this->event_server->wait_first(events);
read=this->comm_dev->read(&gpio_state,1); if((read=this->comm_dev->read(&gpio_state,1))!=1)
{
/* handle exceptions */
throw CUSBI2CException(_HERE_,"Error while receiving answer from the converter");
}
} }
} }
} }
...@@ -331,7 +367,11 @@ int CUSBI2C::write(unsigned char dev_id, unsigned char *data, int len) ...@@ -331,7 +367,11 @@ int CUSBI2C::write(unsigned char dev_id, unsigned char *data, int len)
{ {
try{ try{
this->event_server->wait_first(events,500); this->event_server->wait_first(events,500);
read=this->comm_dev->read(&status,1); if((read=this->comm_dev->read(&status,1))!=1)
{
/* handle exceptions */
throw CUSBI2CException(_HERE_,"Error while receiving answer from the converter");
}
if(status==0x00) if(status==0x00)
{ {
/* handle exceptions */ /* handle exceptions */
...@@ -437,7 +477,11 @@ int CUSBI2C::write_reg(unsigned char dev_id, short int address, unsigned char *d ...@@ -437,7 +477,11 @@ int CUSBI2C::write_reg(unsigned char dev_id, short int address, unsigned char *d
{ {
try{ try{
this->event_server->wait_first(events,500); this->event_server->wait_first(events,500);
read=this->comm_dev->read(&status,1); if((read=this->comm_dev->read(&status,1))!=1)
{
/* handle exceptions */
throw CUSBI2CException(_HERE_,"Error while receiving answer from the converter");
}
if(status==0x00) if(status==0x00)
{ {
/* handle exceptions */ /* handle exceptions */
......
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