linklayer / cantact

Drivers and Command Line Interface for CANtact tools
http://cantact.io
MIT License
46 stars 12 forks source link

python-can documentation on Crowdsupply is outdated/broken/misleading #13

Closed brainstorm closed 3 years ago

brainstorm commented 3 years ago

Docs in the CrowdSupply campaign state:

So how can we use this in practice? After installing the python-can and cantact packages using pip, the built-in scripts can be used to test the installation. To show messages received on CANtact channel 0:

pip install python-can==4.0.0.dev0 cantact can_logger.py -i cantact -c0

There’s also a complete example of sending frames using python-can and CANtact.

In practice:

% pip install python-can==4.0.0.dev0 cantact
Collecting python-can==4.0.0.dev0
  Downloading python-can-4.0.0.dev0.tar.gz (206 kB)
     |████████████████████████████████| 206 kB 1.9 MB/s
  Installing build dependencies ... done
  Getting requirements to build wheel ... done
    Preparing wheel metadata ... done
Requirement already satisfied: cantact in /Users/rvalls/dev/personal/cantact/driver (0.0.7)
Collecting filelock
  Downloading filelock-3.0.12-py3-none-any.whl (7.6 kB)
Requirement already satisfied: wrapt~=1.10 in /Users/rvalls/.mambaforge/envs/reveng/lib/python3.9/site-packages (from python-can==4.0.0.dev0) (1.12.1)
Collecting mypy-extensions<0.5.0,>=0.4.0
  Downloading mypy_extensions-0.4.3-py2.py3-none-any.whl (4.5 kB)
Requirement already satisfied: aenum in /Users/rvalls/.mambaforge/envs/reveng/lib/python3.9/site-packages (from python-can==4.0.0.dev0) (3.0.0)
Building wheels for collected packages: python-can
  Building wheel for python-can (PEP 517) ... done
  Created wheel for python-can: filename=python_can-4.0.0.dev0-py3-none-any.whl size=174567 sha256=7674d6e8aaa4e1f84dda04cc114ea94b9fbf532ac4c1ff33bd80d7556812f590
  Stored in directory: /Users/rvalls/Library/Caches/pip/wheels/4a/fd/a5/c4b3084f0b21321a1c0ca1bdd2a53453b680d820051b31853d
Successfully built python-can
Installing collected packages: mypy-extensions, filelock, python-can
  Attempting uninstall: python-can
    Found existing installation: python-can 3.3.4
    Uninstalling python-can-3.3.4:
      Successfully uninstalled python-can-3.3.4
Successfully installed filelock-3.0.12 mypy-extensions-0.4.3 python-can-4.0.0.dev0
(reveng) rvalls@m1 can_scripts % can_logger.py -i cantact -c0
usage: python -m can.logger [-h] [-f LOG_FILE] [-v] [-c CHANNEL]
                            [-i {socketcan,iscan,slcan,serial,kvaser,virtual,pcan,systec,neovi,seeedstudio,robotell,nican,ixxat,vector,usb2can,canalystii}]
                            [--filter ...] [-b BITRATE] [--fd] [--data_bitrate DATA_BITRATE] [--active | --passive]
python -m can.logger: error: argument -i/--interface: invalid choice: 'cantact' (choose from 'socketcan', 'iscan', 'slcan', 'serial', 'kvaser', 'virtual', 'pcan', 'systec', 'neovi', 'seeedstudio', 'robotell', 'nican', 'ixxat', 'vector', 'usb2can', 'canalystii')

But then installing from develop directly from upstream, namely:

% git clone https://github.com/hardbyte/python-can.git
Cloning into 'python-can'...
remote: Enumerating objects: 13453, done.
remote: Counting objects: 100% (327/327), done.
remote: Compressing objects: 100% (224/224), done.
remote: Total 13453 (delta 196), reused 172 (delta 96), pack-reused 13126
Receiving objects: 100% (13453/13453), 4.19 MiB | 1.60 MiB/s, done.
Resolving deltas: 100% (9758/9758), done.
(reveng) rvalls@m1 can_scripts % cd python-can
(reveng) rvalls@m1 python-can % pip install -e .
Obtaining file:///Users/rvalls/dev/personal/can_scripts/python-can
  Installing build dependencies ... done
  Getting requirements to build wheel ... done
    Preparing wheel metadata ... done
Requirement already satisfied: wrapt~=1.10 in /Users/rvalls/.mambaforge/envs/reveng/lib/python3.9/site-packages (from python-can==4.0.0.dev0) (1.12.1)
Collecting msgpack~=1.0.0
  Downloading msgpack-1.0.2.tar.gz (123 kB)
     |████████████████████████████████| 123 kB 1.7 MB/s
Requirement already satisfied: mypy-extensions<0.5.0,>=0.4.0 in /Users/rvalls/.mambaforge/envs/reveng/lib/python3.9/site-packages (from python-can==4.0.0.dev0) (0.4.3)
Building wheels for collected packages: msgpack
  Building wheel for msgpack (setup.py) ... done
  Created wheel for msgpack: filename=msgpack-1.0.2-cp39-cp39-macosx_11_0_arm64.whl size=69154 sha256=72b28f8abf1e9aa335785fb9fe881742b51788b30504d2bff6ac6b4d4f23909b
  Stored in directory: /Users/rvalls/Library/Caches/pip/wheels/30/52/01/57e347f8406cc2b7e19d8f94394d5b7cd51763f8620541a906
Successfully built msgpack
Installing collected packages: msgpack, python-can
  Running setup.py develop for python-can
Successfully installed msgpack-1.0.2 python-can

It works fine as demonstrated in issue #12

ericevenchick commented 3 years ago

The CLI provided by python-can needs the develop branch to have the cantact option. I've updated the documentation @ https://cantact.io/apis/python.html based on your findings.

Thanks for your help with improving documentation 😃