Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
M
model_car_drivers
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
Container Registry
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
mobile_robotics
ADC
libraries
model_car_drivers
Commits
567f45c0
Commit
567f45c0
authored
4 years ago
by
Sergi Hernandez
Browse files
Options
Downloads
Patches
Plain Diff
Change tData* TData* type names
parent
0be53e33
No related branches found
No related tags found
1 merge request
!1
Sergi
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
include/model_car_driver_base.h
+4
-4
4 additions, 4 deletions
include/model_car_driver_base.h
src/model_car_driver_base.cpp
+8
-8
8 additions, 8 deletions
src/model_car_driver_base.cpp
with
12 additions
and
12 deletions
include/model_car_driver_base.h
+
4
−
4
View file @
567f45c0
...
...
@@ -16,13 +16,13 @@
enum
sm_state
{
WAIT_START
,
READ_ID
,
READ_DATA_LENGTH
,
READ_TIMESTAMP
,
READ_DATA
,
READ_CRC
,
READ_END
};
union
t
TimeStampUnion
union
T
TimeStampUnion
{
unsigned
char
raw
[
4
];
uint32_t
time_stamp
;
};
union
t
CRCUnion
union
T
CRCUnion
{
unsigned
char
raw
[
2
];
uint16_t
crc
;
...
...
@@ -59,10 +59,10 @@ class CModelCarDriverBase
CMutex
data_mutex
;
static
void
*
data_thread
(
void
*
param
);
bool
process_byte
(
THeader
&
header
,
TDataUnion
&
data_union
,
t
CRCUnion
&
crc_union
,
unsigned
char
byte
);
bool
process_byte
(
THeader
&
header
,
TDataUnion
&
data_union
,
T
CRCUnion
&
crc_union
,
unsigned
char
byte
);
bool
get_id
(
uint8_t
&
id
);
void
send_request
(
uint8_t
id
,
uint8_t
data_length
,
uint8_t
*
data
);
sm_state
process_data
(
THeader
&
header
,
TDataUnion
&
data_union
,
t
CRCUnion
&
crc_union
);
sm_state
process_data
(
THeader
&
header
,
TDataUnion
&
data_union
,
T
CRCUnion
&
crc_union
);
virtual
void
process_data_frame
(
uint8_t
id
,
uint32_t
timestamp
,
TDataUnion
data_union
)
=
0
;
void
stuff_frame
(
uint8_t
const
*
frame_in
,
uint8_t
const
size_in
,
uint8_t
**
frame_out
,
uint8_t
&
size_out
);
uint16_t
fletcher16
(
uint8_t
const
*
data
,
uint8_t
bytes
);
...
...
This diff is collapsed.
Click to expand it.
src/model_car_driver_base.cpp
+
8
−
8
View file @
567f45c0
...
...
@@ -171,7 +171,7 @@ void *CModelCarDriverBase::data_thread(void *param)
THeader
header
;
TDataUnion
data_union
;
t
CRCUnion
crc_union
;
T
CRCUnion
crc_union
;
std
::
list
<
std
::
string
>
events
;
events
.
push_back
(
driver
->
serial_port
->
get_rx_event_id
());
...
...
@@ -226,7 +226,7 @@ void *CModelCarDriverBase::data_thread(void *param)
bool
CModelCarDriverBase
::
process_byte
(
THeader
&
header
,
TDataUnion
&
data_union
,
t
CRCUnion
&
crc_union
,
unsigned
char
byte
)
bool
CModelCarDriverBase
::
process_byte
(
THeader
&
header
,
TDataUnion
&
data_union
,
T
CRCUnion
&
crc_union
,
unsigned
char
byte
)
{
bool
frame_ready
=
false
;
...
...
@@ -235,7 +235,7 @@ bool CModelCarDriverBase::process_byte(THeader &header, TDataUnion &data_union,
static
int
ts_count
=
0
;
static
int
data_count
=
0
;
static
int
crc_count
=
0
;
t
TimeStampUnion
ts_union
;
T
TimeStampUnion
ts_union
;
if
(
byte
==
ESCAPE_BYTE
&&
!
escaped
)
escaped
=
true
;
...
...
@@ -343,7 +343,7 @@ bool CModelCarDriverBase::process_byte(THeader &header, TDataUnion &data_union,
return
frame_ready
;
}
sm_state
CModelCarDriverBase
::
process_data
(
THeader
&
header
,
TDataUnion
&
data_union
,
t
CRCUnion
&
crc_union
)
sm_state
CModelCarDriverBase
::
process_data
(
THeader
&
header
,
TDataUnion
&
data_union
,
T
CRCUnion
&
crc_union
)
{
sm_state
state
;
unsigned
char
*
single_frame
=
NULL
;
...
...
@@ -461,19 +461,19 @@ bool CModelCarDriverBase::get_id(uint8_t & id)
void
CModelCarDriverBase
::
send_request
(
uint8_t
id
,
uint8_t
data_length
,
uint8_t
*
data
)
{
unsigned
int
req_frame_size
=
sizeof
(
uint8_t
)
+
sizeof
(
uint8_t
)
+
sizeof
(
t
TimeStampUnion
)
+
data_length
;
unsigned
int
req_frame_size
=
sizeof
(
uint8_t
)
+
sizeof
(
uint8_t
)
+
sizeof
(
T
TimeStampUnion
)
+
data_length
;
unsigned
char
*
frame
;
frame
=
new
unsigned
char
[
req_frame_size
];
std
::
fill
(
frame
,
frame
+
req_frame_size
,
0x00
);
t
TimeStampUnion
ts
=
{
0x00
,
0x00
,
0x00
,
0x00
};
T
TimeStampUnion
ts
=
{
0x00
,
0x00
,
0x00
,
0x00
};
memcpy
(
frame
,
&
id
,
sizeof
(
uint8_t
));
memcpy
(
frame
+
sizeof
(
uint8_t
),
&
data_length
,
sizeof
(
uint8_t
));
memcpy
(
frame
+
2
*
sizeof
(
uint8_t
),
&
ts
,
sizeof
(
t
TimeStampUnion
));
memcpy
(
frame
+
2
*
sizeof
(
uint8_t
),
&
ts
,
sizeof
(
T
TimeStampUnion
));
for
(
unsigned
int
i
=
0
;
i
<
data_length
;
i
++
)
memcpy
(
frame
+
2
*
sizeof
(
uint8_t
)
+
sizeof
(
t
TimeStampUnion
),
&
data
[
i
],
sizeof
(
uint8_t
));
memcpy
(
frame
+
2
*
sizeof
(
uint8_t
)
+
sizeof
(
T
TimeStampUnion
),
&
data
[
i
],
sizeof
(
uint8_t
));
uint16_t
calculated_crc
=
fletcher16
(
frame
,
uint8_t
(
req_frame_size
));
...
...
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