Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
H
HR_Socket_Msg_Demo
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
马伊齐
HR_Socket_Msg_Demo
Commits
ac54686b
Commit
ac54686b
authored
Dec 20, 2023
by
马伊齐
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
本地发送接收Demo
parent
e404ac1a
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
7 additions
and
4 deletions
+7
-4
MsgLocalClient.c
msg_local_send_recv/MsgLocalClient.c
+3
-2
MsgLocalServer.c
msg_local_send_recv/MsgLocalServer.c
+4
-2
No files found.
msg_local_send_recv/MsgLocalClient.c
View file @
ac54686b
...
...
@@ -19,13 +19,14 @@ int main(int argc, char *argv[])
while
(
fgets
(
buffer
,
sizeof
(
buffer
),
stdin
)
!=
NULL
)
{
if
(
msg_local_send
(
MSG_CAN_HEARTBEAT
,
0
,
(
void
*
)
buffer
,
strlen
(
buffer
))
==
-
1
)
buffer
[
strlen
(
buffer
)
-
1
]
=
'\0'
;
if
(
msg_local_send
(
MSG_CAN_OD
,
0
,
(
void
*
)
buffer
,
(
strlen
(
buffer
)
+
1
))
==
-
1
)
{
destroy_msg_queue
();
exit
(
EXIT_FAILURE
);
}
// 清空buffer
memset
(
buffer
,
0
,
sizeof
(
buffer
)
);
memset
(
buffer
,
0
,
BUFFER_SIZE
);
}
// 清理消息队列
...
...
msg_local_send_recv/MsgLocalServer.c
View file @
ac54686b
...
...
@@ -17,6 +17,8 @@ int main(int argc, char *argv[])
exit
(
EXIT_FAILURE
);
}
printf
(
"Server is running...
\n
"
);
while
(
1
)
{
if
(
msg_local_recv
(
&
msg
)
>
0
)
...
...
@@ -24,9 +26,9 @@ int main(int argc, char *argv[])
printf
(
"Received code: %d
\n
"
,
msg
.
code
);
printf
(
"Received type: %d
\n
"
,
msg
.
type
);
printf
(
"Received len: %d
\n
"
,
msg
.
len
);
printf
(
"Received pad: %s
\n
"
,
(
char
*
)(
msg
.
pad
));
printf
(
"Received pad: %s
\n
\n
"
,
(
char
*
)(
msg
.
pad
));
// 清空pad
memset
(
msg
.
pad
,
0
,
msg
.
len
);
memset
(
msg
.
pad
,
0
,
BUFFER_SIZE
);
}
else
{
...
...
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