Openwide-Ingenierie / robotframework-can-uds-library

35 stars 14 forks source link

Set CAN Bus not working with PCANUSB #1

Open jarvjani opened 4 years ago

jarvjani commented 4 years ago

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

RomainNaour commented 4 years ago

Hi @jarvjani,

Thanks for the report, we'll take a look. Also, feel free to create a PR and provide a patch.

Best regards, Romain

chaillm commented 4 years ago

Hi @jarvjani,

Thanks for your report. Can you give us some additional infos? Your kernel's version and the traceback generated at runtime would be great. I've tried to reproduce the bug without success yet.

jarvjani commented 4 years ago

Hey, I am so sorry i forgot to mention even the most basic technical details. This happened when using robot framework on windows 10. This can be easily reproduced by trying to running any tests from testsuite folder on windows machine.

test.zip

Here are the files i am using, and seems to be working on both windows 10 and windows 7. Tests were done using one of these newer PCAN-USB's (IPEH-002021)

RomainNaour commented 4 years ago

Hi @jarvjani,

Sorry for the delay, we have never tested on Windows and considered to do it. I'm glad to this library used even on Windows :)

Can you create a Pull Request on github to contribute your patch?

Best regards, Romain

RomainNaour commented 4 years ago

Hi @jarvjani,

Please, create a Pull Request on github for review.

Best regards, Romain

KrishnaVinothSingh commented 5 months ago

@jarvjani How to send CAN raw data 11 bit identifier default it was in 29 bit identifier. Where i have to change Normal fixed 11bit identifier for CAN raw data???Can u please help me for above topic