Skip to content
Projects
Groups
Snippets
Help
Loading...
Sign in
Toggle navigation
B
Beam Positoning Monitor - Software
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
Wiki
Wiki
image/svg+xml
Discourse
Discourse
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Commits
Issue Boards
Open sidebar
Projects
Beam Positoning Monitor - Software
Commits
45f873c7
Commit
45f873c7
authored
May 17, 2015
by
Lucas Russo
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
src/*/protocols/ops/*_bsmp.c: simplify error handling for send/recv
parent
589a10e7
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
20 additions
and
19 deletions
+20
-19
sm_pr_bsmp.c
src/sm_io/protocols/ops/sm_pr_bsmp.c
+20
-19
No files found.
src/sm_io/protocols/ops/sm_pr_bsmp.c
View file @
45f873c7
...
...
@@ -388,22 +388,23 @@ err_ret_groups:
/* BSMP function I/O */
static
int
_smpr_proto_bsmp_send
(
uint8_t
*
data
,
uint32_t
*
count
)
{
int
err
=
0
;
DBE_DEBUG
(
DBG_LL_IO
|
DBG_LVL_TRACE
,
"[sm_pr:bsmp] Sending %u bytes
\n
"
,
*
count
);
ssize_t
ret
=
smio_thsafe_client_write_block
(
bsmp_glue
.
parent
,
0
,
*
count
,
(
uint32_t
*
)
data
);
DBE_DEBUG
(
DBG_LL_IO
|
DBG_LVL_TRACE
,
"[sm_pr:bsmp] Sent %u bytes
\n
"
,
*
count
);
/* Update count with the number of bytes received */
int
err
;
if
(
ret
>=
0
)
{
*
count
=
ret
;
err
=
0
;
}
else
{
if
(
ret
<
0
)
{
*
count
=
0
;
err
=
-
1
;
goto
err_packet_send
;
}
/* Update count with the number of bytes received */
*
count
=
ret
;
err_packet_send:
return
err
;
}
...
...
@@ -418,15 +419,14 @@ static int _smpr_proto_bsmp_recv (uint8_t *data, uint32_t *count)
(
uint32_t
*
)
data
);
DBE_DEBUG
(
DBG_LL_IO
|
DBG_LVL_TRACE
,
"[sm_pr:bsmp] Received %ld bytes
\n
"
,
ret
);
if
(
ret
>=
0
)
{
*
count
=
ret
;
err
=
0
;
}
else
{
/* error */
if
(
ret
<
0
)
{
*
count
=
0
;
return
-
1
;
err
=
-
1
;
goto
err_packet_header
;
}
*
count
=
ret
;
/* Now, we parse the protocol header and determine how many bytes
* we have left to read. Very protocol dependent. See BSMP documentation.
* and example located in
...
...
@@ -441,15 +441,16 @@ static int _smpr_proto_bsmp_recv (uint8_t *data, uint32_t *count)
DBE_DEBUG
(
DBG_LL_IO
|
DBG_LVL_TRACE
,
"[sm_pr:bsmp] Received another %ld "
"bytes
\n
"
,
ret
);
if
(
ret
>=
0
)
{
*
count
+=
ret
;
err
=
0
;
}
else
{
/* error */
if
(
ret
<
0
)
{
*
count
=
0
;
return
-
1
;
err
=
-
1
;
goto
err_packet_payload
;
}
*
count
+=
ret
;
err_packet_payload:
err_packet_header:
return
err
;
}
...
...
Write
Preview
Markdown
is supported
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