Skip to content

Custom Interfaces #1311

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

Closed
jagauthier opened this issue May 10, 2022 · 4 comments
Closed

Custom Interfaces #1311

jagauthier opened this issue May 10, 2022 · 4 comments
Labels

Comments

@jagauthier
Copy link

Hello,

There is documentation about some custom interface here:
https://python-can.readthedocs.io/en/develop/interfaces.html

Given these two issues:
#1110
#1233

Is this method still valid?

I really don't quite understand how to implement a custom interface. It's a bit deeper into Python than I usually get.
So, I'm looking for a little guidance. IE: I've copied over an existing interface and I am going to modify it.

@jagauthier jagauthier added the bug label May 10, 2022
@zariiii9003
Copy link
Collaborator

The docs should still be valid.

@zariiii9003 zariiii9003 added question and removed bug labels May 19, 2022
@jagauthier
Copy link
Author

jagauthier commented May 23, 2022

Thanks. I've never created an installable python module. I went through the docs, and I did it. I added
entry_points={
'can.interface': [
"slcan_custom=slcan_custom:slcan_customBus",
]
},

to the setup.py file in the setuptools.setup() function.

I created a small virtualenv, and tried to use it:
bus = can.interface.Bus(bustype='slcan_custom', bitrate=500000, channel='/dev/tty0')

But I get this:
can.exceptions.CanInterfaceNotImplementedError: Cannot import class slcan_customBus from module slcan_customfor CAN interface 'slcan_custom': module 'slcan_custom' has no attribute 'slcan_customBus'

I looked at some of the other interfaces, and they seem to have something in __init__.py, like such:
from .slcan_custom import slcan_customBus

But that only gives me an error about top level imports.
attempted relative import beyond top-level package

@zariiii9003
Copy link
Collaborator

Your project structure is probably incorrect. Once you install your own package, you should be able to run from slcan_custom import slcan_customBus from a script. If that fails, then python-can will not be able to import your class either.

@jagauthier
Copy link
Author

Yup, and I cannot do that either. I will re-evaluate the structure and try to figure it out. Python's import nuances have never been a strength for me. Like.. apparently, trying to do the import forces __init__.py to run, when I look at the other interfaces, seems to do the import as well. Well, thanks. I will continue to fight it!

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

No branches or pull requests

2 participants