canlib
1.10.102
  • Welcome
  • Supported Libraries and Installation
  • Tutorials
  • Examples
    • Create a Database
    • Monitor a Channel Using a Database
    • Examine the Contents of a Database
    • Print Information About All Channels
      • Sample Output
    • Monitor a Channel
    • Send Random Messages on a Channel
    • Validate a Memorator Configuration
    • Write a Configuration to a Memorator
  • Reference
  • Release Notes
canlib
  • Docs »
  • Examples »
  • Print Information About All Channels
  • View page source

Print Information About All Channels¶

"""list_channels.py -- List all CANlib channel

This script uses canlib.canlib to list all CANlib channels and information
about the device that is using them.

"""
import argparse

from canlib import canlib


def print_channels():
    for ch in range(canlib.getNumberOfChannels()):
        chdata = canlib.ChannelData(ch)
        print("{ch}. {name} ({ean} / {serial})".format(
            ch=ch,
            name=chdata.channel_name,
            ean=chdata.card_upc_no,
            serial=chdata.card_serial_no,
        ))


if __name__ == '__main__':
    parser = argparse.ArgumentParser(
        description="List all CANlib channels and information about them.")
    args = parser.parse_args()

    print_channels()

Sample Output¶

0. Kvaser Memorator Pro 2xHS v2 (channel 0) (73-30130-00819-9 / 10626)
1. Kvaser Memorator Pro 2xHS v2 (channel 1) (73-30130-00819-9 / 10626)
Next Previous

© Copyright 2019 Kvaser AB Last updated on Sun, 12 May 2019.

Built with Sphinx using a theme provided by Read the Docs.