Commit 63c60db7 authored by Lenard Nagy's avatar Lenard Nagy
Browse files

Added J1939 support by Michael Josenhans


Signed-off-by: Lenard Nagy's avatarLenard Nagy <lenard.nagy@ericsson.com>
parent 1560c32b
......@@ -19,6 +19,7 @@ import from Can all
import from IsobusCMMessageTypes all
import from IsobusNMMessageTypes all
import from IsobusVTMessageTypes all
import from J1939 all
// Note:
// SocketCAN Error frames are not considered here
......@@ -37,17 +38,9 @@ const octetstring ISOBUS_PDUFORMAT_MASK := '00FF0000'O;
const octetstring ISOBUS_PDUSPECIFIC_MASK := '0000FF00'O;
const octetstring ISOBUS_SOURCEADDRESS_MASK := '000000FF'O;
//type BIT3 Priority
type J1939_Priority Priority
type bitstring Priority length(6)
with {
variant "ALIGN(left)";
variant "FIELDLENGTH(6)"
}
type record J1939 { // Error & RTR Frames are not considered here
type record J1939_header { // Error & RTR Frames are not considered here
//PGN pgn optional,
//BIT3 ignore,
Priority prio,
......@@ -90,7 +83,7 @@ type union AnyIsoBusPdu {
with { variant "" }
type record CAN_frame_j1939 {
J1939 can_j1939,
J1939_header can_j1939,
AnyIsoBusPdu can_pdu
}with { variant "" }
......@@ -121,10 +114,10 @@ function j1939frame2can(in CAN_frame_j1939 p_can_frame_j1939, in Priority p_prio
return v_can_frame
}
function pdu1_j1939id2canid(in J1939 p_j1939, in Priority p_priority, in DestinationAddress p_da, in SourceAddress p_sa) return CAN_id{
function pdu1_j1939id2canid(in J1939_header p_j1939, in Priority p_priority, in DestinationAddress p_da, in SourceAddress p_sa) return CAN_id{
var CAN_id v_can_id
v_can_id := bit2oct(oct2bit(p_sa) or4b (oct2bit(p_da) << 8) or4b (oct2bit(p_j1939.pf) << 16) or4b ((p_j1939.dp) << 24) or4b
((p_j1939.res) << 25) or4b (int2bit(bit2int(p_priority), 32) << 26))
((p_j1939.res) << 25) or4b (int2bit(p_priority, 32) << 26))
return v_can_id
}
......@@ -137,12 +130,12 @@ return v_can_id
}
*/
function j1939id2canid(in J1939 p_j1939) return CAN_id{
function j1939id2canid(in J1939_header p_j1939) return CAN_id{
var CAN_id v_can_id
v_can_id := int2oct(
oct2int(p_j1939.sa) + oct2int(p_j1939.ps)*256 + oct2int(p_j1939.pf) * 256 * 256 +
bit2int(p_j1939.dp) * 256 * 256 * 256 + bit2int(p_j1939.res) * 256 * 256 * 256 * 2 +
bit2int(p_j1939.prio) * 256 * 256 * 256 * 2 * 2,
p_j1939.prio * 256 * 256 * 256 * 2 * 2,
4 )
return v_can_id
}
......@@ -161,13 +154,13 @@ function can2j1939frame(CAN_frame p_can_frame) return CAN_frame_j1939 {
return v_can_frame_j1939
}
function canid2j1939(in CAN_id p_can_id) return J1939 {
function canid2j1939(in CAN_id p_can_id) return J1939_header {
//---------------------------------------------------------------------------------------
var bitstring v_can_id_bitstring:= oct2bit(p_can_id)
var J1939 v_j1939
var J1939_header v_j1939
v_j1939.prio :=substr(v_can_id_bitstring, 0, 6); //3 ,3
v_j1939.prio :=bit2int(substr(v_can_id_bitstring, 0, 6)); //3 ,3
v_j1939.res :=v_can_id_bitstring[6];
v_j1939.dp :=v_can_id_bitstring[7];
v_j1939.pf :=p_can_id[1];//(p_can_id and4b ISOBUS_PDUFORMAT_MASK) >> 2 // shift 16 bits = 2 octets
......
......@@ -3,6 +3,16 @@ module IsobusVTMessageTypes {
import from General_Types all
import from IsobusMessageTypes all
external function encode_VT2ECU(in VT2ECU pdu) return octetstring
with { extension "prototype(convert) encode(RAW)" }
external function decode_VT2ECU(in octetstring data) return VT2ECU
with { extension "prototype(convert) decode(RAW)" }
external function encode_ECU2VT(in ECU2VT pdu) return octetstring
with { extension "prototype(convert) encode(RAW)" }
external function decode_ECU2VT(in octetstring data) return ECU2VT
with { extension "prototype(convert) decode(RAW)" }
type INT1 VTfunction
type integer AnyObjectID (0..65535) with { variant "FIELDLENGTH(16)" }; // includes also 65535 as no object
......
......@@ -7,6 +7,7 @@ import from IsobusNMMessageTypes all
import from Isobus all
import from General_Types all
template CAN_frame_j1939 t_message(Isobus.Priority prio_param, BIT1 res_param, BIT1 dp_param,
OCT1 pf_param, OCT1 ps_param, SourceAddress sa_param, template AnyIsoBusPdu t_can_pdu)
:= { can_j1939 := {
......
......@@ -25,6 +25,7 @@ import from Can all
import from Isobus all
import from IsobusMessageTypes all
import from Isobus_Templates all
import from J1939 all
import from IsobusNMMessageTypes all
......@@ -552,26 +553,26 @@ testcase tc_encdec() runs on MTC_CT
{
template CAN_frame_j1939 t_CAN_frame_j1939 := { can_j1939 := { prio := '000110'B, res := '0'B, dp := '1'B, pf := 'E9'O, ps := 'FD'O, sa := 'E6'O },
template CAN_frame_j1939 t_CAN_frame_j1939 := { can_j1939 := { prio := 6, res := '0'B, dp := '1'B, pf := 'E9'O, ps := 'FD'O, sa := 'E6'O },
can_pdu := { addressClaimed := { name := { selfConfigurableAddressValue := '0'B, industryGroupValue := '011'B, deviceClassInstanceValue := '0001'B, deviceClassValue := '0000001'B, reserveValued := '0'B, functionValue := '00000011'B, functionInstanceValue := '00101'B, ecuInstancceValue := '110'B, manufacturerCodeValue := '10000000000'B, identityNumberBits := '101000010000101000000'B } }}}
log(f_encode_CAN_frame_j1939(valueof(t_CAN_frame_j1939)))
log("--------------------------------------------")
log(f_decode_CAN_frame_j1939(f_encode_CAN_frame_j1939(valueof(t_CAN_frame_j1939))))
log("--------------------------------------------")
template CAN_frame_j1939 t_CAN_frame_j1939_2 := { can_j1939 := { prio := '000000'B, res := '0'B, dp := '0'B, pf := '00'O, ps := 'FD'O, sa := 'C0'O }, can_pdu := { requestForAddressClaimed := {pgn := 123}} }
template CAN_frame_j1939 t_CAN_frame_j1939_2 := { can_j1939 := { prio := 0, res := '0'B, dp := '0'B, pf := '00'O, ps := 'FD'O, sa := 'C0'O }, can_pdu := { requestForAddressClaimed := {pgn := 123}} }
log(f_encode_CAN_frame_j1939(valueof(t_CAN_frame_j1939_2)))
log("--------------------------------------------")
log(f_decode_CAN_frame_j1939(f_encode_CAN_frame_j1939(valueof(t_CAN_frame_j1939_2))))
log("--------------------------------------------")
template CAN_frame_j1939 t_CAN_frame_j1939_3 := { can_j1939 := { prio := '000000'B, res := '0'B, dp := '0'B, pf := '00'O, ps := 'FD'O, sa := 'C0'O }, can_pdu := { cannotClaimSourceAddress := { name := { selfConfigurableAddressValue := '0'B, industryGroupValue := '011'B, deviceClassInstanceValue := '0001'B, deviceClassValue := '0000001'B, reserveValued := '0'B, functionValue := '00000011'B, functionInstanceValue := '00101'B, ecuInstancceValue := '110'B, manufacturerCodeValue := '10000000000'B, identityNumberBits := '101000010000101000000'B } }}}
template CAN_frame_j1939 t_CAN_frame_j1939_3 := { can_j1939 := { prio := 0, res := '0'B, dp := '0'B, pf := '00'O, ps := 'FD'O, sa := 'C0'O }, can_pdu := { cannotClaimSourceAddress := { name := { selfConfigurableAddressValue := '0'B, industryGroupValue := '011'B, deviceClassInstanceValue := '0001'B, deviceClassValue := '0000001'B, reserveValued := '0'B, functionValue := '00000011'B, functionInstanceValue := '00101'B, ecuInstancceValue := '110'B, manufacturerCodeValue := '10000000000'B, identityNumberBits := '101000010000101000000'B } }}}
log(f_encode_CAN_frame_j1939(valueof(t_CAN_frame_j1939_3)))
log("--------------------------------------------")
log(f_decode_CAN_frame_j1939(f_encode_CAN_frame_j1939(valueof(t_CAN_frame_j1939_3))))
log("--------------------------------------------")
template CAN_frame_j1939 t_CAN_frame_j1939_6 := { can_j1939 := { prio := '000110'B, res := '0'B, dp := '1'B, pf := 'E6'O , ps := 'FD'O, sa := '00'O }, can_pdu := { commandedAddress := {
template CAN_frame_j1939 t_CAN_frame_j1939_6 := { can_j1939 := { prio := 6, res := '0'B, dp := '1'B, pf := 'E6'O , ps := 'FD'O, sa := '00'O }, can_pdu := { commandedAddress := {
name := { selfConfigurableAddressValue := '0'B, industryGroupValue := '011'B, deviceClassInstanceValue := '0001'B, deviceClassValue := '0000001'B, reserveValued := '0'B, functionValue := '00000011'B, functionInstanceValue := '00101'B, ecuInstancceValue := '110'B, manufacturerCodeValue := '10000000000'B, identityNumberBits := '101000010000101000000'B },
newSourceAddress:='AA'O
} } }
......@@ -583,7 +584,7 @@ testcase tc_encdec() runs on MTC_CT
testcase tc_encdec_vt2ecu_vtStatusReq() runs on MTC_CT
{
template CAN_frame_j1939 t_CAN_frame_j1939 := { can_j1939 := { prio := '000000'B, res := '0'B, dp := '0'B, pf := '00'O, ps := '00'O, sa := '00'O }, can_pdu :=
template CAN_frame_j1939 t_CAN_frame_j1939 := { can_j1939 := { prio := 0, res := '0'B, dp := '0'B, pf := '00'O, ps := '00'O, sa := '00'O }, can_pdu :=
{vt2ecu := {vtStatusReq :=
{ vtfunction := 254,
sourceAddressOfActiveWorkingSetMaster := '11'O,
......@@ -597,7 +598,7 @@ testcase tc_encdec_vt2ecu_vtStatusReq() runs on MTC_CT
testcase tc_encdec_ecu2vt_getMemoryReq() runs on MTC_CT
{
template CAN_frame_j1939 t_CAN_frame_j1939 := { can_j1939 := { prio := '000000'B, res := '0'B, dp := '0'B, pf := '00'O, ps := '00'O, sa := '00'O }, can_pdu :=
template CAN_frame_j1939 t_CAN_frame_j1939 := { can_j1939 := { prio := 0, res := '0'B, dp := '0'B, pf := '00'O, ps := '00'O, sa := '00'O }, can_pdu :=
{ecu2vt := {getMemoryReq :=
{ vtfunction := 194,
reserved2 := 'FF'O,
......@@ -610,7 +611,7 @@ testcase tc_encdec_ecu2vt_getMemoryReq() runs on MTC_CT
testcase tc_encdec_ecu2vt_getMemoryReq_with_templateI() runs on MTC_CT // using a template
{
template CAN_frame_j1939 t_CAN_frame_j1939 := { can_j1939 := { prio := '000000'B, res := '0'B, dp := '0'B, pf := '00'O, ps := '00'O, sa := '00'O }, can_pdu :=
template CAN_frame_j1939 t_CAN_frame_j1939 := { can_j1939 := { prio := 0, res := '0'B, dp := '0'B, pf := '00'O, ps := '00'O, sa := '00'O }, can_pdu :=
{ecu2vt := {getMemoryReq := t_GetMemoryReq(1234567)}}}
log(f_encode_CAN_frame_j1939(valueof(t_CAN_frame_j1939)))
log(f_decode_CAN_frame_j1939(f_encode_CAN_frame_j1939(valueof(t_CAN_frame_j1939))))
......@@ -618,7 +619,7 @@ testcase tc_encdec_ecu2vt_getMemoryReq_with_templateI() runs on MTC_CT // using
testcase tc_encdec_ecu2vt_getMemoryReq_with_template_II() runs on MTC_CT // using a template
{
template CAN_frame_j1939 t_CAN_frame_j1939 := { can_j1939 := { prio := '000000'B, res := '0'B, dp := '0'B, pf := '00'O, ps := '00'O, sa := '00'O }, can_pdu :=
template CAN_frame_j1939 t_CAN_frame_j1939 := { can_j1939 := { prio := 0, res := '0'B, dp := '0'B, pf := '00'O, ps := '00'O, sa := '00'O }, can_pdu :=
t_GetMemoryReq_pdu(1234567)}
log(f_encode_CAN_frame_j1939(valueof(t_CAN_frame_j1939)))
log(f_decode_CAN_frame_j1939(f_encode_CAN_frame_j1939(valueof(t_CAN_frame_j1939))))
......@@ -626,7 +627,7 @@ testcase tc_encdec_ecu2vt_getMemoryReq_with_template_II() runs on MTC_CT // usin
testcase tc_encdec_networkMessage_N_SP_Response_pdu_with_template() runs on MTC_CT // using a template
{
template CAN_frame_j1939 t_CAN_frame_j1939 := t_message ( '000001'B, '1'B, '0'B, '0A'O, '0B'O, '0C'O ,
template CAN_frame_j1939 t_CAN_frame_j1939 := t_message ( 1, '1'B, '0'B, '0A'O, '0B'O, '0C'O ,
t_N_SP_Response_pdu(port_3, port_4, {'01'O,'02'O,'03'O,'04'O,'05'O,'06'O,'07'O}))
log(f_encode_CAN_frame_j1939(valueof(t_CAN_frame_j1939)))
log(f_decode_CAN_frame_j1939(f_encode_CAN_frame_j1939(valueof(t_CAN_frame_j1939))))
......@@ -634,7 +635,7 @@ testcase tc_encdec_networkMessage_N_SP_Response_pdu_with_template() runs on MTC_
testcase tc_encdec_networkMessage_N_SP_Response_with_template() runs on MTC_CT // using a template
{
template CAN_frame_j1939 t_CAN_frame_j1939 := t_network_message ( '000001'B, '1'B, '0'B, '0A'O, '0B'O, '0C'O ,
template CAN_frame_j1939 t_CAN_frame_j1939 := t_network_message ( 1, '1'B, '0'B, '0A'O, '0B'O, '0C'O ,
{n_SP_Response := t_N_SP_Response(port_3, port_4, {'01'O,'02'O,'03'O,'04'O,'05'O,'06'O,'07'O})})
log(f_encode_CAN_frame_j1939(valueof(t_CAN_frame_j1939)))
log(f_decode_CAN_frame_j1939(f_encode_CAN_frame_j1939(valueof(t_CAN_frame_j1939))))
......@@ -642,7 +643,7 @@ testcase tc_encdec_networkMessage_N_SP_Response_with_template() runs on MTC_CT /
testcase tc_encdec_N_SP_Response_with_template() runs on MTC_CT // using a template
{
template CAN_frame_j1939 t_CAN_frame_j1939 := t_message ( '000001'B, '1'B, '0'B, '0A'O, '0B'O, '0C'O ,
template CAN_frame_j1939 t_CAN_frame_j1939 := t_message ( 1, '1'B, '0'B, '0A'O, '0B'O, '0C'O ,
{networkMessage := {n_SP_Response := t_N_SP_Response(port_3, port_4, {'01'O,'02'O,'03'O,'04'O,'05'O,'06'O,'07'O})}})
log(f_encode_CAN_frame_j1939(valueof(t_CAN_frame_j1939)))
log(f_decode_CAN_frame_j1939(f_encode_CAN_frame_j1939(valueof(t_CAN_frame_j1939))))
......@@ -650,7 +651,7 @@ testcase tc_encdec_N_SP_Response_with_template() runs on MTC_CT // using a templ
testcase tc_encdec_ecu2vt_workingSetMaintenanceReq() runs on MTC_CT // using a template
{
template CAN_frame_j1939 t_CAN_frame_j1939 := { can_j1939 := { prio := '000000'B, res := '0'B, dp := '0'B, pf := '00'O, ps := '00'O, sa := '00'O }, can_pdu :=
template CAN_frame_j1939 t_CAN_frame_j1939 := { can_j1939 := { prio := 0, res := '0'B, dp := '0'B, pf := '00'O, ps := '00'O, sa := '00'O }, can_pdu :=
t_WorkingSetMaintenanceReq_pdu({
initiatingWorkingSetMaintenance := true,
reserved1 := false,
......@@ -667,7 +668,7 @@ testcase tc_encdec_ecu2vt_workingSetMaintenanceReq() runs on MTC_CT // using a t
testcase tc_encdec_etp_dt () runs on MTC_CT // using a template
{
template CAN_frame_j1939 t_CAN_frame_j1939 := { can_j1939 := { prio := '000000'B, res := '1'B, dp := '1'B, pf := 'FE'O, ps := '00'O, sa := 'F8'O },
template CAN_frame_j1939 t_CAN_frame_j1939 := { can_j1939 := { prio := 0, res := '1'B, dp := '1'B, pf := 'FE'O, ps := '00'O, sa := 'F8'O },
can_pdu := { etp_dt := { seq_no := 105, data := '6C652073657276'O } } }
log(f_encode_CAN_frame_j1939(valueof(t_CAN_frame_j1939)))
log(f_decode_CAN_frame_j1939(f_encode_CAN_frame_j1939(valueof(t_CAN_frame_j1939))))
......@@ -687,7 +688,6 @@ testcase tc_dec_requestForAddressClaimed() runs on MTC_CT
}
testcase tc_dec_largemessage() runs on MTC_CT
{
......@@ -720,6 +720,44 @@ j1939_pdu := '18ECF8F810160004FFEBFE00'O
log("--------------------------------------------")
}
import from IsobusVTMessageTypes all
testcase tc_decode_VT2ECU() runs on MTC_CT
{
var octetstring j1939_vt_pdu
j1939_vt_pdu := 'c7ff02cde001e001'O
j1939_vt_pdu := 'c200ffff7d48400c'O
j1939_vt_pdu := 'c3ffffffff7f7fff'O
j1939_vt_pdu := 'c00400ffffffffff'O
j1939_vt_pdu := 'e00130303034333030'O
j1939_vt_pdu := 'd1ffffffff00ffff'O
j1939_vt_pdu := '09d00701ffff01ff'O
j1939_vt_pdu := 'b3ffffda5900ffff'O
j1939_vt_pdu := 'a82bd300bc0b0000'O
j1939_vt_pdu := 'a82cd300bb0b0000'O
j1939_vt_pdu := 'a82dd300bb0b0000'O
j1939_vt_pdu := 'b3ffff02d700ffff'O
j1939_vt_pdu := 'a875d600c4da0000'O
j1939_vt_pdu := 'a876d600c2da0000'O
j1939_vt_pdu := 'a877d600ffff0000'O
j1939_vt_pdu := 'a878d600ffff0000'O
j1939_vt_pdu := 'a879d600ffff0000'O
j1939_vt_pdu := 'a87ad600ffff0000'O
j1939_vt_pdu := 'a87bd600ffff0000'O
j1939_vt_pdu := 'a87cd600ffff0000'O
j1939_vt_pdu := 'a87dd600ffff0000'O
j1939_vt_pdu := 'a87ed600ffff0000'O
//j1939_vt_pdu := 'ade90300ffffffff'O
//j1939_vt_pdu := '09d00700ffff00ff'O
log(j1939_vt_pdu)
log("--------------------------------------------")
log(decode_VT2ECU(j1939_vt_pdu))
log("--------------------------------------------")
}
//test case declarations
testcase tc_Example001() runs on MTC_CT
{
......@@ -752,6 +790,7 @@ testcase tc_Example001() runs on MTC_CT
//when the test case terminates, MTC will terminate as well
//PTCs terminate (reach the state done) when the function with which they were started terminates
//test case declarations
testcase tc_Example002() runs on MTC_CT
{
......
......@@ -127,7 +127,7 @@ return SocketCAN_ioctl_result {
timer t_guard
t_guard.start(c_guard)
pt_socketCAN.send(SocketCAN_ioctl:{id:= p_socket_id, ifu := omit});
pt_socketCAN.send(SocketCAN_Types.SocketCAN_ioctl:{id:= p_socket_id, ifu := omit});
// receive response
alt {
[] pt_socketCAN.receive(a_SocketCAN_ioctl_result(a_result(SocketCAN_SUCCESS))) -> value v_result
......
##############################################################################
# Copyright (c) 2000-2019 Ericsson Telecom AB 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 J1939 tests
SocketCAN_J1939_test.tc_can_j1939_send_and_receive_can_frame
SocketCAN_J1939_test.tc_can_j1939_send_and_receive_can_frame_parallel
This diff is collapsed.
......@@ -85,12 +85,14 @@ ARCHIVE_DIR = backup
# TTCN-3 modules of this project:
TTCN3_MODULES = ../src/Bcm.ttcn ../src/Can.ttcn ../src/CanError.ttcn ../src/General_Types.ttcn ../src/Raw.ttcn \
SocketCAN_BCM_test.ttcn ../src/SocketCAN_PortType.ttcn SocketCAN_RAW_test.ttcn ../src/SocketCAN_Templates.ttcn \
../src/SocketCAN_Types.ttcn SocketCANtest.ttcn Isobus.ttcn Isobustest.ttcn IsobusMessageTypes.ttcn \
../src/SocketCAN_Types.ttcn ../src/J1939.ttcn \
SocketCANtest.ttcn Isobus.ttcn Isobustest.ttcn IsobusMessageTypes.ttcn \
Isobus_Templates.ttcn IsobusNMMessageTypes.ttcn IsobusCMMessageTypes.ttcn IsobusVTMessageTypes.ttcn \
Isotp.ttcn Isotptest.ttcn \
CAN_matrix_general_types.ttcn CAN_matrix_test.ttcn CAN_matrix.ttcn CAN_matrix_messages.ttcn CANFD_matrix_messages.ttcn \
CAN_matrix_signals.ttcn CAN_matrix_templates.ttcn \
UnifiedDiagnosticServices.ttcn UnifiedDiagnosticServicestest.ttcn UnifiedDiagnosticServices_Template.ttcn
UnifiedDiagnosticServices.ttcn UnifiedDiagnosticServicestest.ttcn UnifiedDiagnosticServices_Template.ttcn \
J1939test.ttcn SocketCAN_J1939_test.ttcn
# ASN.1 modules of this project:
ASN1_MODULES =
......@@ -99,12 +101,14 @@ ASN1_MODULES =
# this project:
GENERATED_SOURCES = Bcm.cc Can.cc CanError.cc General_Types.cc Raw.cc \
SocketCAN_BCM_test.cc SocketCAN_PortType.cc SocketCAN_RAW_test.cc SocketCAN_Templates.cc \
SocketCAN_Types.cc SocketCANtest.cc Isobus.cc Isobustest.cc IsobusMessageTypes.cc \
SocketCAN_Types.cc J1939.cc \
SocketCANtest.cc Isobus.cc Isobustest.cc IsobusMessageTypes.cc \
Isobus_Templates.cc IsobusNMMessageTypes.cc IsobusCMMessageTypes.cc IsobusVTMessageTypes.cc \
Isotp.cc Isotptest.cc \
CAN_matrix_general_types.cc CAN_matrix_test.cc CAN_matrix.cc CAN_matrix_messages.cc CANFD_matrix_messages.cc \
CAN_matrix_signals.cc CAN_matrix_templates.cc \
UnifiedDiagnosticServices.cc UnifiedDiagnosticServicestest.cc UnifiedDiagnosticServices_Template.cc
UnifiedDiagnosticServices.cc UnifiedDiagnosticServicestest.cc UnifiedDiagnosticServices_Template.cc \
J1939test.cc SocketCAN_J1939_test.cc
GENERATED_HEADERS = $(GENERATED_SOURCES:.cc=.hh)
......
/* Copyright (c) 2000-2019 Ericsson Telecom AB
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v2.0
* which accompanies this distribution, and is available at
* https://www.eclipse.org/org/documents/epl-2.0/EPL-2.0.html
*
* Contributors:
* Michael Josenhans
******************************************************************************/
//
// File: SocketCAN_J1939_test.ttcn
// Description: SocketCAN J1939 testcases for J1939 messages
//
module SocketCAN_J1939_test
{
import from J1939 all
import from J1939test all
function create_octetstring_of_size(in integer size) return octetstring {
var octetstring v_pdu_mod_1024 := ''O
var octetstring v_pdu_1024 := ''O
var octetstring v_pdu_mod_1048576 := ''O //1024*1024
var octetstring v_pdu_1048576 := ''O
var octetstring v_pdu_1073741824 := ''O //1024*1024*1024
var octetstring v_pdu := ''O
var integer vcount :=0
var integer maxcount
maxcount := size mod 1024
for (vcount :=0;vcount < maxcount; vcount := vcount+1){
v_pdu_mod_1024 := v_pdu_mod_1024 & int2oct((vcount mod 256),1)
}
log("1")
for (vcount :=0;vcount < 1024; vcount := vcount+1){
v_pdu_1024 := v_pdu_1024 & int2oct((vcount mod 256),1)
}
log("2")
maxcount := (size /1024) mod 1024
for (vcount :=0;vcount < maxcount; vcount := vcount+1){
v_pdu_mod_1048576 := v_pdu_mod_1048576 & v_pdu_1024
}
v_pdu_mod_1048576 := v_pdu_mod_1048576 & v_pdu_mod_1024
log("3")
for (vcount :=0;vcount < 1024; vcount := vcount+1){
v_pdu_1048576 := v_pdu_1048576 & v_pdu_1024
}
log("4")
maxcount := (size / (1024*1024))
for (vcount :=0;vcount < maxcount; vcount := vcount+1){
v_pdu_1073741824 := v_pdu_1073741824 & v_pdu_1048576
}
v_pdu_1073741824 := v_pdu_1073741824 & v_pdu_mod_1048576
log("5")
v_pdu := v_pdu_1073741824
return v_pdu
}
testcase tc_can_j1939_send_and_receive_can_frame() runs on MTC {
var PTC v_ptc_j1939SendInitiator := PTC.create("PTC1_ptc_j1939SendInitiator") alive
var PTC v_ptc_j1939FrameReceiver := PTC.create("PTC2_ptc_j1939FrameReceiver") alive
f_addSyncSlaveSet(v_ptc_j1939SendInitiator, v_PTCSet)
f_addSyncSlaveSet(v_ptc_j1939FrameReceiver, v_PTCSet)
connect(mtc:pt_sync, v_ptc_j1939SendInitiator:pt_sync)
connect(mtc:pt_sync, v_ptc_j1939FrameReceiver:pt_sync)
const integer c_send_prio := 2
const octetstring c_addr_source1 := '80'O
const octetstring c_pgn_destination1 := '00E700'O // ECU to VT
const octetstring c_addr_destination1 := '90'O
var octetstring v_pdu_send := ''O
//v_pdu_send := create_octetstring_of_size(117440505)
v_pdu_send := create_octetstring_of_size (4193975) //4193976
log("length of v_pdu_send: ", lengthof(v_pdu_send))
v_ptc_j1939SendInitiator.start(f_ptc_J1939SendInitiator(
e_testbody1,
c_send_prio,
c_addr_source1,
c_pgn_destination1,
c_addr_destination1,
v_pdu_send))
v_ptc_j1939FrameReceiver.start(f_ptc_J1939FrameReceiver(
e_testbody2,
c_addr_destination1, /* p_j1939_addr_source */
c_pgn_destination1, /* p_peer_pgn */
c_addr_source1, /* p_peer_addr */
J1939_NO_NAME, /* p_peer_name */
v_pdu_send /* p_j1939_pdu_expected */))
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_j1939SendInitiator:pt_sync)
disconnect(mtc:pt_sync, v_ptc_j1939FrameReceiver:pt_sync)
all component.kill;
}
testcase tc_can_j1939_send_and_receive_can_frame_parallel() runs on MTC {
var PTC v_ptc_j1939SendInitiator1 := PTC.create("PTC1_ptc_j1939SendInitiator1") alive
var PTC v_ptc_j1939FrameReceiver1 := PTC.create("PTC2_ptc_j1939FrameReceiver1") alive
var PTC v_ptc_j1939SendInitiator2 := PTC.create("PTC1_ptc_j1939SendInitiator2") alive
var PTC v_ptc_j1939FrameReceiver2 := PTC.create("PTC2_ptc_j1939FrameReceiver2") alive
f_addSyncSlaveSet(v_ptc_j1939SendInitiator1, v_PTCSet)
f_addSyncSlaveSet(v_ptc_j1939FrameReceiver1, v_PTCSet)
f_addSyncSlaveSet(v_ptc_j1939SendInitiator2, v_PTCSet)
f_addSyncSlaveSet(v_ptc_j1939FrameReceiver2, v_PTCSet)
connect(mtc:pt_sync, v_ptc_j1939SendInitiator1:pt_sync)
connect(mtc:pt_sync, v_ptc_j1939FrameReceiver1:pt_sync)
connect(mtc:pt_sync, v_ptc_j1939SendInitiator2:pt_sync)
connect(mtc:pt_sync, v_ptc_j1939FrameReceiver2:pt_sync)
const integer c_send_prio := 2
const octetstring c_addr_source1 := '80'O
const octetstring c_pgn_destination1 := '00E700'O // ECU to VT
const octetstring c_addr_destination1 := '90'O
const octetstring c_addr_source2 := '80'O
const octetstring c_pgn_destination2 := '00E700'O // ECU to VT
const octetstring c_addr_destination2 := '91'O
var octetstring v_pdu_send1 := ''O
var octetstring v_pdu_send2 := ''O
//v_pdu_send := create_octetstring_of_size(117440505)
v_pdu_send1 := create_octetstring_of_size(4193976)
log("length of v_pdu_send1: ", lengthof(v_pdu_send1))
v_pdu_send2 := create_octetstring_of_size(4193976)
log("length of v_pdu_send2: ", lengthof(v_pdu_send2))
v_ptc_j1939SendInitiator1.start(f_ptc_J1939SendInitiator(
e_testbody1,
c_send_prio,
c_addr_source1,
c_pgn_destination1,
c_addr_destination1,
v_pdu_send1))
v_ptc_j1939FrameReceiver1.start(f_ptc_J1939FrameReceiver(
e_testbody2,
c_addr_destination1, /* p_j1939_addr_source */
c_pgn_destination1, /* p_peer_pgn */
c_addr_source1, /* p_peer_addr */
J1939_NO_NAME, /* p_peer_name */
v_pdu_send1 /* p_j1939_pdu_expected */))
v_ptc_j1939SendInitiator2.start(f_ptc_J1939SendInitiator(
e_testbody1,
c_send_prio,
c_addr_source2,
c_pgn_destination2,
c_addr_destination2,
v_pdu_send2))
v_ptc_j1939FrameReceiver2.start(f_ptc_J1939FrameReceiver(
e_testbody2,
c_addr_destination2, /* p_j1939_addr_source */
c_pgn_destination2, /* p_peer_pgn */
c_addr_source2, /* p_peer_addr */
J1939_NO_NAME, /* p_peer_name */
v_pdu_send2 /* p_j1939_pdu_expected */))
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_j1939SendInitiator1:pt_sync)
disconnect(mtc:pt_sync, v_ptc_j1939FrameReceiver1:pt_sync)
disconnect(mtc:pt_sync, v_ptc_j1939SendInitiator2:pt_sync)
disconnect(mtc:pt_sync, v_ptc_j1939FrameReceiver2:pt_sync)
all component.kill;
}
testcase tc_can_f_j1939_address_claim() runs on MTC {
var PTC v_ptc_j1939AddressClaimInitiator := PTC.create("PTC1_ptc_j1939AddressClaimInitiator") alive
f_addSyncSlaveSet(v_ptc_j1939AddressClaimInitiator, v_PTCSet)
connect(mtc:pt_sync, v_ptc_j1939AddressClaimInitiator:pt_sync)
const J1939_NAME c_j1939_name_source := '1122334455667788'O
v_ptc_j1939AddressClaimInitiator.start(f_j1939_address_claim(
e_testbody1,
c_j1939_name_source))
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_j1939AddressClaimInitiator:pt_sync)
all component.kill;
}
testcase tc_can_f_j1939_address_claim2() runs on MTC {
var PTC v_ptc_j1939AddressClaimInitiator := PTC.create("PTC1_ptc_j1939AddressClaimInitiator") alive
f_addSyncSlaveSet(v_ptc_j1939AddressClaimInitiator, v_PTCSet)
connect(mtc:pt_sync, v_ptc_j1939AddressClaimInitiator:pt_sync)