Skip to content

Set CAN Bus not working with PCANUSB #1

@jarvjani

Description

@jarvjani

Hey,
Curf.py: in set_can both self.bus and self.logbus are trying to initialize to same device. This is not possible, and will result as an error when trying to connect logbus.

I removed all the logging and got it working:
-modification in curf.py
def set_can(self, interface, channel, bitrate, db=None, test_name=None):
""" Set the CAN BUS
Keyword arguments:
interface -- can interface (socketcan, vector, ...)
channel -- can channel (can0, vcan0, ...)
bitrate -- can bitrate (125000, 500000, ...)
db -- can database (arxml,dbc,kcd,sym,cdd)
test_name -- Name of test case

    See https://cantools.readthedocs.io/en/latest/#about
    See https://python-can.readthedocs.io/en/master/interfaces.html
    """
    dt_now = dt.datetime.now()
    self.interface = interface
    self.channel = channel
    self.bitrate = bitrate
    self.db_file = db
    self.bus = can.interface.Bus(
        bustype=self.interface, channel=self.channel, bitrate=self.bitrate)
    if db is not None and db != 'None':
        self.db = cantools.database.load_file(db)
        self.db_default_node = self.db.nodes[0].name

    self.is_set = True

-modification to curf.robot

Stop CAN Bus
Stop Bus

-My can.robot test file, located outside CURF folder
*** Settings ***
Resource ./CURF/keywords/curf.robot
Test Setup Set CAN Bus ${INTERFACE} ${CHANNEL} ${BITRATE} ${DB FILE}
Test Teardown Stop CAN Bus
Library DateTime

*** Variables ***
${DB FILE} ./CURF/dbc/example.dbc
${INTERFACE} pcan
${CHANNEL} PCAN_USBBUS1
${BITRATE} 250000
${DEFAULT TIMEOUT} 3000
${DEFAULT NODE} DRIVER

*** Test Cases ***

Send a CAN frame
Send Frame With ID 0x5D3 And DEADBEEF As Data

Send a given signal
Send Signal SENSOR_SONARS_err_count With Value 0

-Proof it works:

kuva

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions