cmcerove / pyvxl

A python library for working with the CAN bus through Vector's vxlAPI.dll
MIT License
16 stars 5 forks source link

Using pyvxl for the vector xl hardware (VN1640A) #4

Closed DonByte97 closed 1 year ago

DonByte97 commented 2 years ago

Hello,

a friend of mine and me are trying to use your package for CAN-Communication on a VN1640A but we arent really sure how to do it. After installing the package via the .bat file, we tried to follow the flowchart for can-comunication and looking for the commands in the package to use them but we weren't succsesfull.

Is it neccessary to got by the flowchart(open the port and activate the channel by hand) and if yes, how and which commands have to be used?

cmcerove commented 2 years ago

Hi @DonByte97,

Sorry for the lack of examples and documentation to get you started. Here's a simple example:

from pyvxl import CAN

can = CAN()

# Connect to channel 2 and associate test_dbc.dbc with this channel. If you only have a single Vector box 
# connected to your PC, this number should match the numbers printed on the case. If you have more than
# one connected, you can find this number through Vector Hardware Config in the control panel.
# This dbc can be found here https://github.com/cmcerove/pyvxl/tree/develop/pyvxl/tests.
can2 = can.add_channel(num=2, db='test_dbc.dbc')

# Send a message from the imported test_dbc.dbc. This message is periodic and will continue
#  to be transmitted every 50ms after this point. 
can2.send_message('msg2')

# Stop the periodic message
can2.stop_message('msg2')

Ideally you wouldn't need to worry about the flowchart in Vector's documentation since CAN should handle that by managing the connection to Vxl which is the lower level wrapper for the DLL. I'm sure there are bugs though so please let me know if something wasn't obvious or if something could be improved.

There are a few more examples in https://github.com/cmcerove/pyvxl/blob/develop/pyvxl/tests/test_can.py

I also apologize for the slow response. I haven't had much free time lately.

DonByte97 commented 2 years ago

Hi @cmcerove !

Thank you very much for your answer and the example on how to use your package for CAN Communication with the Vector Hardware.

I am going to try it out the next days and I'll let you know if bugs appear or if I have further questions.

The other thing is, that we also want to try out LIN Communication, but you mentioned that this isnt implemented in your package so far.

Is there any chance that this feature is implemented soon or can you tell us how to implement it ourselves?

cmcerove commented 2 years ago

Implementing LIN wasn't planned anytime soon. I might be able to give you an example to get you started if I can find it. The only time I needed it in the past was to check that a specific value was transmitted on the bus.

DonByte97 commented 2 years ago

Would be really great, if you can find the example for LIN. Thanks a lot!

cmcerove commented 2 years ago

I found the old code I was thinking about but pyvxl has changed so much since then it's probably more confusing than helpful. If you have trouble implementing it, let me know and I might be able to point you in the right direction.