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
ffcf99f7
Commit
ffcf99f7
authored
8 years ago
by
Jake Drahos
Browse files
Options
Downloads
Patches
Plain Diff
Implemented update encoding/decoding
parent
5162d624
No related branches found
No related tags found
No related merge requests found
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
groundStation/src/backend/backend.c
+13
-3
13 additions, 3 deletions
groundStation/src/backend/backend.c
groundStation/src/backend/bitwise.h
+9
-0
9 additions, 0 deletions
groundStation/src/backend/bitwise.h
groundStation/src/backend/cmHandler.c
+8
-6
8 additions, 6 deletions
groundStation/src/backend/cmHandler.c
with
30 additions
and
9 deletions
groundStation/src/backend/backend.c
+
13
−
3
View file @
ffcf99f7
...
...
@@ -35,6 +35,7 @@
#include
"type_def.h"
#include
"packet.h"
#include
"respcontrol.h"
#include
"update.h"
#include
"config.h"
#include
"cmHandler.h"
...
...
@@ -317,13 +318,22 @@ void sendVrpnPacket(struct ucart_vrpn_TrackerData *info) {
struct
metadata
m
;
uint8_t
data
[
128
];
if
(
EncodeUpdate
(
&
m
,
data
,
128
,
info
))
{
struct
position_update
u
;
u
.
id
=
currMessageID
;
u
.
x
=
info
->
x
;
u
.
y
=
info
->
y
;
u
.
z
=
info
->
z
;
u
.
pitch
=
info
->
pitch
;
u
.
roll
=
info
->
roll
;
u
.
yaw
=
info
->
yaw
;
if
(
EncodeUpdate
(
&
m
,
data
,
128
,
&
u
))
{
warnx
(
"Big problems"
);
return
;
}
m
.
msg_id
=
currMessageID
++
;
size_t
psize
;
s
size_t
psize
;
if
((
psize
=
EncodePacket
(
packet
,
64
,
&
m
,
data
))
<
0
)
{
warnx
(
"Big problems"
);
return
;
...
...
@@ -650,7 +660,7 @@ static void client_recv(int fd) {
printf
(
" 0x%.2x"
,
(
signed
)
packet
[
i
]);
}
printf
(
"'
\n
"
);
writeQuad
(
(
char
*
)
packet
,
packetSize
);
writeQuad
(
packet
,
packetSize
);
}
char
*
rest
=
&
buffer
[
newline
]
+
1
;
...
...
This diff is collapsed.
Click to expand it.
groundStation/src/backend/bitwise.h
+
9
−
0
View file @
ffcf99f7
...
...
@@ -11,6 +11,15 @@
/* Build a 16-bit integer out of two bytes */
#define BytesTo16(lsb, msb) (((lsb) & 0xff) | (((msb) << 8) & 0xff))
/* Same for 32bit */
#define IntByte1(x) ((x) & 0xff)
#define IntByte2(x) (((x) >> 8) & 0xff)
#define IntByte3(x) (((x) >> 16) & 0xff)
#define IntByte4(x) (((x) >> 24) & 0xff)
#define BytesToInt(b1, b2, b3, b4) (((b1) & 0xff) | (((b2) << 8) & 0xff) \
| (((b3) << 16) & 0xff) | (((b4) & 0xff)))
/* Break apart a float. Sadly this is UB, but the "correct" way
* to do this involves actually implementing
* IEEE 754 in software to do so
...
...
This diff is collapsed.
Click to expand it.
groundStation/src/backend/cmHandler.c
+
8
−
6
View file @
ffcf99f7
#include
"cmHandler.h"
/*enum respContIndices {
/*
enum respContIndices {
GET_PITCH_P ,
GET_PITCH_I ,
GET_PITCH_D ,
...
...
@@ -30,11 +31,10 @@
GET_LONG_I ,
GET_LONG_D ,
GET_LONG ,
GET_LONG_RATE,
MAX_COMMANDS
};
*/
};
const
char
*
respContStrings
[
MAX_COMMANDS
]
{
const char * respContStrings[MAX_COMMANDS]
=
{
"getrollp",
"getrolli",
"getrolld",
...
...
@@ -71,7 +71,8 @@ const char * respContStrings[MAX_COMMANDS] {
"getheighti",
"getheightd",
"getheight"
}
};
*/
const
char
*
cmToString
(
int
msgType
,
const
struct
controller_message
*
cm
)
{
...
...
@@ -88,7 +89,8 @@ const char * cmToString(int msgType, const struct controller_message *cm)
return
NULL
;
break
;
case
RESPCONTROL_ID
:
return
respContStrings
[
cm
->
id
+
cm
->
value_id
];
return
"FOOBAR"
;
// return respContStrings[cm->id + cm->value_id];
break
;
default:
return
NULL
;
...
...
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