Skip to content
GitLab
Menu
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
labrobotica
drivers
usb_i2c_adapter
Commits
aa2183a8
Commit
aa2183a8
authored
Mar 30, 2020
by
Sergi Hernandez
Browse files
Solved the problems associated with some warning messages.
parent
55dcf380
Changes
1
Hide whitespace changes
Inline
Side-by-side
src/usb_i2c.cpp
View file @
aa2183a8
...
...
@@ -84,7 +84,11 @@ unsigned char CUSBI2C::get_revision(void)
else
{
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
;
...
...
@@ -140,7 +144,11 @@ void CUSBI2C::set_gpio(gpio_pins pin, bool value)
else
{
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
)
gpio_state
|=
(
0x01
<<
(
pin
+
1
));
else
...
...
@@ -155,7 +163,11 @@ void CUSBI2C::set_gpio(gpio_pins pin, bool value)
else
{
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)
else
{
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
)))
return
true
;
else
...
...
@@ -211,7 +227,11 @@ short int CUSBI2C::get_analog(gpio_pins pin)
if
(
this
->
gpio_config
[
pin
]
==
analog_input
)
{
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
{
this
->
event_server
->
wait_first
(
events
);
read
=
this
->
comm_dev
->
read
(
&
answer
[
total_read
],
4
-
total_read
);
...
...
@@ -248,7 +268,11 @@ void CUSBI2C::turn_led_on(void)
else
{
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
;
cmd
[
1
]
=
0x10
;
cmd
[
2
]
=
gpio_state
;
...
...
@@ -260,7 +284,11 @@ void CUSBI2C::turn_led_on(void)
else
{
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)
else
{
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
;
cmd
[
1
]
=
0x10
;
cmd
[
2
]
=
gpio_state
;
...
...
@@ -293,7 +325,11 @@ void CUSBI2C::turn_led_off(void)
else
{
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)
{
try
{
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
)
{
/* handle exceptions */
...
...
@@ -437,7 +477,11 @@ int CUSBI2C::write_reg(unsigned char dev_id, short int address, unsigned char *d
{
try
{
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
)
{
/* handle exceptions */
...
...
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment