hardbyte / python-can

The can package provides controller area network support for Python developers
https://python-can.readthedocs.io
GNU Lesser General Public License v3.0
1.31k stars 604 forks source link

adding a generic CANalyst-II backend #1298

Open mikisama opened 2 years ago

mikisama commented 2 years ago

Hi, guys.

Version 3.x of python-can worked well with my CANalyst-II. However, in version 4.x, I found that the backend of python-can for CANalyst-II has changed. My CANalyst-II can not work with python-can.

Would you consider adding a 'generic' CANalyst-II backend like the 3.x version?

zariiii9003 commented 2 years ago

@projectgus Could you take a look?

projectgus commented 2 years ago

Oh wow, this is very interesting! @mikisama I did not actually know there was a "genuine" CANalyst-II from ZLG available for sale.

Here's all of the versions I can find:

  1. Chuangxin Technology version. Example. Available on Taobao, Aliexpress, etc. This is the version I have.
  2. Looks the same as 1 but doesn't say "Chuangxin Technology" on the case. Example. According to Taobao sellers this is still Chuangxin Technology version, but I haven't confirmed that the USB protocol & DLL are the same. Same device also available in silver.
  3. iTek Canalyst-II. I only saw this version today. I don't know anything about it.
  4. ZLG CANalyst-II+. This product doesn't seem to be sold any more, I can't find anywhere to buy it. The ZLG official Taobao store doesn't have it. They sell the "USBCAN" device instead, and there is a PR to add support for the ZLG USBCAN.

It seems like there are two ways forward:

  1. Revert #1127 and go back to using the DLL. This will remove some things fixed in the PR, but it will mean that other "Canalyst-II" versions can work by changing the DLL.
  2. Find out what the difference in USB protocol is for the other Canalyst-II types, and add support in the Python backend. I am interested to help with this, if there are not too many different clones.

@mikisama @zariiii9003 Can you share about the exact Canalyst-II that you have? A photo, where you bought it, when you bought it, etc?

mikisama commented 2 years ago

Hi, @projectgus Thanks for your reply.

I have this one USBCAN-II

The stuff in this zip is a ZLG-compatible DLL and manual. Guangcheng Technology USBCAN Interface Function Library Instruction Manual.zip

projectgus commented 2 years ago

Thanks, that's interesting. So the one you have is actually a "ZLG USBCAN" compatible clone, not "Canalyst-II" exactly. But it all works with the same ControlCan DLL and the "CANPro" ZLG software?

The Shenyang Guangcheng Technology CAN protocol support in their documentation actually sounds better than the basic Canalyst-II protocol support which doesn't allow much detection of CAN bus errors. I am wondering if I should get one of these and write a pure Python backend for it as well. :)

I think #1209 by @keelung-yang will add support for this USBCAN device again, because this PR is using the DLL as well. It's interesting that USBCAN worked in the old versions using the DLL for canalystii backend though, I didn't know this and I don't think the maintainers knew this!

keelung-yang commented 2 years ago

As discussed with supporters from ZLG, they may use incompatible libraries just for supporting Windows/Linux or CAN/CAN-FD, or even for the same product as asked by different clients.

We also discussed Canalyst-II in python-can v3.x, and they tell me I can't use it for our USBCANFD-100U/200U. That's why I develop a new back-end: Only for Linux. On Windows they use different APIs. There are many works need to be done for support both Linux and Windows.

In short, there are huge compatibility issues among ZLG official libraries. You cannot expect compatible APIs to manipulate ZLG CAN devices, as Kvaser/Vector/Intrepid..., only if ZLG decide to develop one. Or there're many many works need to be done for compatibility.

Update:

For ZLG official Windows python-can package, you can access this page https://manual.zlg.cn/web/#/169/6075 But it's declared no sustaining anymore: https://manual.zlg.cn/web/#/169/6070

微信图片_20220507231428

微信图片_20220507231447

Nareshkumar-g commented 1 year ago

I want to use python-can [canalst-II] in pyhton 2.7, what can i do?

mikisama commented 1 year ago

I want to use python-can [canalst-II] in pyhton 2.7, what can i do?

You can try install the old version

pip install python-can==3.3.4