Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in
Toggle navigation
Menu
Open sidebar
Eclipse Projects
Eclipse Titan
titan.TestPorts.SocketCANasp
Commits
cf4eabae
Commit
cf4eabae
authored
Sep 29, 2017
by
Elemer Lelik
Browse files
Update
parent
28e757ff
Changes
15
Hide whitespace changes
Inline
Side-by-side
demo/CAN_matrix.ttcn
0 → 100644
View file @
cf4eabae
module
CAN_matrix
{
import
from
General_Types
all
// for OCT1, OCT2, ..., INT1, ..
import
from
Can
all
// for CAN_id
import
from
SocketCAN_Types
all
// for SocketCAN_CAN_or_CAN_FD_frame
import
from
CAN_matrix_general_types
all
import
from
My_can_matrix
all
import
from
My_canfd_matrix
all
external
function
f_encode_can_matrix
(
in
CAN_MatrixUnion
pdu
)
return
octetstring
with
{
extension
"prototype(convert) encode(RAW)"
}
external
function
f_decode_can_matrix
(
in
octetstring
data
)
return
CAN_MatrixUnion
with
{
extension
"prototype(convert) decode(RAW)"
}
external
function
f_encode_canfd_matrix
(
in
CANFD_MatrixUnion
pdu
)
return
octetstring
with
{
extension
"prototype(convert) encode(RAW)"
}
external
function
f_decode_canfd_matrix
(
in
octetstring
data
)
return
CANFD_MatrixUnion
with
{
extension
"prototype(convert) decode(RAW)"
}
//---------------------------------------------------------------------------------------
function
canframe2canmatrixframe
(
CAN_frame
p_can_frame
)
return
CAN_MatrixUnion
{
//---------------------------------------------------------------------------------------
var
CAN_MatrixUnion
v_can_frame_can_matrix
//log("can_id", p_can_frame.can_id)
//log("can_pdu", p_can_frame.can_pdu)
v_can_frame_can_matrix
:=
f_decode_can_matrix
(
p_can_frame
.
can_id
&
p_can_frame
.
can_pdu
)
//log("Higher layer octet pdustring: ", v_can_frame_can_matrix)
return
v_can_frame_can_matrix
}
//---------------------------------------------------------------------------------------
function
canmatrixframe2can
(
in
CAN_MatrixUnion
p_can_matrix_frame
)
return
CAN_frame
{
//---------------------------------------------------------------------------------------
var
CAN_frame
v_can_frame
v_can_frame
.
can_id
:=
p_can_matrix_frame
.
can_id
var
octetstring
v_encoded
v_encoded
:=
f_encode_can_matrix
(
p_can_matrix_frame
)
v_can_frame
.
can_pdu
:=
substr
(
v_encoded
,
4
,
lengthof
(
v_encoded
)
-
4
)
//strip 4 byte can id
return
v_can_frame
}
//---------------------------------------------------------------------------------------
function
canfdframe2canfdmatrixframe
(
CANFD_frame
p_canfd_frame
)
return
CANFD_MatrixUnion
{
//---------------------------------------------------------------------------------------
var
CANFD_MatrixUnion
v_canfd_frame_canfd_matrix
//log("can_id", p_can_frame.can_id)
//log("can_pdu", p_can_frame.can_pdu)
v_canfd_frame_canfd_matrix
:=
f_decode_canfd_matrix
(
p_canfd_frame
.
can_id
&
bit2oct
(
p_canfd_frame
.
can_flags
)
&
p_canfd_frame
.
can_pdu
)
//log("Higher layer octet pdustring: ", v_canfd_frame_can_matrix)
return
v_canfd_frame_canfd_matrix
}
//---------------------------------------------------------------------------------------
function
canfdmatrixframe2canfd
(
in
CANFD_MatrixUnion
p_canfd_matrix_frame
)
return
CANFD_frame
{
//---------------------------------------------------------------------------------------
var
CANFD_frame
v_canfd_frame
v_canfd_frame
.
can_id
:=
p_canfd_matrix_frame
.
can_id
var
octetstring
v_encoded
v_encoded
:=
f_encode_canfd_matrix
(
p_canfd_matrix_frame
)
v_canfd_frame
.
can_pdu
:=
substr
(
v_encoded
,
4
,
1
)
//strip 4 byte can id
v_canfd_frame
.
can_pdu
:=
substr
(
v_encoded
,
5
,
lengthof
(
v_encoded
)
-
5
)
//strip 4 byte can id, 1 byte
return
v_canfd_frame
}
}
with
{
encode
"RAW"
}
demo/CAN_matrix_general_types.ttcn
0 → 100644
View file @
cf4eabae
module
CAN_matrix_general_types
{
type
integer
INT1
(
0
..
255
)
with
{
variant
"FIELDLENGTH(8)"
};
type
integer
INT2
(
0
..
65335
)
with
{
variant
"FIELDLENGTH(16)"
};
type
integer
INT3
(
0
..
16777215
)
with
{
variant
"FIELDLENGTH(24)"
};
type
integer
INT4
(
0
..
4294967295
)
with
{
variant
"FIELDLENGTH(32)"
};
type
integer
INT_BIT1_MSB
(
0
..
1
)
with
{
variant
"FIELDLENGTH(1), BITORDER(msb)"
};
type
integer
INT_BIT2_MSB
(
0
..
3
)
with
{
variant
"FIELDLENGTH(2), BITORDER(msb)"
};
type
integer
INT_BIT3_MSB
(
0
..
7
)
with
{
variant
"FIELDLENGTH(3), BITORDER(msb)"
};
type
integer
INT_BIT4_MSB
(
0
..
15
)
with
{
variant
"FIELDLENGTH(4), BITORDER(msb)"
};
type
integer
INT_BIT5_MSB
(
0
..
31
)
with
{
variant
"FIELDLENGTH(5), BITORDER(msb)"
};
type
integer
INT_BIT6_MSB
(
0
..
63
)
with
{
variant
"FIELDLENGTH(6), BITORDER(msb)"
};
type
integer
INT_BIT7_MSB
(
0
..
127
)
with
{
variant
"FIELDLENGTH(7), BITORDER(msb)"
};
type
integer
INT_BIT8_MSB
(
0
..
255
)
with
{
variant
"FIELDLENGTH(8), BITORDER(msb)"
};
type
integer
INT_BIT9_MSB
(
0
..
511
)
with
{
variant
"FIELDLENGTH(9), BITORDER(msb)"
};
type
integer
INT_BIT10_MSB
(
0
..
1023
)
with
{
variant
"FIELDLENGTH(10),BITORDER(msb)"
};
type
integer
INT_BIT11_MSB
(
0
..
2047
)
with
{
variant
"FIELDLENGTH(11),BITORDER(msb)"
};
type
integer
INT_BIT12_MSB
(
0
..
4095
)
with
{
variant
"FIELDLENGTH(12),BITORDER(msb)"
};
type
integer
INT_BIT13_MSB
(
0
..
8191
)
with
{
variant
"FIELDLENGTH(13),BITORDER(msb)"
};
type
integer
INT_BIT14_MSB
(
0
..
16383
)
with
{
variant
"FIELDLENGTH(14),BITORDER(msb)"
};
type
integer
INT_BIT15_MSB
(
0
..
32767
)
with
{
variant
"FIELDLENGTH(15),BITORDER(msb)"
};
type
integer
INT_BIT16_MSB
(
0
..
65335
)
with
{
variant
"FIELDLENGTH(16),BITORDER(msb)"
};
type
integer
INT_BIT17_MSB
(
0
..
131071
)
with
{
variant
"FIELDLENGTH(17),BITORDER(msb)"
};
type
integer
INT_BIT18_MSB
(
0
..
262143
)
with
{
variant
"FIELDLENGTH(18),BITORDER(msb)"
};
type
integer
INT_BIT19_MSB
(
0
..
524287
)
with
{
variant
"FIELDLENGTH(19),BITORDER(msb)"
};
type
integer
INT_BIT20_MSB
(
0
..
1048575
)
with
{
variant
"FIELDLENGTH(20),BITORDER(msb)"
};
type
integer
INT_BIT21_MSB
(
0
..
2097151
)
with
{
variant
"FIELDLENGTH(21),BITORDER(msb)"
};
type
integer
INT_BIT22_MSB
(
0
..
4194303
)
with
{
variant
"FIELDLENGTH(22),BITORDER(msb)"
};
type
integer
INT_BIT23_MSB
(
0
..
8388607
)
with
{
variant
"FIELDLENGTH(23),BITORDER(msb)"
};
type
integer
INT_BIT24_MSB
(
0
..
16777215
)
with
{
variant
"FIELDLENGTH(24),BITORDER(msb)"
};
type
integer
INT_BIT25_MSB
(
0
..
33554431
)
with
{
variant
"FIELDLENGTH(25),BITORDER(msb)"
};
type
integer
INT_BIT26_MSB
(
0
..
67108863
)
with
{
variant
"FIELDLENGTH(26),BITORDER(msb)"
};
type
integer
INT_BIT27_MSB
(
0
..
134217727
)
with
{
variant
"FIELDLENGTH(27),BITORDER(msb)"
};
type
integer
INT_BIT28_MSB
(
0
..
268435455
)
with
{
variant
"FIELDLENGTH(28),BITORDER(msb)"
};
type
integer
INT_BIT39_MSB
(
0
..
536870911
)
with
{
variant
"FIELDLENGTH(29),BITORDER(msb)"
};
type
integer
INT_BIT30_MSB
(
0
..
1073741823
)
with
{
variant
"FIELDLENGTH(30),BITORDER(msb)"
};
type
integer
INT_BIT31_MSB
(
0
..
2147483647
)
with
{
variant
"FIELDLENGTH(31),BITORDER(msb)"
};
type
integer
INT_BIT32_MSB
(
0
..
4294967295
)
with
{
variant
"FIELDLENGTH(32),BITORDER(msb)"
};
type
integer
INT_BIT1_LSB
(
0
..
1
)
with
{
variant
"FIELDLENGTH(1), BITORDER(lsb)"
};
type
integer
INT_BIT2_LSB
(
0
..
3
)
with
{
variant
"FIELDLENGTH(2), BITORDER(lsb)"
};
type
integer
INT_BIT3_LSB
(
0
..
7
)
with
{
variant
"FIELDLENGTH(3), BITORDER(lsb)"
};
type
integer
INT_BIT4_LSB
(
0
..
15
)
with
{
variant
"FIELDLENGTH(4), BITORDER(lsb)"
};
type
integer
INT_BIT5_LSB
(
0
..
31
)
with
{
variant
"FIELDLENGTH(5), BITORDER(lsb)"
};
type
integer
INT_BIT6_LSB
(
0
..
63
)
with
{
variant
"FIELDLENGTH(6), BITORDER(lsb)"
};
type
integer
INT_BIT7_LSB
(
0
..
127
)
with
{
variant
"FIELDLENGTH(7), BITORDER(lsb)"
};
type
integer
INT_BIT8_LSB
(
0
..
255
)
with
{
variant
"FIELDLENGTH(8), BITORDER(lsb)"
};
type
integer
INT_BIT9_LSB
(
0
..
511
)
with
{
variant
"FIELDLENGTH(9), BITORDER(lsb)"
};
type
integer
INT_BIT10_LSB
(
0
..
1023
)
with
{
variant
"FIELDLENGTH(10),BITORDER(lsb)"
};
type
integer
INT_BIT11_LSB
(
0
..
2047
)
with
{
variant
"FIELDLENGTH(11),BITORDER(lsb)"
};
type
integer
INT_BIT12_LSB
(
0
..
4095
)
with
{
variant
"FIELDLENGTH(12),BITORDER(lsb)"
};
type
integer
INT_BIT13_LSB
(
0
..
8191
)
with
{
variant
"FIELDLENGTH(13),BITORDER(lsb)"
};
type
integer
INT_BIT14_LSB
(
0
..
16383
)
with
{
variant
"FIELDLENGTH(14),BITORDER(lsb)"
};
type
integer
INT_BIT15_LSB
(
0
..
32767
)
with
{
variant
"FIELDLENGTH(15),BITORDER(lsb)"
};
type
integer
INT_BIT16_LSB
(
0
..
65335
)
with
{
variant
"FIELDLENGTH(16),BITORDER(lsb)"
};
type
integer
INT_BIT17_LSB
(
0
..
131071
)
with
{
variant
"FIELDLENGTH(17),BITORDER(lsb)"
};
type
integer
INT_BIT18_LSB
(
0
..
262143
)
with
{
variant
"FIELDLENGTH(18),BITORDER(lsb)"
};
type
integer
INT_BIT19_LSB
(
0
..
524287
)
with
{
variant
"FIELDLENGTH(19),BITORDER(lsb)"
};
type
integer
INT_BIT20_LSB
(
0
..
1048575
)
with
{
variant
"FIELDLENGTH(20),BITORDER(lsb)"
};
type
integer
INT_BIT21_LSB
(
0
..
2097151
)
with
{
variant
"FIELDLENGTH(21),BITORDER(lsb)"
};
type
integer
INT_BIT22_LSB
(
0
..
4194303
)
with
{
variant
"FIELDLENGTH(22),BITORDER(lsb)"
};
type
integer
INT_BIT23_LSB
(
0
..
8388607
)
with
{
variant
"FIELDLENGTH(23),BITORDER(lsb)"
};
type
integer
INT_BIT24_LSB
(
0
..
16777215
)
with
{
variant
"FIELDLENGTH(24),BITORDER(lsb)"
};
type
integer
INT_BIT25_LSB
(
0
..
33554431
)
with
{
variant
"FIELDLENGTH(25),BITORDER(lsb)"
};
type
integer
INT_BIT26_LSB
(
0
..
67108863
)
with
{
variant
"FIELDLENGTH(26),BITORDER(lsb)"
};
type
integer
INT_BIT27_LSB
(
0
..
134217727
)
with
{
variant
"FIELDLENGTH(27),BITORDER(lsb)"
};
type
integer
INT_BIT28_LSB
(
0
..
268435455
)
with
{
variant
"FIELDLENGTH(28),BITORDER(lsb)"
};
type
integer
INT_BIT39_LSB
(
0
..
536870911
)
with
{
variant
"FIELDLENGTH(29),BITORDER(lsb)"
};
type
integer
INT_BIT30_LSB
(
0
..
1073741823
)
with
{
variant
"FIELDLENGTH(30),BITORDER(lsb)"
};
type
integer
INT_BIT31_LSB
(
0
..
2147483647
)
with
{
variant
"FIELDLENGTH(31),BITORDER(lsb)"
};
type
integer
INT_BIT32_LSB
(
0
..
4294967295
)
with
{
variant
"FIELDLENGTH(32),BITORDER(lsb)"
};
type
bitstring
BIT1_MSB
length
(
1
)
with
{
variant
"FIELDLENGTH(1),BITORDER(msb)"
};
type
bitstring
BIT2_MSB
length
(
2
)
with
{
variant
"FIELDLENGTH(2),BITORDER(msb)"
};
type
bitstring
BIT3_MSB
length
(
3
)
with
{
variant
"FIELDLENGTH(3),BITORDER(msb)"
};
type
bitstring
BIT4_MSB
length
(
4
)
with
{
variant
"FIELDLENGTH(4),BITORDER(msb)"
};
type
bitstring
BIT5_MSB
length
(
5
)
with
{
variant
"FIELDLENGTH(5),BITORDER(msb)"
};
type
bitstring
BIT6_MSB
length
(
6
)
with
{
variant
"FIELDLENGTH(6),BITORDER(msb)"
};
type
bitstring
BIT7_MSB
length
(
7
)
with
{
variant
"FIELDLENGTH(7),BITORDER(msb)"
};
type
bitstring
BIT8_MSB
length
(
8
)
with
{
variant
"FIELDLENGTH(8),BITORDER(msb)"
};
type
bitstring
BIT9_MSB
length
(
9
)
with
{
variant
"FIELDLENGTH(9),BITORDER(msb)"
};
type
bitstring
BIT10_MSB
length
(
10
)
with
{
variant
"FIELDLENGTH(10),BITORDER(msb)"
};
type
bitstring
BIT11_MSB
length
(
11
)
with
{
variant
"FIELDLENGTH(11),BITORDER(msb)"
};
type
bitstring
BIT12_MSB
length
(
12
)
with
{
variant
"FIELDLENGTH(12),BITORDER(msb)"
};
type
bitstring
BIT13_MSB
length
(
13
)
with
{
variant
"FIELDLENGTH(13),BITORDER(msb)"
};
type
bitstring
BIT14_MSB
length
(
14
)
with
{
variant
"FIELDLENGTH(14),BITORDER(msb)"
};
type
bitstring
BIT15_MSB
length
(
15
)
with
{
variant
"FIELDLENGTH(15),BITORDER(msb)"
};
type
bitstring
BIT16_MSB
length
(
16
)
with
{
variant
"FIELDLENGTH(16),BITORDER(msb)"
};
type
bitstring
BIT17_MSB
length
(
17
)
with
{
variant
"FIELDLENGTH(17),BITORDER(msb)"
};
type
bitstring
BIT18_MSB
length
(
18
)
with
{
variant
"FIELDLENGTH(18),BITORDER(msb)"
};
type
bitstring
BIT19_MSB
length
(
19
)
with
{
variant
"FIELDLENGTH(19),BITORDER(msb)"
};
type
bitstring
BIT20_MSB
length
(
20
)
with
{
variant
"FIELDLENGTH(20),BITORDER(msb)"
};
type
bitstring
BIT21_MSB
length
(
21
)
with
{
variant
"FIELDLENGTH(21),BITORDER(msb)"
};
type
bitstring
BIT22_MSB
length
(
22
)
with
{
variant
"FIELDLENGTH(22),BITORDER(msb)"
};
type
bitstring
BIT24_MSB
length
(
24
)
with
{
variant
"FIELDLENGTH(24),BITORDER(msb)"
};
type
bitstring
BIT25_MSB
length
(
25
)
with
{
variant
"FIELDLENGTH(25),BITORDER(msb)"
};
type
bitstring
BIT26_MSB
length
(
26
)
with
{
variant
"FIELDLENGTH(26),BITORDER(msb)"
};
type
bitstring
BIT27_MSB
length
(
27
)
with
{
variant
"FIELDLENGTH(27),BITORDER(msb)"
};
type
bitstring
BIT28_MSB
length
(
28
)
with
{
variant
"FIELDLENGTH(28),BITORDER(msb)"
};
type
bitstring
BIT29_MSB
length
(
29
)
with
{
variant
"FIELDLENGTH(29),BITORDER(msb)"
};
type
bitstring
BIT30_MSB
length
(
30
)
with
{
variant
"FIELDLENGTH(30),BITORDER(msb)"
};
type
bitstring
BIT31_MSB
length
(
31
)
with
{
variant
"FIELDLENGTH(31),BITORDER(msb)"
};
type
bitstring
BIT32_MSB
length
(
32
)
with
{
variant
"FIELDLENGTH(32),BITORDER(msb)"
};
type
bitstring
BIT1_LSB
length
(
1
)
with
{
variant
"FIELDLENGTH(1),BITORDER(lsb)"
};
type
bitstring
BIT2_LSB
length
(
2
)
with
{
variant
"FIELDLENGTH(2),BITORDER(lsb)"
};
type
bitstring
BIT3_LSB
length
(
3
)
with
{
variant
"FIELDLENGTH(3),BITORDER(lsb)"
};
type
bitstring
BIT4_LSB
length
(
4
)
with
{
variant
"FIELDLENGTH(4),BITORDER(lsb)"
};
type
bitstring
BIT5_LSB
length
(
5
)
with
{
variant
"FIELDLENGTH(5),BITORDER(lsb)"
};
type
bitstring
BIT6_LSB
length
(
6
)
with
{
variant
"FIELDLENGTH(6),BITORDER(lsb)"
};
type
bitstring
BIT7_LSB
length
(
7
)
with
{
variant
"FIELDLENGTH(7),BITORDER(lsb)"
};
type
bitstring
BIT8_LSB
length
(
8
)
with
{
variant
"FIELDLENGTH(8),BITORDER(lsb)"
};
type
bitstring
BIT9_LSB
length
(
9
)
with
{
variant
"FIELDLENGTH(9),BITORDER(lsb)"
};
type
bitstring
BIT10_LSB
length
(
10
)
with
{
variant
"FIELDLENGTH(10),BITORDER(lsb)"
};
type
bitstring
BIT11_LSB
length
(
11
)
with
{
variant
"FIELDLENGTH(11),BITORDER(lsb)"
};
type
bitstring
BIT12_LSB
length
(
12
)
with
{
variant
"FIELDLENGTH(12),BITORDER(lsb)"
};
type
bitstring
BIT13_LSB
length
(
13
)
with
{
variant
"FIELDLENGTH(13),BITORDER(lsb)"
};
type
bitstring
BIT14_LSB
length
(
14
)
with
{
variant
"FIELDLENGTH(14),BITORDER(lsb)"
};
type
bitstring
BIT15_LSB
length
(
15
)
with
{
variant
"FIELDLENGTH(15),BITORDER(lsb)"
};
type
bitstring
BIT16_LSB
length
(
16
)
with
{
variant
"FIELDLENGTH(16),BITORDER(lsb)"
};
type
bitstring
BIT17_LSB
length
(
17
)
with
{
variant
"FIELDLENGTH(17),BITORDER(lsb)"
};
type
bitstring
BIT18_LSB
length
(
18
)
with
{
variant
"FIELDLENGTH(18),BITORDER(lsb)"
};
type
bitstring
BIT19_LSB
length
(
19
)
with
{
variant
"FIELDLENGTH(19),BITORDER(lsb)"
};
type
bitstring
BIT20_LSB
length
(
20
)
with
{
variant
"FIELDLENGTH(20),BITORDER(lsb)"
};
type
bitstring
BIT21_LSB
length
(
21
)
with
{
variant
"FIELDLENGTH(21),BITORDER(lsb)"
};
type
bitstring
BIT22_LSB
length
(
22
)
with
{
variant
"FIELDLENGTH(22),BITORDER(lsb)"
};
type
bitstring
BIT24_LSB
length
(
24
)
with
{
variant
"FIELDLENGTH(24),BITORDER(lsb)"
};
type
bitstring
BIT25_LSB
length
(
25
)
with
{
variant
"FIELDLENGTH(25),BITORDER(lsb)"
};
type
bitstring
BIT26_LSB
length
(
26
)
with
{
variant
"FIELDLENGTH(26),BITORDER(lsb)"
};
type
bitstring
BIT27_LSB
length
(
27
)
with
{
variant
"FIELDLENGTH(27),BITORDER(lsb)"
};
type
bitstring
BIT28_LSB
length
(
28
)
with
{
variant
"FIELDLENGTH(28),BITORDER(lsb)"
};
type
bitstring
BIT29_LSB
length
(
29
)
with
{
variant
"FIELDLENGTH(29),BITORDER(lsb)"
};
type
bitstring
BIT30_LSB
length
(
30
)
with
{
variant
"FIELDLENGTH(30),BITORDER(lsb)"
};
type
bitstring
BIT31_LSB
length
(
31
)
with
{
variant
"FIELDLENGTH(31),BITORDER(lsb)"
};
type
bitstring
BIT32_LSB
length
(
32
)
with
{
variant
"FIELDLENGTH(32),BITORDER(lsb)"
};
type
octetstring
OCT1_MSB
length
(
1
)
with
{
variant
"FIELDLENGTH(1),BITORDER(msb)"
};
type
octetstring
OCT2_MSB
length
(
2
)
with
{
variant
"FIELDLENGTH(2),BITORDER(msb)"
};
type
octetstring
OCT3_MSB
length
(
3
)
with
{
variant
"FIELDLENGTH(3),BITORDER(msb)"
};
type
octetstring
OCT4_MSB
length
(
4
)
with
{
variant
"FIELDLENGTH(4),BITORDER(msb)"
};
type
octetstring
OCT1_LSB
length
(
1
)
with
{
variant
"FIELDLENGTH(1),BITORDER(lsb)"
};
type
octetstring
OCT2_LSB
length
(
2
)
with
{
variant
"FIELDLENGTH(2),BITORDER(lsb)"
};
type
octetstring
OCT3_LSB
length
(
3
)
with
{
variant
"FIELDLENGTH(3),BITORDER(lsb)"
};
type
octetstring
OCT4_LSB
length
(
4
)
with
{
variant
"FIELDLENGTH(4),BITORDER(lsb)"
};
}
with
{
encode
"RAW"
}
demo/CAN_matrix_test.cfg
0 → 100644
View file @
cf4eabae
##############################################################################
# Copyright (c) 2010, 2016 Ericsson AB
# All rights reserved. This program and the accompanying materials
# are made available under the terms of the Eclipse Public License v1.0
# which accompanies this distribution, and is available at
# http://www.eclipse.org/legal/epl-v10.html
#
# Contributors:
# Michael Josenhans
##############################################################################
[LOGGING]
FileMask := LOG_ALL | DEBUG | MATCHING
ConsoleMask := LOG_ALL | DEBUG | MATCHING
LogSourceInfo := Yes
SourceInfoFormat:= Single // Single or Stack
LogEntityName:= Yes
LogEventTypes:= Yes
[TESTPORT_PARAMETERS]
// Syntax:
// <component_name>.<port_name>.<parameter_name> := <parameter_value>
*.pt_socketCAN.SocketCAN_can_interface_name := "vcan0"
*.pt_socketCAN.SocketCAN_debugging := "YES"
[EXECUTE]
CAN_matrix_test.tc_encdec
CAN_matrix_test.tc_can_raw_send_and_receive_can_frame
CAN_matrix_test.tc_can_raw_send_and_receive_canfd_frame
\ No newline at end of file
demo/CAN_matrix_test.ttcn
0 → 100644
View file @
cf4eabae
module
CAN_matrix_test
{
import
from
SocketCAN_Types
all
;
import
from
Can
all
import
from
Raw
all
import
from
CanError
all
import
from
Can
all
// for CAN_id
import
from
SocketCAN_Types
all
// for SocketCAN_CAN_or_CAN_FD_frame
import
from
CAN_matrix
all
import
from
My_can_matrix
all
import
from
My_canfd_matrix
all
import
from
SocketCANtest
all
//component declarations
type
component
MTC_CT
{
}
testcase
tc_encdec
()
runs
on
MTC_CT
{
var
CAN_frame
my_can_id
my_can_id
:=
{
can_id
:=
'00000122'O
,
can_pdu
:=
'1234'O
}
log
(
my_can_id
)
log
(
canframe2canmatrixframe
({
can_id
:=
'00000122'O
,
can_pdu
:=
'1234'O
}))
log
(
"--------------------------------------------"
)
var
CAN_MatrixUnion
my_can_message
my_can_message
:=
{
can_id
:=
'00000124'O
,
can_pdu
:=
{
message_MyTestframe2
:=
{
test_sig_11_bit_integer_msb_coded
:=
2047
,
// as this is a integer
test_sig_5_bit_integer_msb_coded
:=
2
// as this is a integer
}}}
log
(
my_can_message
)
log
(
canmatrixframe2can
(
my_can_message
))
log
(
"--------------------------------------------"
)
template
CAN_MatrixUnion
t_message_testFrame0_1
:=
{
// please note that if it is an extended can address, it would be '0x80000122' as usual in socketCAN
can_id
:=
'00000122'O
,
// '...'O as this is anm octetstring
can_pdu
:=
{
message_MyTestframe0
:=
{
test_sig_11_bit_bitstring_lsb_coded
:=
'01010101011'B
,
// '...'B as this is a bitstring
test_sig_5_bit_bitstring_lsb_coded
:=
'11111'B
// '...'B as this is a bitstring
}
}
}
log
(
f_encode_can_matrix
(
valueof
(
t_message_testFrame0_1
)))
log
(
"--------------------------------------------"
)
log
(
f_decode_can_matrix
(
f_encode_can_matrix
(
valueof
(
t_message_testFrame0_1
))))
log
(
"--------------------------------------------"
)
template
CAN_MatrixUnion
t_message_testFrame1_1
:=
{
// please note that if it is an extended can address, it would be '0x80000123' as usual in socketCAN
can_id
:=
'00000123'O
,
// '...'O as this is anm octetstring
can_pdu
:=
{
message_MyTestframe1
:=
{
test_sig_11_bit_bitstring_msb_coded
:=
'01010101011'B
,
// '...'B as this is a bitstring
test_sig_5_bit_bitstring_msb_coded
:=
'11111'B
// '...'B as this is a bitstring
}
}
}
log
(
f_encode_can_matrix
(
valueof
(
t_message_testFrame1_1
)))
log
(
"--------------------------------------------"
)
log
(
f_decode_can_matrix
(
f_encode_can_matrix
(
valueof
(
t_message_testFrame1_1
))))
log
(
"--------------------------------------------"
)
template
CAN_MatrixUnion
t_message_testFrame2_1
:=
{
can_id
:=
'00000124'O
,
// '...'O as this is anm octetstring
can_pdu
:=
{
message_MyTestframe2
:=
{
test_sig_11_bit_integer_msb_coded
:=
2047
,
// as this is a integer
test_sig_5_bit_integer_msb_coded
:=
2
// as this is a integer
}
}
}
log
(
f_encode_can_matrix
(
valueof
(
t_message_testFrame2_1
)))
log
(
"--------------------------------------------"
)
log
(
f_decode_can_matrix
(
f_encode_can_matrix
(
valueof
(
t_message_testFrame2_1
))))
log
(
"--------------------------------------------"
)
template
CAN_MatrixUnion
t_message_testFrame3_1
:=
{
can_id
:=
'00000125'O
,
// '...'O as this is anm octetstring
can_pdu
:=
{
message_MyTestframe3
:=
{
test_sig_1_byte_octetstring_msb_coded
:=
'
FF
'
O
,
// as this is a 1 Byte octetstring
test_sig_2_byte_octetstring_msb_coded
:=
'
123
F
'
O
// as this is a 2 Byte octetstring
}
}
}
log
(
f_encode_can_matrix
(
valueof
(
t_message_testFrame3_1
)))
log
(
"--------------------------------------------"
)
log
(
f_decode_can_matrix
(
f_encode_can_matrix
(
valueof
(
t_message_testFrame3_1
))))
log
(
"--------------------------------------------"
)
template
CAN_MatrixUnion
t_message_extendedFrame1_1
:=
{
can_id
:=
'
80000001
'
O
,
// '...'O as this is anm octetstring
can_pdu
:=
{
message_extendedFrame1
:=
{
test_sig_2_byte_octetstring_msb_coded
:=
'
FFFF
'
O
// as this is a 2 Byte octetstring
}
}
}
log
(
f_encode_can_matrix
(
valueof
(
t_message_extendedFrame1_1
)))
log
(
"--------------------------------------------"
)
log
(
f_decode_can_matrix
(
f_encode_can_matrix
(
valueof
(
t_message_extendedFrame1_1
))))
log
(
"--------------------------------------------"
)
var
CAN_MESSAGE_TESTFRAME1
v_message_Frame1_2
var
CAN_MESSAGE_TESTFRAME2
v_message_Frame2_2
var
CAN_MESSAGE_TESTFRAME3
v_message_Frame3_2
var
CAN_MESSAGE_TESTFRAME4
v_message_Frame4_2
var
CAN_MESSAGE_TESTFRAME5
v_message_Frame5_2
var
CAN_MESSAGE_EXTENDEDFRAME1
v_message_extendedFrame1_2
v_message_Frame1_2
:=
{
// please note that if it is an extended can address, it would be '0x80000123' as usual in socketCAN
test_sig_11_bit_bitstring_msb_coded
:=
'01010101011'B
,
// '...'B as this is a bitstring
test_sig_5_bit_bitstring_msb_coded
:=
'11111'B
// '...'B as this is a bitstring
}
template
CAN_MatrixUnion
t_message_Frame1_2
:=
{
can_id
:=
'00000123'O
,
// '...'O as this is an octetstring
can_pdu
:=
{
message_MyTestframe1
:=
v_message_Frame1_2
}
}
log
(
f_encode_can_matrix
(
valueof
(
t_message_Frame1_2
)))
log
(
"--------------------------------------------"
)
log
(
f_decode_can_matrix
(
f_encode_can_matrix
(
valueof
(
t_message_Frame1_2
))))
log
(
"--------------------------------------------"
)
v_message_Frame2_2
:=
{
// please note that if it is an extended can address, it would be '0x80000124' as usual in socketCAN
test_sig_11_bit_integer_msb_coded
:=
2047
,
// as this is a integer
test_sig_5_bit_integer_msb_coded
:=
2
// as this is a integer
}
template
CAN_MatrixUnion
t_message_Frame2_2
:=
{
can_id
:=
'00000124'O
,
// '...'O as this is an octetstring
can_pdu
:=
{
message_MyTestframe2
:=
v_message_Frame2_2
}
}
log
(
f_encode_can_matrix
(
valueof
(
t_message_Frame2_2
)))
log
(
"--------------------------------------------"
)
log
(
f_decode_can_matrix
(
f_encode_can_matrix
(
valueof
(
t_message_Frame2_2
))))
log
(
"--------------------------------------------"
)
v_message_Frame3_2
:=
{
// please note that if it is an extended can address, it would be '0x80000125' as usual in socketCAN
test_sig_1_byte_octetstring_msb_coded
:=
'
FF
'
O
,
// as this is a 1 Byte octetstring
test_sig_2_byte_octetstring_msb_coded
:=
'
123
F
'
O
// as this is a 2 Byte octetstring
}
template
CAN_MatrixUnion
t_message_Frame3_2
:=
{
can_id
:=
'00000125'O
,
// '...'O as this is an octetstring
can_pdu
:=
{
message_MyTestframe3
:=
v_message_Frame3_2
}
}
log
(
f_encode_can_matrix
(
valueof
(
t_message_Frame3_2
)))
log
(
"--------------------------------------------"
)
log
(
f_decode_can_matrix
(
f_encode_can_matrix
(
valueof
(
t_message_Frame3_2
))))
log
(
"--------------------------------------------"
)
v_message_Frame4_2
:=
{
test_unsig_9_bit_2_padded_integer_msb_coded
:=
511
,
// as this is a 9 Bit bitstring
test_sig_5_bit_integer_msb_coded
:=
8
// as this is a 5 bit integer
}
template
CAN_MatrixUnion
t_message_Frame4_2
:=
{
can_id
:=
'00000126'O
,
// '...'O as this is an octetstring
can_pdu
:=
{
message_MyTestframe4
:=
v_message_Frame4_2
}
}
log
(
f_encode_can_matrix
(
valueof
(
t_message_Frame4_2
)))
log
(
"--------------------------------------------"
)
log
(
f_decode_can_matrix
(
f_encode_can_matrix
(
valueof
(
t_message_Frame4_2
))))
log
(
"--------------------------------------------"
)
v_message_Frame5_2
:=
{
test_unsig_9_bit_2_padded_integer_msb_coded
:=
127
,
// as this is a 9 Bit bitstring
test_sig_5_bit_integer_msb_coded
:=
16
// as this is a 5 bit integer
}
template
CAN_MatrixUnion
t_message_Frame5_2
:=
{
can_id
:=
'00000127'O
,
// '...'O as this is an octetstring
can_pdu
:=
{
message_MyTestframe5
:=
v_message_Frame5_2
}
}
log
(
f_encode_can_matrix
(
valueof
(
t_message_Frame5_2
)))
log
(
"--------------------------------------------"
)
log
(
f_decode_can_matrix
(
f_encode_can_matrix
(
valueof
(
t_message_Frame5_2
))))
log
(
"--------------------------------------------"
)
v_message_extendedFrame1_2
:=
{
// please note that if it is an extended can address, it would be '0x80000125' as usual in socketCAN
test_sig_2_byte_octetstring_msb_coded
:=
'
FFFF
'
O
// as this is a 2 Byte octetstring
}
template
CAN_MatrixUnion
t_message_extendedFrame1_2
:=
{
can_id
:=
'
80000001
'
O
,
// '...'O as this is an octetstring
can_pdu
:=
{
message_extendedFrame1
:=
v_message_extendedFrame1_2
}
}
log
(
f_encode_can_matrix
(
valueof
(
t_message_extendedFrame1_2
)))
log
(
"--------------------------------------------"
)
log
(
f_decode_can_matrix
(
f_encode_can_matrix
(
valueof
(
t_message_extendedFrame1_2
))))
log
(
"--------------------------------------------"
)
var
SocketCAN_CAN_or_CAN_FD_frame
v_frame_to_send1
,
v_frame_to_send2
// This is the way a can frame is prepared for sending and at frame reception
v_frame_to_send1
:=
{
can_frame
:=
{
can_id
:=
'00000122'O
,
can_pdu
:=
'
0123456789
ABCDEF
'
O
}
}
// the received canframe (precondition it is a CAN-frame and not an CANFD-frame):
var
CAN_frame
can_frame
can_frame
:=
v_frame_to_send1
.
can_frame
// For information only:
// This is the way a canfd frame would be prepared for sending and at frame reception
v_frame_to_send2
:=
{
canfd_frame
:=
{
can_id
:=
'00000015'O
,
can_flags
:=
'01010101'B
,
can_pdu
:=
'
0123456789
ABCDEF0123456789ABCDEF0123456789ABCDEF0123456789ABCDEF0123456789ABCDEF0123456789ABCDEF0123456789ABCDEF0123456789ABCDEF
'
O
}
}
setverdict
(
pass
)
}
testcase
tc_can_raw_send_and_receive_can_frame
()
runs
on
MTC
{
var
PTC
v_ptc_rawSendInitiator
:=
PTC
.
create
(
"PTC1_ptc_rawSendInitiator"
)
alive
var
PTC
v_ptc_rawFrameReceiver
:=
PTC
.
create
(
"PTC2_ptc_rawFrameReceiver"
)
alive
f_addSyncSlaveSet
(
v_ptc_rawSendInitiator
,
v_PTCSet
)
f_addSyncSlaveSet
(
v_ptc_rawFrameReceiver
,
v_PTCSet
)
connect
(
mtc
:
pt_sync
,
v_ptc_rawSendInitiator
:
pt_sync
)
connect
(
mtc
:
pt_sync
,
v_ptc_rawFrameReceiver
:
pt_sync
)
var
CAN_MESSAGE_TESTFRAME1
v_message_Frame1_3
v_message_Frame1_3
:=
{
// please note that if it is an extended can address, it would be '0x80000123' as usual in socketCAN
test_sig_11_bit_bitstring_msb_coded
:=
'01010101011'B
,
// '...'B as this is a bitstring
test_sig_5_bit_bitstring_msb_coded
:=
'11111'B
// '...'B as this is a bitstring
}
template
CAN_MatrixUnion
t_message_Frame1_3
:=
{
can_id
:=
'00000123'O
,
// '...'O as this is an octetstring
can_pdu
:=
{
message_MyTestframe1
:=
v_message_Frame1_3
}
}
var
SocketCAN_CAN_or_CAN_FD_frame
v_frame_to_send
v_frame_to_send
:=
{
can_frame
:=
canmatrixframe2can
(
valueof
(
t_message_Frame1_3
))}
v_ptc_rawSendInitiator
.
start
(
f_ptc_RawSendInitiator
(
e_testbody1
,
v_frame_to_send
))
v_ptc_rawFrameReceiver
.
start
(
f_ptc_RawFrameReceiver
(
e_testbody3
,
v_frame_to_send
))
var
e_Phase
v_phase
for
(
v_phase
:=
c_firstPhase
;
v_phase
<
e_testcase_complete
;
v_phase
:=
f_incMTCPhase
(
v_phase
))
{
f_startPhase
(
v_phase
)
log
(
"MTC: "
,
v_phase
)
f_awaitEndPhase
(
v_phase
)
}
all
component
.
done
;
log
(
"MTC done"
)
disconnect
(
mtc
:
pt_sync
,
v_ptc_rawSendInitiator
:
pt_sync
)
disconnect
(
mtc
:
pt_sync
,
v_ptc_rawFrameReceiver
:
pt_sync
)
all
component
.
kill
;
}
testcase
tc_can_raw_send_and_receive_canfd_frame
()
runs
on
MTC
{
var
PTC
v_ptc_rawSendInitiator
:=
PTC
.
create
(
"PTC1_ptc_rawSendInitiator"
)
alive
var
PTC
v_ptc_rawFrameReceiver
:=
PTC
.
create
(
"PTC2_ptc_rawFrameReceiver"
)
alive
f_addSyncSlaveSet
(
v_ptc_rawSendInitiator
,
v_PTCSet
)
f_addSyncSlaveSet
(
v_ptc_rawFrameReceiver
,
v_PTCSet
)
connect
(
mtc
:
pt_sync
,
v_ptc_rawSendInitiator
:
pt_sync
)
connect
(
mtc
:
pt_sync
,
v_ptc_rawFrameReceiver
:
pt_sync
)
var
SocketCAN_CAN_or_CAN_FD_frame
v_canfd_frame_to_send
v_canfd_frame_to_send
:=
{
canfd_frame
:=
{
can_id
:=
'00000015'O
,
can_flags
:=
'10101010'B
,
can_pdu
:=
'
0123456789
ABCDEF0123456789ABCDEF0123456789ABCDEF0123456789ABCDEF0123456789ABCDEF0123456789ABCDEF0123456789ABCDEF0123456789ABCDEF
'
O
}