Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
M
MicroCART
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Deploy
Releases
Model registry
Monitor
Incidents
Analyze
Value stream analytics
Contributor 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
Distributed Autonomous Networked Control Lab
MicroCART
Commits
cfba4748
Commit
cfba4748
authored
7 years ago
by
burneykb
Browse files
Options
Downloads
Patches
Plain Diff
implemented cb_addnode in the quad_app library
parent
cc49ff74
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
quad/src/quad_app/callbacks.c
+21
-1
21 additions, 1 deletion
quad/src/quad_app/callbacks.c
with
21 additions
and
1 deletion
quad/src/quad_app/callbacks.c
+
21
−
1
View file @
cfba4748
#include
"communication.h"
#include
"commands.h"
#include
"graph_blocks.h"
#include
"type_def.h"
#include
"computation_graph.h"
#include
"util.h"
...
...
@@ -382,10 +383,29 @@ int cb_getnodes(struct modular_structs *structs, struct metadata *meta, unsigned
* |-----------------------------|
*/
int
cb_addnode
(
struct
modular_structs
*
structs
,
struct
metadata
*
meta
,
unsigned
char
*
data
,
unsigned
short
length
)
{
const
struct
computation_graph
*
graph
=
structs
->
parameter_struct
.
graph
;
// Check if the data length is large enough
if
(
length
<
2
)
{
return
-
1
;}
// Size of name
size_t
name_len
=
length
-
2
;
struct
computation_graph
*
graph
=
structs
->
parameter_struct
.
graph
;
char
resp_buf
[
2
];
int16_t
node_type
=
build_short
(
data
);
if
(
node_type
<
0
&&
node_type
>=
MAX_BLOCK_TYPES
)
{
pack_short
(
-
1
,
resp_buf
);
send_data
(
&
structs
->
hardware_struct
.
uart
,
RESPADDNODE_ID
,
meta
->
msg_id
,
resp_buf
,
2
);
return
-
1
;
}
char
*
name
=
strndup
(
data
+
2
,
name_len
);
int
new_block_id
=
graph_add_defined_block
(
graph
,
node_type
,
name
);
free
(
name
);
// Format the response data
// New Block Id
pack_short
(
new_block_id
,
resp_buf
);
// Send the response
send_data
(
&
structs
->
hardware_struct
.
uart
,
RESPADDNODE_ID
,
meta
->
msg_id
,
resp_buf
,
2
);
return
0
;
}
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