Skip to content

LIN - FERAL Features

General

Integrated bus master

This module is supposed to simulate a LIN bus which is controlled by a FERAL bus master. The bus master can be configured ether using a LDF file or manually during the configuration. Both possibilities are shown below:

Example

// - Create "LDF-Parser" (LIN Description File)
ClassLoader classloader = Thread.currentThread().getContextClassLoader();
LDFParser parser = new LDFParser(Paths.get("PATH_TO_FILE"));
parser.parseLDF();
// Create a LIN network having amount of Interfaces defined in the LDF.
LINNetwork network = parser.createLINNetwork(director);

// - Setup network parameter
parser.injectLINNetworkParameters(network.getConfig()); // Apply LIN Network Parameters by the LDF
network.getConfig().setTimeBase(SimulationDuration.MS(10));
network.getConfig().setScheduleStartDelay(SimulationDuration.MS(120));
parser.instantiateSchedule(network);

// - Setup communication interfaces
parser.setupCommunicationInterfaces(network);

// - Setup links from/to network
new Link(network.getMasterInterface().getOutputPort( "linID5_out"), linReceiver.getInputPort("comm"));
new Link(linSender.getOutputPort("comm"), network.getSlaveInterface(0).getInputPort("linID5_in"));
//Create a LIN network having 2 Interfaces.
LINNetwork network = new DefaultLINNetwork(director, 2);
// - Setup network parameter
network.setBitRate(10000);
network.getConfig().setTimeBase(SimulationDuration.MS(10));
network.getConfig().setScheduleStartDelay(SimulationDuration.MS(120));
network.addSchedule("SCHEDULE_NAME")
    .addUnconditionalFrame(
        1  /* first slave */ , 
        5  /* frame duration = 5 * time base */, 
        5  /* frame ID */);

// - Setup communication interfaces
network.getMasterInterface().addRxMessageType("5", "linID5_out", 2); 
network.getSlaveInterface(0).addTxMessageType("5", "linID5_in", 2);

// - Setup links from/to network
new Link(network.getMasterInterface().getOutputPort( "linID5_out"), linReceiver.getInputPort("comm"));
new Link(linSender.getOutputPort("comm"), network.getSlaveInterface(0).getInputPort("linID5_in"));
""" Create the network from the LDF file """
lin = feral.lin_from_ldf(str(pathlib.Path("\LDF_UnconditionalSchedule.lin")))

""" Link the network with the components """
feral.link(producer, "output", lin, "linID5_in")
feral.link(lin, "linID5_out", sink, "input")
""" Create network nodes """
node0 = LINNodeConfig(
    name="node0",
    message_types=[
        MessageTypeConfig(
            type=MessageType.TX,
            address="5",
            simulated_payload_size=2,
            port_name="node0_tx"
        )]
    )

node1 = LINNodeConfig(
    name="node1",
    message_types=[
        MessageTypeConfig(
            type=MessageType.RX,
            address="5",
            simulated_payload_size=2,
            port_name="node1_rx"
        )]
    )

""" Create LIN config """
lin_config = LINConfig(
    nodes=[node0, node1],
    bit_rate=10000,
    time_base=feral.millis(10),
    log_transmissions=False
    )

""" Create the network, the schedule and the linking """
lin = feral.create_lin(config=lin_config)
schedule = (feral.add_schedule("Schedule Table", lin)
                .add_unconditional_frame(0, 5, 5)
                .add_sporadic_frame(5,[5]))

feral.link(producer, "output", lin, "node0_tx")
feral.link(lin, "node1_rx", sink, "input")

Supported message types

The current implementation supports the use of

  • Unconditional frames,
  • Sporadic frames and
  • Event triggered frames.

Diagnostic and reserved frame types are not yet implemented.

Additional information and standard compliancy

The current implementation is designed for LIN 2.0 and above and cannot be guarenteed to work with prior versions.

Simulated message size

The simulated message size is not bound to the LIN ID. This constraint is not part of the LIN specification 2.0 and later. However, it is part of the LIN Protocol Specification Revision 1.3, which is not supported. Please note, that currently the message size generated from the payload of FERAL LogicFrames will also not get checked at any point for beeing within the specification.

LIN Network Parameters

Lin networks have some general paremeters which can be set.

Parameter Value Range Default Value Description
numSlaves 0..16 2 Number of slaves in the network (additional to the master)
bitRateInBitsPerSecond 1000..20000 19200 Bitrate of the network
syncBreakLengthInBits >13 13 Length of the sync break field
syncBreakDelimiterLengthInBits 1..4 1 Length of the sync break field delimiter
timeBase 1..100ms 50ms Length of the time base as FERAL SimulationDuration
interByteSpace 0..1ms 0ms Length of the inter byte space breaks as FERAL SimulationDuration
jitterRange ([0..10ms], [0..10ms]) (0ms, 0ms) Jitter range (minVal, maxVal) as Pair<SimulationDuration, SimulationDuration>
responseSpace 0..2ms 0 Length of the response space
startingScheduleName String null Sets the name of the first schedule for the master. Doesn't need to be set, but if, the name has to start with a letter and contain only letters, numbers and underscores.

Warning

The jitter range is currently unsused and does not affect the behaviour of the simulation.

Frame Structure

Position Size Type Name Description
0-3 4 int8 InterfaceID The interface ID enables the selection of an interface. Normally, only one interface per endpoint is supported, and the interface ID is therefore 1.
4-7 4 int8 BusID The bus ID defines the bus type and the bus specific format that is used for the frame.
8 1 int8 ChannelID The channel ID enables the selection of a channel foe network configurations that support multiple channels.
9 1 int8 Direction May be used to indicate the direction of a message (TX/RX).
10 1 int8 Version Defines the version of the used message format.

Protocol-Specific Fields

Position Size Type Name Description
11 1 int8 LIN ID Contains the ID of the message as integer with value of 0..61
12 1 int8 Message Size Describes how many payload bytes this message contains as integer of 0..8
13 <Size> [int8] Payload The raw payload bytes of the message.

BusID Values

Bus ID Bus Type
1 CAN (without FD support)
2 FlexRay
3 Ethernet
4 CAN (with CANFD support)
5 LIN
6 LINPhys