Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

can interfaces not working #98

Open
oliverbl opened this issue Mar 30, 2022 · 4 comments
Open

can interfaces not working #98

oliverbl opened this issue Mar 30, 2022 · 4 comments

Comments

@oliverbl
Copy link

version: 0.18.46

I can`t initialize any can interface, the can transport module does not find any sublasses and returns an empty list

def registered_drivers():
    """
    Returns
    -------
    dict (name, class)
        Dictionary containing CAN driver names and classes of all
        available drivers (pyxcp supplied and user-defined).
    """
    sub_classes = CanInterfaceBase.__subclasses__()
    return OrderedDict(zip(([c.__name__ for c in sub_classes]), sub_classes))

I also noticed other issues:

def isExtendedIdentifier(identifier: int) -> bool:
    """Check for extendend CAN identifier.

    Parameters
    ----------
    identifier: int

    Returns
    -------
    bool
    """
    return (identifier & CAN_EXTENDED_ID) == CAN_EXTENDED_ID

IDs can be extended although they are smaller than 11bit
I think the only way to be sure is to use an additional config variable to set extended or normal IDs.

Also the SLAVE and MASTER ID seem to be used reversed:

    def transmit(self, payload):
        frame = Message(
            arbitration_id=self.parent.can_id_slave.id,
            is_extended_id=True if self.parent.can_id_slave.is_extended else False,
            is_fd=self.is_fd,
            data=payload,
        )
        self.bus.send(frame)

I think this should be the master ID

@oliverbl
Copy link
Author

The first issue can be resolved by importing the driver in the user code, for example:

import pyxcp.transport.candriver.pc_pcan

Is this how it is supposed to work? Is there documentation about this?

@oliverbl
Copy link
Author

Ok the second issue can be solved by combining the IDs with the extended bit: 0x80000000

@christoph2
Copy link
Owner

The first one was (now fixed) an installation issue, the required package python-can was missing.
Just run pip install python-can

isExtendedIdentifier works correctly, CAN_EXTENDED_ID IS defined as 0x80000000, i.e. Autosar-style.

@christoph2
Copy link
Owner

I've just added a tiny script -- pyxcp-probe-can-drivers -- giving you an overview whats on your system.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants