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
d40c82a5
Commit
d40c82a5
authored
8 years ago
by
dawehr
Browse files
Options
Downloads
Patches
Plain Diff
Added echo functionality to parse_packet(). Sends back the message ID upon receiving a message.
parent
80ae5c41
No related branches found
No related tags found
No related merge requests found
Changes
43
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
modular_quad_pid/src/commands.c
+14
-0
14 additions, 0 deletions
modular_quad_pid/src/commands.c
modular_quad_pid/src/communication.c
+27
-0
27 additions, 0 deletions
modular_quad_pid/src/communication.c
modular_quad_pid/src/communication.h
+1
-0
1 addition, 0 deletions
modular_quad_pid/src/communication.h
with
42 additions
and
0 deletions
modular_quad_pid/src/commands.c
+
14
−
0
View file @
d40c82a5
...
@@ -22,6 +22,18 @@ struct MessageType MessageTypes[MAX_TYPE] =
...
@@ -22,6 +22,18 @@ struct MessageType MessageTypes[MAX_TYPE] =
stringType
,
stringType
,
// Function pointer
// Function pointer
&
debug
&
debug
},
// Echo subtype
{
// ID
0x01
,
// Command text
"ack"
,
// Type of the command data
intType
,
// Function pointer
NULL
}
}
}
}
},
},
...
@@ -388,6 +400,8 @@ int response(unsigned char *packet, int dataLen, modular_structs_t *structs)
...
@@ -388,6 +400,8 @@ int response(unsigned char *packet, int dataLen, modular_structs_t *structs)
// ------------------------------------------------------------------
// ------------------------------------------------------------------
// Quad side implementation
// Quad side implementation
// TODO: Erase memory leaks
int
yawset
(
unsigned
char
*
packet
,
int
dataLen
,
modular_structs_t
*
structs
)
int
yawset
(
unsigned
char
*
packet
,
int
dataLen
,
modular_structs_t
*
structs
)
{
{
float
value
;
float
value
;
...
...
This diff is collapsed.
Click to expand it.
modular_quad_pid/src/communication.c
+
27
−
0
View file @
d40c82a5
...
@@ -113,6 +113,33 @@ int parse_packet(unsigned char * packet, unsigned char ** data, metadata_t * met
...
@@ -113,6 +113,33 @@ int parse_packet(unsigned char * packet, unsigned char ** data, metadata_t * met
if
(
packet_checksum
!=
calculated_checksum
)
if
(
packet_checksum
!=
calculated_checksum
)
printf
(
"Checksums did not match (Quadlog): 0x%02x
\t
0x%02x
\n
"
,
packet_checksum
,
calculated_checksum
);
printf
(
"Checksums did not match (Quadlog): 0x%02x
\t
0x%02x
\n
"
,
packet_checksum
,
calculated_checksum
);
//////////////////////////////
// Send an acknowledgment packet
// Send a reply to the ground station
int
buf
=
meta_data
->
msg_id
;
unsigned
char
*
responsePacket
;
metadata_t
metadata
=
{
BEGIN_CHAR
,
MessageTypes
[
0
].
ID
,
MessageTypes
[
0
].
subtypes
[
1
].
ID
,
0
,
sizeof
(
int
)
};
formatPacket
(
&
metadata
,
&
buf
,
&
responsePacket
);
// Send each byte of the packet individually
for
(
i
=
0
;
i
<
8
+
metadata
.
data_len
;
i
++
)
{
// Debug print statement for all of the bytes being sent
//printf("%d: 0x%x\n", i, responsePacket[i]);
uart0_sendByte
(
responsePacket
[
i
]);
}
free
(
responsePacket
);
return
0
;
return
0
;
}
}
...
...
This diff is collapsed.
Click to expand it.
modular_quad_pid/src/communication.h
+
1
−
0
View file @
d40c82a5
...
@@ -7,6 +7,7 @@
...
@@ -7,6 +7,7 @@
#include
<limits.h>
#include
<limits.h>
#include
"commands.h"
#include
"commands.h"
#include
"type_def.h"
#include
"type_def.h"
#include
"uart.h"
int
formatCommand
(
unsigned
char
*
command
,
unsigned
char
**
formattedCommand
);
int
formatCommand
(
unsigned
char
*
command
,
unsigned
char
**
formattedCommand
);
int
formatPacket
(
metadata_t
*
metadata
,
void
*
data
,
unsigned
char
**
formattedCommand
);
int
formatPacket
(
metadata_t
*
metadata
,
void
*
data
,
unsigned
char
**
formattedCommand
);
...
...
This diff is collapsed.
Click to expand it.
Prev
1
2
3
Next
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