Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
U
usb_i2c_adapter
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Model registry
Operate
Environments
Monitor
Incidents
Service Desk
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
labrobotica
drivers
usb_i2c_adapter
Commits
aa2183a8
Commit
aa2183a8
authored
5 years ago
by
Sergi Hernandez
Browse files
Options
Downloads
Patches
Plain Diff
Solved the problems associated with some warning messages.
parent
55dcf380
No related branches found
No related tags found
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
src/usb_i2c.cpp
+55
-11
55 additions, 11 deletions
src/usb_i2c.cpp
with
55 additions
and
11 deletions
src/usb_i2c.cpp
+
55
−
11
View file @
aa2183a8
...
@@ -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 */
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment