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
40e6dff7
Commit
40e6dff7
authored
Mar 19, 2020
by
Rafal Babski
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
linux_serial_minimal driver improvements
parent
5cb004f4
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
24 additions
and
17 deletions
+24
-17
src/drivers/linux_serial_minimal.c
src/drivers/linux_serial_minimal.c
+24
-17
No files found.
src/drivers/linux_serial_minimal.c
View file @
40e6dff7
...
...
@@ -186,7 +186,7 @@ static void setup_termios(struct termios* tty, __po_hi_device_id id)
#define PACKET_ESCAPE_BYTE '\x1B'
// 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
in
t
msg_length
)
static
uint32_t
encode_packet
(
uint8_t
*
data
,
const
uint32_t
data_length
,
const
uint8_t
*
msg_content
,
const
uint32_
t
msg_length
)
{
if
(
msg_length
<=
8
)
{
...
...
@@ -206,7 +206,7 @@ static int encode_packet(uint8_t* data, const int data_length, const uint8_t* ms
return
0
;
}
in
t
length
=
0
;
uint32_
t
length
=
0
;
data
[
length
++
]
=
PACKET_START_BYTE
;
...
...
@@ -354,21 +354,28 @@ enum PACKET_DECODER_STATE
ESCAPE_STARTED
};
__po_hi_msg_t
__po_hi_c_driver_serial_linux_poller_msg
;
static
uint8_t
packet_decoder_buffer
[
PACKET_DECODER_BUFFER_SIZE
];
static
int
packet_decoder_index
=
0
;
static
enum
PACKET_DECODER_STATE
packet_decoder_state
;
static
void
process_packet
(
uint8_t
*
data
,
int
size
)
{
uint32_t
port
=
7
;
uint32_t
length
=
size
;
__PO_HI_DEBUG_DEBUG
(
"[LINUX SERIAL] Processing packet
\n
"
);
__po_hi_c_driver_linux_serial_minimal_request
.
port
=
(
__po_hi_local_port_t
)
7
;
__PO_HI_DEBUG_DEBUG
(
"[LINUX SERIAL] Copying data (%d bytes)
\n
"
,
size
);
memcpy
(
&
__po_hi_c_driver_linux_serial_minimal_request
.
vars
,
data
,
size
);
uint8_t
*
request_size_pointer
=
((
uint8_t
*
)
&
__po_hi_c_driver_linux_serial_minimal_request
.
vars
)
+
size
;
__PO_HI_DEBUG_DEBUG
(
"[LINUX SERIAL] Copying size (%d bytes)
\n
"
,
size
);
memcpy
(
request_size_pointer
,
&
size
,
4
);
__PO_HI_DEBUG_DEBUG
(
"[LINUX SERIAL] Packet deliver
\n
"
,
size
);
__po_hi_msg_reallocate
(
&
__po_hi_c_driver_serial_linux_poller_msg
);
memcpy
(
__po_hi_c_driver_serial_linux_poller_msg
.
content
,
&
port
,
4
);
memcpy
(
__po_hi_c_driver_serial_linux_poller_msg
.
content
+
4
,
data
,
size
);
memcpy
(
__po_hi_c_driver_serial_linux_poller_msg
.
content
+
(
__PO_HI_MESSAGES_MAX_SIZE
-
8
),
&
length
,
4
);
__po_hi_c_driver_serial_linux_poller_msg
.
length
=
__PO_HI_MESSAGES_MAX_SIZE
;
__po_hi_unmarshall_request
(
&
__po_hi_c_driver_linux_serial_minimal_request
,
&
__po_hi_c_driver_serial_linux_poller_msg
);
__PO_HI_DEBUG_DEBUG
(
"[LINUX SERIAL] Deliver to port %u
\n
"
,
__po_hi_c_driver_linux_serial_minimal_request
.
port
);
__po_hi_main_deliver
(
&
__po_hi_c_driver_linux_serial_minimal_request
);
}
...
...
@@ -471,16 +478,16 @@ int __po_hi_c_driver_linux_serial_minimal_sender (__po_hi_task_id task_id, __po
__po_hi_marshall_request
(
request
,
&
__po_hi_c_driver_linux_serial_minimal_sender_msg
);
int
msg_length
=
__po_hi_msg_length
(
&
__po_hi_c_driver_linux_serial_minimal_sender_msg
);
uint32_t
msg_length
=
(
uint32_t
)
__po_hi_msg_length
(
&
__po_hi_c_driver_linux_serial_minimal_sender_msg
);
uint8_t
*
msg_content
=
(
uint8_t
*
)
malloc
(
msg_length
);
__po_hi_msg_get_data
(
msg_content
,
&
__po_hi_c_driver_linux_serial_minimal_sender_msg
,
0
,
msg_length
);
in
t
data_length
=
msg_length
*
2
+
2
;
uint32_
t
data_length
=
msg_length
*
2
+
2
;
uint8_t
*
data
=
(
uint8_t
*
)
malloc
(
data_length
);
in
t
length
=
encode_packet
(
data
,
data_length
,
msg_content
,
msg_length
);
uint32_
t
length
=
encode_packet
(
data
,
data_length
,
msg_content
,
msg_length
);
if
(
length
>
0
)
{
...
...
@@ -489,7 +496,7 @@ int __po_hi_c_driver_linux_serial_minimal_sender (__po_hi_task_id task_id, __po
{
__PO_HI_DEBUG_DEBUG
(
" [LINUX SERIAL] write %d bytes in loop to device
\n
"
,
length
);
for
(
n
=
0
;
n
<
length
;
n
++
)
for
(
n
=
0
;
n
<
(
int
)
length
;
n
++
)
{
write
(
po_hi_c_driver_serial_fd_write
,
&
(
data
[
n
]),
1
);
usleep
(
po_hi_c_driver_serial_sending_wait
);
...
...
@@ -515,18 +522,18 @@ int __po_hi_c_driver_linux_serial_minimal_sender (__po_hi_task_id task_id, __po
{
__PO_HI_DEBUG_CRITICAL
(
" [LINUX SERIAL] failed !
\n
"
);
}
else
if
((
0
<=
n
)
&
(
n
<
length
))
else
if
((
0
<=
n
)
&
(
n
<
(
int
)
length
))
{
__PO_HI_DEBUG_CRITICAL
(
" [LINUX SERIAL] Unable write - write returned %d !
\n
"
,
n
);
}
else
{
__PO_HI_DEBUG_
DEBUG
(
" [LINUX SERIAL] OK !
\n
"
);
__PO_HI_DEBUG_
CRITICAL
(
" [LINUX SERIAL] OK !
\n
"
);
}
}
__PO_HI_DEBUG_DEBUG
(
"[LINUX SERIAL] write() returns %d, message sent: 0x"
,
n
);
__PO_HI_DEBUG_DEBUG
(
"[LINUX SERIAL] write() returns %d, message sent: 0x
\n
"
,
n
);
}
__po_hi_mutex_unlock
(
&
__po_hi_c_driver_linux_serial_minimal_send_mutex
);
...
...
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