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
Model registry
Analyze
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
Avionics
Software Development
Skyward Boardcore
Commits
0d57f729
Commit
0d57f729
authored
3 years ago
by
Federico Mandelli
Browse files
Options
Downloads
Patches
Plain Diff
[canbus-dev] Created test canprotocol,need testing
parent
de9a5368
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/shared/drivers/canbus/CanProtocol.h
+0
-2
0 additions, 2 deletions
src/shared/drivers/canbus/CanProtocol.h
src/tests/drivers/canbus/test-canprotocol.cpp
+92
-0
92 additions, 0 deletions
src/tests/drivers/canbus/test-canprotocol.cpp
with
92 additions
and
2 deletions
src/shared/drivers/canbus/CanProtocol.h
+
0
−
2
View file @
0d57f729
...
@@ -20,8 +20,6 @@
...
@@ -20,8 +20,6 @@
* THE SOFTWARE.
* THE SOFTWARE.
*/
*/
// this was written under the influence of redbull and ichnusa, pls do not judge
#pragma once
#pragma once
#include
<ActiveObject.h>
#include
<ActiveObject.h>
...
...
This diff is collapsed.
Click to expand it.
src/tests/drivers/canbus/test-canprotocol.cpp
0 → 100644
+
92
−
0
View file @
0d57f729
#include
<drivers/canbus/CanProtocol.h>
#include
<utils/Debug.h>
#include
"drivers/canbus/BusLoadEstimation.h"
#include
"drivers/canbus/Canbus.h"
#include
"utils/collections/CircularBuffer.h"
constexpr
uint32_t
BAUD_RATE
=
500
*
1000
;
constexpr
float
SAMPLE_POINT
=
87.5
f
/
100.0
f
;
constexpr
uint32_t
MSG_DEADLINE
=
100
;
// ms
constexpr
uint32_t
MSG_LOST_DEADLINE
=
400
;
// ms
using
std
::
string
;
using
namespace
Boardcore
;
using
namespace
Boardcore
::
Canbus
;
using
namespace
miosix
;
#ifdef _ARCH_CORTEXM3_STM32
using
CanRX
=
Gpio
<
GPIOA_BASE
,
11
>
;
using
CanTX
=
Gpio
<
GPIOA_BASE
,
12
>
;
#else
using
CanRX
=
Gpio
<
GPIOA_BASE
,
11
>
;
using
CanTX
=
Gpio
<
GPIOA_BASE
,
12
>
;
#endif
int
main
()
{
{
miosix
::
FastInterruptDisableLock
dLock
;
#ifdef _ARCH_CORTEXM3_STM32
CanRX
::
mode
(
Mode
::
ALTERNATE
);
CanTX
::
mode
(
Mode
::
ALTERNATE
);
#else
CanRX
::
mode
(
Mode
::
ALTERNATE
);
CanTX
::
mode
(
Mode
::
ALTERNATE
);
CanRX
::
alternateFunction
(
9
);
CanTX
::
alternateFunction
(
9
);
#endif
}
CanbusDriver
::
CanbusConfig
cfg
{};
CanbusDriver
::
AutoBitTiming
bt
;
bt
.
baudRate
=
BAUD_RATE
;
bt
.
samplePoint
=
SAMPLE_POINT
;
IRQCircularBuffer
<
CanData
,
NPACKET
>*
buffer
;
CanbusDriver
*
c
=
new
CanbusDriver
(
CAN1
,
cfg
,
bt
);
CanProtocol
protocol
(
c
,
buffer
);
// Allow every message
Mask32FilterBank
f2
(
0
,
0
,
0
,
0
,
0
,
0
,
0
);
c
->
addFilter
(
f2
);
c
->
init
();
protocol
.
start
();
const
int
slp
=
500
;
CanData
toSend
;
toSend
.
canId
=
0x01
;
toSend
.
len
=
3
;
toSend
.
payload
[
0
]
=
1
;
toSend
.
payload
[
1
]
=
2
;
toSend
.
payload
[
2
]
=
3
;
for
(;;)
{
protocol
.
sendCan
(
toSend
);
(
*
buffer
).
waitUntilNotEmpty
();
CanData
temp
=
(
*
buffer
).
IRQpop
();
if
(
temp
.
canId
!=
toSend
.
canId
||
temp
.
len
!=
toSend
.
len
||
temp
.
payload
[
0
]
!=
toSend
.
payload
[
0
]
||
temp
.
payload
[
1
]
!=
toSend
.
payload
[
1
]
||
temp
.
payload
[
2
]
!=
toSend
.
payload
[
2
])
{
TRACE
(
"Error
\n
"
);
TRACE
(
"Expected id %d , received %d
\n
"
,
toSend
.
canId
,
temp
.
canId
);
TRACE
(
"Expected len %d , received %d
\n
"
,
toSend
.
len
,
temp
.
len
);
TRACE
(
"Expected payload 0 %d , received %d
\n
"
,
toSend
.
payload
[
0
],
temp
.
payload
[
0
]);
TRACE
(
"Expected payload 1 %d , received %d
\n
"
,
toSend
.
payload
[
1
],
temp
.
payload
[
1
]);
TRACE
(
"Expected payload 2 %d , received %d
\n
"
,
toSend
.
payload
[
2
],
temp
.
payload
[
2
]);
}
Thread
::
sleep
(
slp
);
}
}
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