Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
Skyward Boardcore
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package registry
Container registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD 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
Giulia Facchi
Skyward Boardcore
Commits
5bb818b7
Commit
5bb818b7
authored
7 years ago
by
Alvise de'Faveri
Browse files
Options
Downloads
Patches
Plain Diff
Fixed dsgamma-test
There are still some problems on reading, and sometimes it goes in stack overflow.
parent
a4d3117d
Branches
Branches containing commit
Tags
Tags containing commit
No related merge requests found
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
src/entrypoints/dsgamma-test.cpp
+20
-22
20 additions, 22 deletions
src/entrypoints/dsgamma-test.cpp
src/shared/drivers/gamma868/Gamma868.cpp
+3
-3
3 additions, 3 deletions
src/shared/drivers/gamma868/Gamma868.cpp
with
23 additions
and
25 deletions
src/entrypoints/dsgamma-test.cpp
+
20
−
22
View file @
5bb818b7
...
@@ -31,7 +31,7 @@
...
@@ -31,7 +31,7 @@
using
namespace
std
;
using
namespace
std
;
using
namespace
miosix
;
using
namespace
miosix
;
#define
MSG
_LEN
6
#define
PKT
_LEN
24
typedef
Gpio
<
GPIOG_BASE
,
13
>
greenLed
;
typedef
Gpio
<
GPIOG_BASE
,
13
>
greenLed
;
typedef
Gpio
<
GPIOG_BASE
,
14
>
redLed
;
typedef
Gpio
<
GPIOG_BASE
,
14
>
redLed
;
...
@@ -44,8 +44,8 @@ long long sendTime = 0;
...
@@ -44,8 +44,8 @@ long long sendTime = 0;
int
nTentativi
=
0
;
int
nTentativi
=
0
;
int
tot
=
0
;
int
tot
=
0
;
void
sender
();
void
sender
(
void
*
arg
);
void
receiver
(
void
*
arg
);
void
receiver
();
int
main
()
{
int
main
()
{
//Discovery gpio setup
//Discovery gpio setup
...
@@ -56,14 +56,15 @@ int main() {
...
@@ -56,14 +56,15 @@ int main() {
button
::
mode
(
Mode
::
INPUT
);
button
::
mode
(
Mode
::
INPUT
);
}
}
sender
();
Thread
::
create
(
sender
,
STACK_MIN
);
receiver
();
return
0
;
return
0
;
}
}
void
sender
(){
void
sender
(
void
*
arg
){
while
(
1
){
while
(
1
){
while
(
1
){
while
(
1
){
...
@@ -72,15 +73,13 @@ void sender(){
...
@@ -72,15 +73,13 @@ void sender(){
printf
(
"Writing...
\n
"
);
printf
(
"Writing...
\n
"
);
nTentativi
++
;
char
msg
[
PKT_LEN
];
if
(
nTentativi
==
1
)
Thread
::
create
(
receiver
,
STACK_MIN
);
for
(
int
i
=
0
;
i
<
PKT_LEN
;
i
++
){
char
msg
[
MSG_LEN
];
for
(
int
i
=
0
;
i
<
nTentativi
;
i
++
){
msg
[
i
]
=
'#'
;
msg
[
i
]
=
'#'
;
}
}
sendTime
=
miosix
::
getTick
();
sendTime
=
miosix
::
getTick
();
nTentativi
++
;
gamma
.
send
(
msg
);
gamma
.
send
(
msg
);
printf
(
"Ok
\n
"
);
printf
(
"Ok
\n
"
);
...
@@ -88,15 +87,16 @@ void sender(){
...
@@ -88,15 +87,16 @@ void sender(){
}
}
}
}
void
receiver
(
void
*
arg
){
void
receiver
(){
while
(
1
){
while
(
1
){
//read
//read
char
inputBuf
[
MSG_LEN
];
// int len = 1; // SENDER ONLY
int
len
=
PKT_LEN
;
char
inputBuf
[
len
];
printf
(
"Reading:
\n
"
);
printf
(
"Reading:
\n
"
);
gamma
.
receive
(
MSG_LEN
,
inputBuf
);
gamma
.
receive
(
len
,
inputBuf
);
for
(
int
i
=
0
;
i
<
MSG_LEN
;
i
++
){
for
(
int
i
=
0
;
i
<
len
;
i
++
){
printf
(
"Received: %c
\n
"
,
inputBuf
[
i
]);
printf
(
"Received: %c
\n
"
,
inputBuf
[
i
]);
}
}
...
@@ -106,15 +106,13 @@ void receiver(void *arg){
...
@@ -106,15 +106,13 @@ void receiver(void *arg){
printf
(
"--------------RESULT------------"
);
printf
(
"--------------RESULT------------"
);
tot
+=
rtt
;
tot
+=
rtt
;
if
(
nTentativi
>
0
)
printf
(
"Tentativi: %d Media: %d
\n
"
,
nTentativi
,
tot
/
(
2
*
nTentativi
));
printf
(
"Tentativi: %d Media: %d
\n
"
,
nTentativi
,
tot
/
(
2
*
nTentativi
));
// RECEIVER ONLY
// RECEIVER ONLY
//
Thread::sleep(
5
0);
Thread
::
sleep
(
20
0
);
//
gamma.send(inputBuf);
gamma
.
send
(
inputBuf
);
//Thread::sleep(
2
00);
//Thread::sleep(
10
00);
}
}
}
}
\ No newline at end of file
This diff is collapsed.
Click to expand it.
src/shared/drivers/gamma868/Gamma868.cpp
+
3
−
3
View file @
5bb818b7
...
@@ -54,10 +54,10 @@ bool Gamma868::send(const char *msg)
...
@@ -54,10 +54,10 @@ bool Gamma868::send(const char *msg)
bool
Gamma868
::
receive
(
int
bufLen
,
char
*
buf
)
bool
Gamma868
::
receive
(
int
bufLen
,
char
*
buf
)
{
{
//TODO synchronize
//TODO synchronize
char
received
[
bufLen
+
2
];
char
received
[
bufLen
+
1
];
read
(
fd
,
&
received
,
bufLen
+
2
);
read
(
fd
,
&
received
,
bufLen
+
1
);
for
(
int
i
=
0
;
bufLen
<
bufLen
;
i
++
){
for
(
int
i
=
0
;
i
<
bufLen
;
i
++
){
buf
[
i
]
=
received
[
i
];
buf
[
i
]
=
received
[
i
];
}
}
return
true
;
return
true
;
...
...
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