Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
P
proview
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Esteban Blanc
proview
Commits
24129261
Commit
24129261
authored
Mar 01, 2012
by
claes
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
IO Arduino checksum fix
parent
38434254
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
10 additions
and
6 deletions
+10
-6
otherio/exp/rt/src/pwr_arduino_uno.ino
otherio/exp/rt/src/pwr_arduino_uno.ino
+9
-5
otherio/lib/rt/src/rt_io_m_arduino_uno.c
otherio/lib/rt/src/rt_io_m_arduino_uno.c
+1
-1
No files found.
otherio/exp/rt/src/pwr_arduino_uno.ino
View file @
24129261
...
@@ -101,7 +101,7 @@ void add_checksum( byte *buf)
...
@@ -101,7 +101,7 @@ void add_checksum( byte *buf)
int
check_checksum
(
byte
size
,
byte
id
,
byte
type
,
byte
*
buf
)
int
check_checksum
(
byte
size
,
byte
id
,
byte
type
,
byte
*
buf
)
{
{
int
i
;
int
i
;
unsigned
char
sum
=
0
;
byte
sum
=
0
;
sum
^=
size
;
sum
^=
size
;
sum
^=
id
;
sum
^=
id
;
...
@@ -109,7 +109,7 @@ int check_checksum( byte size, byte id, byte type, byte *buf)
...
@@ -109,7 +109,7 @@ int check_checksum( byte size, byte id, byte type, byte *buf)
for
(
i
=
0
;
i
<
size
-
4
;
i
++
)
for
(
i
=
0
;
i
<
size
-
4
;
i
++
)
sum
^=
buf
[
i
];
sum
^=
buf
[
i
];
if
(
buf
[
size
-
1
]
==
sum
)
if
(
buf
[
size
-
4
]
==
sum
)
return
1
;
return
1
;
return
0
;
return
0
;
}
}
...
@@ -135,6 +135,7 @@ void resetOutput()
...
@@ -135,6 +135,7 @@ void resetOutput()
int
serialRead
()
int
serialRead
()
{
{
int
num
;
int
num
;
int
csum
;
num
=
Serial
.
available
();
num
=
Serial
.
available
();
if
(
num
==
0
)
if
(
num
==
0
)
...
@@ -153,11 +154,10 @@ int serialRead()
...
@@ -153,11 +154,10 @@ int serialRead()
for
(
int
i
=
0
;
i
<
msgSize
;
i
++
)
for
(
int
i
=
0
;
i
<
msgSize
;
i
++
)
msgData
[
i
]
=
Serial
.
read
();
msgData
[
i
]
=
Serial
.
read
();
if
(
!
check_checksum
(
msgSize
,
msgId
,
msgType
,
msgData
))
csum
=
check_checksum
(
msgSize
+
3
,
msgId
,
msgType
,
msgData
);
return
ARD__CHECKSUM
;
if
(
debug
)
{
if
(
debug
)
{
rmsg
[
0
]
=
msgSize
-
1
+
3
;
rmsg
[
0
]
=
msgSize
+
3
-
1
;
rmsg
[
1
]
=
msgId
;
rmsg
[
1
]
=
msgId
;
rmsg
[
2
]
=
MSG_TYPE_DEBUG
;
rmsg
[
2
]
=
MSG_TYPE_DEBUG
;
for
(
int
j
=
0
;
j
<
msgSize
-
1
;
j
++
)
for
(
int
j
=
0
;
j
<
msgSize
-
1
;
j
++
)
...
@@ -165,6 +165,10 @@ int serialRead()
...
@@ -165,6 +165,10 @@ int serialRead()
add_checksum
(
rmsg
);
add_checksum
(
rmsg
);
Serial
.
write
(
rmsg
,
rmsg
[
0
]);
Serial
.
write
(
rmsg
,
rmsg
[
0
]);
}
}
msgSize
--
;
if
(
!
csum
)
return
ARD__CHECKSUM
;
return
ARD__SUCCESS
;
return
ARD__SUCCESS
;
}
}
...
...
otherio/lib/rt/src/rt_io_m_arduino_uno.c
View file @
24129261
...
@@ -300,7 +300,7 @@ static int send_connect_request( io_sLocal *local, pwr_sClass_Arduino_Uno *op, i
...
@@ -300,7 +300,7 @@ static int send_connect_request( io_sLocal *local, pwr_sClass_Arduino_Uno *op, i
sts
=
write
(
local
->
fd
,
&
msg
,
msg
.
size
);
sts
=
write
(
local
->
fd
,
&
msg
,
msg
.
size
);
sts
=
receive
(
local
->
fd
,
msg
.
id
,
&
rmsg
,
2
1
,
op
->
Timeout
,
op
);
sts
=
receive
(
local
->
fd
,
msg
.
id
,
&
rmsg
,
2
3
,
op
->
Timeout
,
op
);
if
(
sts
&
1
)
{
if
(
sts
&
1
)
{
if
(
rmsg
.
type
!=
ard_eMsgType_ConnectRes
)
if
(
rmsg
.
type
!=
ard_eMsgType_ConnectRes
)
return
IO__INITFAIL
;
return
IO__INITFAIL
;
...
...
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