Skip to content

Latest commit

 

History

History
32 lines (24 loc) · 1.24 KB

python-api.md

File metadata and controls

32 lines (24 loc) · 1.24 KB

Python API

Receive Messages

Use this function to Receive CAN messages

def receive_can(device):    
    msgs, error_count = ics.get_messages(device)
    print("Received {} messages with {} errors.".format(len(msgs), error_count))
    for i, m in enumerate(msgs):
       print('Message #{}\t'.format(i+1), end='')
       print('\tArbID: {}\tData: {}'.format(hex(m.ArbIDOrHeader), [hex(x) for x in m.Data]))

Transmit Messages

Use this function to Transmit CAN messages

def transmit_can(device):
    msg = ics.SpyMessage()
    msg.ArbIDOrHeader = 0x01 # CAN Arbitration ID
    msg.Data = (1,2,3,4,5,6,7,8) # Data Bytes go here
    msg.NetworkID = ics.NETID_HSCAN # First channel of CAN
        # msg parameter here can also be a tuple of messages
    ics.transmit_messages(device, msg)

You can read the full documentation for libicsneo at https://libicsneo.readthedocs.io/en/latest/ and Python documentation at https://python-ics.readthedocs.io/en/2.15/.