Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
P
PolyORB-HI-C
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
6
Issues
6
List
Boards
Labels
Service Desk
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Operations
Operations
Incidents
Environments
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
TASTE
PolyORB-HI-C
Commits
f30d2697
Commit
f30d2697
authored
Mar 10, 2020
by
Rafal Babski
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
linux_serial_minial driver - code improvements
parent
68751956
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
15 additions
and
6 deletions
+15
-6
src/drivers/linux_serial_minimal.c
src/drivers/linux_serial_minimal.c
+15
-6
No files found.
src/drivers/linux_serial_minimal.c
View file @
f30d2697
...
...
@@ -99,6 +99,7 @@ static void setup_bit_size(struct termios* tty, __po_hi_c_serial_conf_t* serialc
}
else
{
__PO_HI_DEBUG_DEBUG
(
"Setting bit 8
\n
"
);
tty
->
c_cflag
|=
CS8
;
}
}
...
...
@@ -184,20 +185,27 @@ static void setup_termios(struct termios* tty, __po_hi_device_id id)
#define PACKET_STOP_BYTE '\x03'
#define PACKET_ESCAPE_BYTE '\x1B'
static
int
encode_packet
(
uint8_t
*
data
,
const
uint8_t
*
msg_content
,
const
int
msg_length
)
// process packet data generated by PolyORB to send it using UART
static
int
encode_packet
(
uint8_t
*
data
,
const
int
data_length
,
const
uint8_t
*
msg_content
,
const
int
msg_length
)
{
if
(
msg_length
<=
8
)
{
__PO_HI_DEBUG_DEBUG
(
"Encoding packet
Not enaugh msg_length,
%d
\n
"
,
msg_length
);
__PO_HI_DEBUG_DEBUG
(
"Encoding packet
- not enough msg_length, at least 9 bytes is required, got
%d
\n
"
,
msg_length
);
// the message is empty
return
0
;
}
// first four bytes of msg_content - port
uint8_t
*
data_ptr
=
(
uint8_t
*
)
(
msg_content
+
4
);
// skip port to access data
// first four bytes of msg_content - port
number
uint8_t
*
data_ptr
=
(
uint8_t
*
)
(
msg_content
+
4
);
// skip port
number
to access data
// last four bytes of msg_content - actual msg length
uint32_t
*
length_ptr
=
(
uint32_t
*
)(
msg_content
+
(
msg_length
-
4
));
if
(
data_length
<
*
length_ptr
*
2
+
2
)
{
__PO_HI_DEBUG_CRITICAL
(
"Encoding packet - not enough data_length, at least %d bytes is required, got %d
\n
"
,
*
length_ptr
,
data_length
);
return
0
;
}
int
length
=
0
;
data
[
length
++
]
=
PACKET_START_BYTE
;
...
...
@@ -470,8 +478,9 @@ int __po_hi_c_driver_linux_serial_minimal_sender (__po_hi_task_id task_id, __po
0
,
msg_length
);
uint8_t
*
data
=
(
uint8_t
*
)
malloc
(
msg_length
*
2
+
1
);
int
length
=
encode_packet
(
data
,
msg_content
,
msg_length
);
int
data_length
=
msg_length
*
2
+
2
;
uint8_t
*
data
=
(
uint8_t
*
)
malloc
(
data_length
);
int
length
=
encode_packet
(
data
,
data_length
,
msg_content
,
msg_length
);
if
(
length
>
0
)
{
...
...
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