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

Not able to run CAN.py example file #4

Open
RajeshPolamReddy opened this issue Mar 20, 2023 · 2 comments
Open

Not able to run CAN.py example file #4

RajeshPolamReddy opened this issue Mar 20, 2023 · 2 comments

Comments

@RajeshPolamReddy
Copy link

In Back end cargo run --release -- --port 18881 is running in cmd

 Running `E:\Data\00_Projects\SiriAB\virtualcan-master\rust\target\release\virtualcan.exe --port 18881`

2023-03-21 00:23:16,808 INFO [virtualcan::server] Starting virtual can server at: 0.0.0.0:18881
2023-03-21 00:23:16,811 INFO [virtualcan::server] Bound to 0.0.0.0:18881

Iam Using VS code to run the Python example file,
Once i run this I am getting below error

[Running] python -u "e:\Data\00_Projects\SiriAB\VCAN.py"
Traceback (most recent call last):
File "e:\Data\00_Projects\SiriAB\VCAN.py", line 3, in
bus = can.Bus(interface='virtualcan', channel='localhost:18881')
File "C:\Users\Rajesh\AppData\Roaming\Python\Python310\site-packages\can\interface.py", line 108, in new
kwargs = load_config(config=kwargs, context=context)
File "C:\Users\Rajesh\AppData\Roaming\Python\Python310\site-packages\can\util.py", line 192, in load_config
bus_config = _create_bus_config(config)
File "C:\Users\Rajesh\AppData\Roaming\Python\Python310\site-packages\can\util.py", line 211, in _create_bus_config
raise CanInterfaceNotImplementedError(
can.exceptions.CanInterfaceNotImplementedError: Unknown interface type "virtualcan"

@RajeshPolamReddy
Copy link
Author

I think the interface should be virtual instead of virtualcan
bus = can.Bus(interface='virtual', channel='localhost:18881').. Once i change i see in the terminal as Done..

If I want to send the CAN data and see the data that is being sent ...
Do you have any example file to see like CAN Tx and Rx ?

@windelbouwman
Copy link
Owner

After installing virtualcan as a python module, you should use something like:

bus = can.Bus(bustype="virtualcan", channel="localhost:18881")
bus.send(can.Message(data=bytes([1, 2]))
print(bus.recv())

Note that virtual and virtualcan are different CAN drivers.

See also:
https://python-can.readthedocs.io/en/stable/virtual-interfaces.html

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