LIN Tutorial

Scripting

Receiving and sending LIN messages

  1. To send or receive LIN messages, it is necessary to configure the Hardware device first. It can be a CAN case device. Once the device is configured and assigned to a communication channel, it is possible to send and receive LIN messages.

  2. Scripting part simulates only the Master mode. We can send only LIN requests (LIN header)

Capture LIN messages

def tc_prepare_capture(msg, call_back_function):
    msg.on_message_received += call_back_function
    msg.start_capture()
    return
    
def on_msg_received(msg):
    print(msg)

lin_msg = message_builder.create_lin_message(channel_01.name, channel_01.name)
tc_prepare_capture(lin_msg, on_msg_received)
print("Verify LIN message... ")
tc_wait_for_return(1000)

Send LIN message

def initialize_lin_message(lin_msg, lin_id, lin_length):
    lin_msg.lin_header.message_id = lin_id
    lin_msg.lin_header.length = lin_length

ID = 0x07
LENGTH = 0x08

lin_msg = message_builder.create_lin_message(channel_01.name, channel_01.name)
print("Initialize LIN message...")
initialize_lin_message(lin_msg, ID, LENGTH)
print("Send LIN message...")
lin_msg.send()
tc_wait_for_return(1000)

Database

see details in LIN Database.