Coder Social home page Coder Social logo

robotframework-can-uds-library's Introduction

CURF

CAN UDS for Robot Framework

CAN BUS with ISO-14229 implementation RobotFramework Library

The goal of this Robotframework Library is testing CAN BUS with RobotFramework

CAN, UDS and ISO-TP Reminder

They are a lot of CAN protocols and it can be confusing.

CAN (ISO-11898) was released in 1991 and the main limit is the size of payload (8 Bytes) by frame.

ISO-TP (ISO 15765-2) TP means 'Transport Layer' was introducted in 2016. The main goal is the transfer of longer messages over CAN into multiples frames, adding metadata that allows the interpretation of individual frames and reassembly into a complete message packet by the recipient. It can carry up to 4095 bytes of payload per message packet.

UDS (ISO 14229-1) Unified Diagnostic Services is a communication protocol, Unified means that is an international and not company specific standard. This standard use ISO-TP.

Compatibility

This RobotFramework library is cross-platform (tested under Debian9, and Windows 10)

The library use python-can to support CAN interface the interfaces linked here must be compatibles.

The library use isotp to handle ISO-15765 protocol

The library use cantools to encoding/decoding CAN Database, see here to find compatible format

Requirements

They are a few dependencies, the library must work in Linux and Windows

pip install robotframework
pip install python-can
pip install cantools
pip install can-isotp

Use

See testsuite/test.robot

All test must start with

Set CAN Bus ${INTERFACE} ${CHANNEL} ${BITRATE} ${DB FILE}

So the best can be to instanciate it with 'Test Setup'

Before using ISO-TP/UDS specific keywords you must instanciate it as follow:

Set ISOTP Protocol ${SOURCE} ${DESTINATION} ${ADDRESSING MODE}

robotframework-can-uds-library's People

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

robotframework-can-uds-library's Issues

Closing the CAN connection

Hello, I am using data driver to read DID's from CSV file with CURF, but soon after 32 connection i start getting

VectorError: xlGetChannelIndex failed (XL_ERR_HW_NOT_PRESENT)

which i believe is because of set can bus at the start of every test setup and not closing the channel. I am enclosing my code below. Please help.

`*** Settings ***
Documentation Theses test cases are to check the valid responses for the ECU Identification
Resource ../keywords/curf.robot
Resource ../keywords/UDS_Variables.robot

Test Setup Set CAN Bus ${INTERFACE} ${CHANNEL} ${BITRATE} ${DB FILE}
Test Teardown End Log Can

Library DateTime
Library DataDriver ../data/Service_22_ECU_Identification.csv

Test Template ReportDID_22

*** Variables ***

*** Test Cases ***
Log ReadDataByIdentifier_ECU_Identification_${RDI_22} ${RDI_22}

*** Keywords ***
ReportDID_22
[Arguments] ${RDI_22}
Set ISOTP Protocol ${SOURCE} ${DESTINATION} ${ADDRESSING MODE}
${RES} = Report DID ${RDI_22}
Log ${RES}`

Features / modifications / suggestions?

I did not see a 'discussion' item under the project...

I'd like to create use more of the raw CAN and J1939 style periodic messages. I can modify the CURFLibrary to add a modifiable method. However, the cantools python package does not support this as the messages are 'encoded' and only the can library supports modifying a period message.

Suggestions on how to include an extra function such as ramping a signal? (this is a complication of the first item). I'd like to specify ramping a signal or signals in a periodic message, given a starting value and ending value, and a time or rate. As I'm new to Robot I do not know how the execution occurs and details on the architecture. My first thought was a task / thread that updated the periodic message ever xyz mSec.

Quick idea on what the Robot top level looks like:
*** Test Cases ***
Create Modifiable Periodic Frame
Start Modifiable Transmission of Message ETC1 And Set1 As Data With 0.1 Seconds Periodic
Waiting 5 Seconds
Start SignalRamping of TransmissionInputShaftSpeed As Data [700,100] With 5 Seconds
Waiting 6 Seconds
...

Suggestions on supporting more than 1 database or CAN bus channel? I do not believe the cantools supports more than 1 database. I can merge databases, but this is not ideal. A complication may also be source addresses in J1939 messaging. A database signal, but no source address means if I have a system with more than one device transmitting a message, I cannot know the difference between messages. I could define the database with unique identifiers for every signal, but this may be a bit time consuming. Suggestions?

Any chance you may expand the library to include support for the SAE J1939 transport protocol? It's similar to the ISO, but slightly different. I'm looking for DM1 multi-packet support and the DM14 / 15 / 16 memory transfer features only. The DM14 - 16 typically use a seed / key mechanism to control access and a RTS / CTS identification. These are secondary to my possible usage, but thought I would inquire. Depending on how the above plays out and if I can actually use Robot with the CAN bus for testing means I could potentially write routines for these features as well.

Cheers
J -

Padding of transmitted isotp messages simplifies usage

Many thanks for the great library, which saves us a lot of time.

During a proof of concept we stumbled upon a problem, which could be only resolved by changing the Curf.py a bit.

Can you please change the following line in Curf.py on line 213, so that messages not fitting an 8 Byte Can-Frame are automatically filled up with padding bytes:

self.isotp_stack = isotp.CanStack(
     bus=self.bus, 
     address=self.isotp_addr,  
     error_handler=self.curf_error_handler, 
     params = {"tx_padding":0x55}) 

Windows 10 Permission Error 13

I ran into issues with the demo Sample on a lawicel CANUSB Dongle.

using slcan with COM10 on windows.

Testcase looks like

*** Settings ***
Resource      CURF/keywords/curf.robot
Test Setup      Set CAN Bus ${INTERFACE} ${CHANNEL} ${BITRATE} ${DB FILE} 
Test Teardown   End Log Can 
Library    DateTime

*** Variables ***
${DB FILE}              None
${INTERFACE}            slcan
${CHANNEL}              COM10
${BITRATE}              500000
${DEFAULT TIMEOUT}      3
${DEFAULT NODE}         DRIVER


*** Test Cases ***
Log Next Raw Frame
    ${Next_Frame} =     Get Next Raw Can Frame
    Log       ${Next_Frame}

The Output is:

robot can.robot

==============================================================================
Can
==============================================================================
Log Next Raw Frame                                                    | FAIL |
Setup failed:
SerialException: could not open port 'COM10': PermissionError(13, 'Zugriff verweigert', None, 5)

Also teardown failed:
AttributeError: 'Curf' object has no attribute 'notifier'

If i use the python-can directly, i have no issues to send a message over can:

import can
can.rc['interface'] = 'slcan'
can.rc['channel'] = 'COM10'
can.rc['bitrate'] = 500000
from can.interface import Bus

bus = can.interface.Bus(bustype="slcan", channel="COM10") 

tx_msg = can.Message(
    arbitration_id=0x01,
    data=[0x11, 0x22, 0x33, 0x44, 0x55, 0x66, 0x77, 0x88],
 )
bus.send(tx_msg)

print("Stopped sending messages")

I looks like this is not a general problem on sending can messages from windows with the device.

Set CAN Bus not working with PCANUSB

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

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.