Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
Caco
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
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
Vytor Calixto
Caco
Commits
f56cc998
Commit
f56cc998
authored
9 years ago
by
Vytor Calixto
Browse files
Options
Downloads
Patches
Plain Diff
Added parity check and calc
parent
7b37afdd
No related branches found
No related tags found
1 merge request
!1
Lento
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
Protocol.cpp
+21
-2
21 additions, 2 deletions
Protocol.cpp
Protocol.h
+4
-1
4 additions, 1 deletion
Protocol.h
with
25 additions
and
3 deletions
Protocol.cpp
+
21
−
2
View file @
f56cc998
...
...
@@ -9,6 +9,25 @@ void Protocol::setMessage(Message message){
this
->
message
=
message
;
}
bool
Protocol
::
send
(
int
socket
)
{
return
true
;
}
char
Protocol
::
calcParity
()
{
char
parity
=
0x00
;
char
*
m
=
this
->
message
.
c_ctrl
.
begin
+
this
->
message
.
c_ctrl
.
size
+
this
->
message
.
c_ctrl
.
seqType
+
(
&
data
[
0
]);
for
(
int
i
=
0
;
i
<
strlen
(
m
);
++
i
)
{
parity
=
parity
^
m
[
i
];
}
this
->
message
.
c_ctrl
.
parity
=
parity
;
return
parity
;
}
bool
Protocol
::
checkParity
()
{
char
parity
=
this
->
calcParity
();
return
(
parity
==
this
->
message
.
c_ctrl
.
parity
);
}
Protocol
::
Protocol
(){
message
.
begin
=
0x7E
;
this
->
message
.
c_ctrl
.
begin
=
0x7E
;
}
This diff is collapsed.
Click to expand it.
Protocol.h
+
4
−
1
View file @
f56cc998
...
...
@@ -11,6 +11,9 @@ public:
Message
getMessage
();
void
setMessage
(
Message
message
);
bool
send
(
int
socket
);
char
calcParity
();
bool
checkParity
();
Protocol
();
};
...
...
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