Giter Club home page Giter Club logo

cantact's People

Contributors

ericevenchick avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

cantact's Issues

No input validation on ./can send

Using a purchased Cantact Pro here...

cantact % ./target/debug/can send 0 CFE6CEB CACA
thread 'main' panicked at 'range end index 64 out of range for slice of length 0', driver/src/lib.rs:100:38
note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace
zsh: segmentation fault  ./target/debug/can send 0 CFE6CEB CACA

Bad input should return a Result<Err> with a helpful error message instead of panic-ing... also, I'd appreciate some example of send command (with output) in the docs :-S

CLI 'can send 0 0 0' can't work on windows

can send 0 0 0
thread 'main' panicked at 'range end index 64 out of range for slice of length 0', driver\src\lib.rs:100:38

quite simple to reproduce

  1. Install cargo and driver 0.1.0
  2. plug in CANtact pro
  3. can --help looks ok
  4. can send 0 0 0

error: failed to compile `cantact v0.1.2`

warning: build failed, waiting for other jobs to finish...
error: failed to compile cantact v0.1.2, intermediate artifacts can be found at /tmp/cargo-installiRibaI

"gs_usb 1-1.3:1.0 can0: Unexpected out of range echo id -256" and "can-isotp: isotp_sendmsg: can_send_ret -105"

After stressing CANTACT PRO a bit with a variant of this example but in a loop (I might post a code snippet/reproducer a bit later on):

https://github.com/marcelbuesing/socketcan-isotp/blob/master/examples/uds.rs

I've noticed the following messages in the kernel's dmesg and the interface itself stopped responding until I ran ifconfig can0 down && ifconfig can0 up again (cantact lights still on, unlike #18):

[   47.392807] IPv6: ADDRCONF(NETDEV_CHANGE): can0: link becomes ready
[38995.821664] can: controller area network core
[38995.821882] NET: Registered protocol family 29
[38995.901358] can: isotp protocol
[39852.713297] can: raw protocol
[473518.169804] gs_usb 1-1.3:1.0 can0: Unexpected out of range echo id -256
[473584.371852] gs_usb 1-1.3:1.0 can0: Unexpected out of range echo id -256
[473810.879016] gs_usb 1-1.3:1.0 can0: Unexpected out of range echo id -256
[473941.703153] gs_usb 1-1.3:1.0 can0: Unexpected out of range echo id -256
[474007.845229] gs_usb 1-1.3:1.0 can0: Unexpected out of range echo id -256
[474290.224146] gs_usb 1-1.3:1.0 can0: Unexpected out of range echo id -256
[474513.851197] gs_usb 1-1.3:1.0 can0: Unexpected out of range echo id -256
[474648.135451] gs_usb 1-1.3:1.0 can0: Unexpected out of range echo id -256
[474889.043020] gs_usb 1-1.3:1.0 can0: Unexpected out of range echo id -256
[474978.185816] gs_usb 1-1.3:1.0 can0: Unexpected out of range echo id -256
[475533.573321] gs_usb 1-1.3:1.0 can0: Unexpected out of range echo id -256
[475554.653991] gs_usb 1-1.3:1.0 can0: Unexpected out of range echo id -256
[475610.035753] gs_usb 1-1.3:1.0 can0: Unexpected out of range echo id -256
[475678.947905] gs_usb 1-1.3:1.0 can0: Unexpected out of range echo id -256
[475750.750761] gs_usb 1-1.3:1.0 can0: Unexpected out of range echo id -256
[476028.188951] gs_usb 1-1.3:1.0 can0: Unexpected out of range echo id -256
[476589.216530] gs_usb 1-1.3:1.0 can0: Unexpected out of range echo id -256
[476596.816784] gs_usb 1-1.3:1.0 can0: Unexpected out of range echo id -256
[476756.341799] gs_usb 1-1.3:1.0 can0: Unexpected out of range echo id -256
[476977.998761] gs_usb 1-1.3:1.0 can0: Unexpected out of range echo id -256
[477472.744351] gs_usb 1-1.3:1.0 can0: Unexpected out of range echo id -256
[477562.907198] gs_usb 1-1.3:1.0 can0: Unexpected out of range echo id -256
[477701.451518] gs_usb 1-1.3:1.0 can0: Unexpected out of range echo id -256
[477890.817515] gs_usb 1-1.3:1.0 can0: Unexpected out of range echo id -256
[477897.757707] gs_usb 1-1.3:1.0 can0: Unexpected out of range echo id -256
[478027.081779] gs_usb 1-1.3:1.0 can0: Unexpected out of range echo id -256
[478593.949573] gs_usb 1-1.3:1.0 can0: Unexpected out of range echo id -256
[478784.846110] gs_usb 1-1.3:1.0 can0: Unexpected out of range echo id -256
[478870.638308] gs_usb 1-1.3:1.0 can0: Unexpected out of range echo id -256
[479166.887624] gs_usb 1-1.3:1.0 can0: Unexpected out of range echo id -256
[479349.933427] gs_usb 1-1.3:1.0 can0: Unexpected out of range echo id -256
[479479.337485] gs_usb 1-1.3:1.0 can0: Unexpected out of range echo id -256
[479566.140243] gs_usb 1-1.3:1.0 can0: Unexpected out of range echo id -256
[479965.132743] gs_usb 1-1.3:1.0 can0: Unexpected out of range echo id -256
[479965.892780] gs_usb 1-1.3:1.0 can0: Unexpected out of range echo id -256
[480173.439339] gs_usb 1-1.3:1.0 can0: Unexpected out of range echo id -256
[483751.450487] can-isotp: isotp_sendmsg: can_send_ret -105
[486722.405717] gs_usb 1-1.3:1.0 can0: Unexpected out of range echo id -256
[486856.759953] gs_usb 1-1.3:1.0 can0: Unexpected out of range echo id -256

I'm running on a RPi1 with kernel:

Linux raspberrypi 5.10.17+ #1421 Thu May 27 13:58:02 BST 2021 armv6l GNU/Linux

Did you experience this in any of your tests with ISOTP payloads, @ericevenchick? @hartkopp Have you seen that -105 ret code and what could be the underlying issue?

And @HubertD or @marckleinebudde, have you seen those "Unexpected out of range echo id -256" in any other device(s) you've tested with your gs_usb lkm?

Device not found

@ericevenchick This is a followup on issue #3 , I'm not finding my cantact device with the python interface either:

$ pip install cantact

(...all ok...)

$ ipython
Python 3.7.9 | packaged by conda-forge | (default, Dec  9 2020, 20:58:55) 
Type "copyright", "credits" or "license" for more information.

IPython 5.8.0 -- An enhanced Interactive Python.
?         -> Introduction and overview of IPython's features.
%quickref -> Quick reference.
help      -> Python's own help system.
object?   -> Details about 'object', use 'object??' for extra details.

In [1]: import cantact

In [2]: foo = cantact.Interface()
---------------------------------------------------------------------------
SystemError                               Traceback (most recent call last)
<ipython-input-2-c321422b385c> in <module>()
----> 1 foo = cantact.Interface()

SystemError: DeviceNotFound

As mentioned on issue #3 , I'm testing cantact in a STM32F042G6 board since I bought the cantact-pro and I'd like to be familiar when it arrives.

Happy to debug/test it further for you, hints on what might be going on appreciated though ;)

Building Cantact.dll

I'm trying to build a Cantact.dll in x64
(Actually I need to wrap it in .NET for an x64 .NET project)

I can find an x86 version of cantact.dll in the cantact branch of your busmaster fork
Also I can see in this repo there is the driver/src/c/mod.rs which seems to be the source code for cantact.dll

However, I'm not sure how to build this to x64
When I try to build the repo with cargo i get the following errors:

C:\dev\cantact>cargo install --path .
  Installing cantact v0.0.7 (C:\dev\cantact)
    Updating crates.io index
   Compiling winapi v0.3.9
   Compiling autocfg v1.0.1
   Compiling proc-macro2 v1.0.24
   Compiling unicode-xid v0.2.1
   Compiling syn v1.0.48
   Compiling cfg-if v1.0.0
   Compiling crc32fast v1.2.1
   Compiling version_check v0.9.2
   Compiling winapi-build v0.1.1
   Compiling libc v0.2.80
   Compiling take_mut v0.2.2
   Compiling rle-decode-fast v1.0.1
   Compiling adler32 v1.2.0
   Compiling cfg-if v0.1.10
   Compiling vcpkg v0.2.10
   Compiling cc v1.0.62
   Compiling pkg-config v0.3.19
   Compiling serde_derive v1.0.117
   Compiling serde v1.0.117
   Compiling lazy_static v1.4.0
   Compiling maybe-uninit v2.0.0
   Compiling bitflags v1.2.1
   Compiling winapi v0.2.8
   Compiling unicode-segmentation v1.7.0
   Compiling log v0.4.11
   Compiling linked-hash-map v0.5.3
   Compiling hashbrown v0.9.1
   Compiling cantact-driver v0.0.7 (C:\dev\cantact\driver)
   Compiling unicode-width v0.1.8
   Compiling strsim v0.10.0
   Compiling os_str_bytes v2.4.0
   Compiling vec_map v0.8.2
   Compiling textwrap v0.12.1
   Compiling yaml-rust v0.4.4
   Compiling shell32-sys v0.1.2
   Compiling ole32-sys v0.2.0
   Compiling proc-macro-error-attr v1.0.4
   Compiling proc-macro-error v1.0.4
   Compiling num-traits v0.2.14
   Compiling crossbeam-utils v0.7.2
   Compiling num-integer v0.1.44
   Compiling indexmap v1.6.0
   Compiling heck v0.3.1
   Compiling libflate v0.1.27
   Compiling quote v1.0.7
   Compiling crossbeam-channel v0.4.4
   Compiling winapi-util v0.1.5
   Compiling time v0.1.44
   Compiling atty v0.2.14
   Compiling ctrlc v3.1.7
   Compiling filetime v0.2.13
   Compiling termcolor v1.1.0
   Compiling tar v0.4.30
   Compiling chrono v0.4.19
   Compiling libusb1-sys v0.3.7
   Compiling simplelog v0.8.0
   Compiling clap_derive v3.0.0-beta.2
   Compiling clap v3.0.0-beta.2
   Compiling app_dirs v1.2.1
   Compiling toml v0.5.7
   Compiling cantact v0.0.7 (C:\dev\cantact)
error[E0308]: mismatched types
  --> src/main.rs:37:9
   |
36 |     let result = match matches.subcommand() {
   |                        -------------------- this expression has type `std::option::Option<(&str, &clap::ArgMatches)>`
37 |         ("dump", Some(m)) => dump::cmd(m),
   |         ^^^^^^^^^^^^^^^^^ expected enum `std::option::Option`, found tuple
   |
   = note: expected enum `std::option::Option<(&str, &clap::ArgMatches)>`
             found tuple `(_, _)`

error[E0308]: mismatched types
  --> src/main.rs:38:9
   |
36 |     let result = match matches.subcommand() {
   |                        -------------------- this expression has type `std::option::Option<(&str, &clap::ArgMatches)>`
37 |         ("dump", Some(m)) => dump::cmd(m),
38 |         ("send", Some(m)) => send::cmd(m),
   |         ^^^^^^^^^^^^^^^^^ expected enum `std::option::Option`, found tuple
   |
   = note: expected enum `std::option::Option<(&str, &clap::ArgMatches)>`
             found tuple `(_, _)`

error[E0308]: mismatched types
  --> src/main.rs:39:9
   |
36 |     let result = match matches.subcommand() {
   |                        -------------------- this expression has type `std::option::Option<(&str, &clap::ArgMatches)>`
...
39 |         ("cfg", Some(m)) => cfg::cmd(m),
   |         ^^^^^^^^^^^^^^^^ expected enum `std::option::Option`, found tuple
   |
   = note: expected enum `std::option::Option<(&str, &clap::ArgMatches)>`
             found tuple `(_, _)`

error: aborting due to 3 previous errors

For more information about this error, try `rustc --explain E0308`.
error: failed to compile `cantact v0.0.7 (C:\dev\cantact)`, intermediate artifacts can be found at `C:\dev\cantact\target`

Caused by:
  could not compile `cantact`.

To learn more, run the command again with --verbose.

I will keep trying here

Using cantact in a virtual machine

Hello,

I'm using cantact in my virtual machine and I'm having the problem that it recognizes the device, but I don't see the can0 interface.

image
image

How can I fix it so that the can0 interface appears?

send_one.py does not work

https://github.com/linklayer/cantact/blob/master/driver/examples/send_one.py

% ./send_one.py
thread '<unnamed>' panicked at 'index out of bounds: the len is 0 but the index is 0', driver/src/python.rs:128:13
note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace
Traceback (most recent call last):
  File "/Users/rvalls/dev/personal/can_scripts/./send_one.py", line 33, in <module>
    send_one()
  File "/Users/rvalls/dev/personal/can_scripts/./send_one.py", line 26, in send_one
    bus.send(msg)
  File "/Users/rvalls/dev/personal/can_scripts/python-can/can/interfaces/cantact.py", line 106, in send
    self.interface.send(
pyo3_runtime.PanicException: index out of bounds: the len is 0 but the index is 0
zsh: segmentation fault  ./send_one.py

Device not found Error

On Ubuntu, when I run can -v dump I get a Device not found Error. ifconfig -a shows can0. The red AND green lights are on, on the cantact.

bitrate can be changed but data_bitrate cannot?

There's a -b bitrate flag, but I'm confused on what data_bitrate actually means ... plus it cannot be changed? Cannot find explanation in docs either.

% ./target/debug/can cfg -h
can-cfg
Set device configurations

USAGE:
    can cfg [FLAGS] [OPTIONS]

FLAGS:
    -d, --disable     Disable this channel
    -f, --fd          Enable CAN-FD mode
    -h, --help        Prints help information
    -l, --loopback    Enable hardware loopback mode
    -m, --monitor     Enable monitor (listen only) mode
    -V, --version     Prints version information

OPTIONS:
    -b, --bitrate <bitrate>    Channel bitrate in bits/second
    -c, --channel <channel>    Channel to configure


% ./target/debug/can cfg -c 0 -b 500000
Channels:
	0 -> Channel { bitrate: 500000, enabled: true, loopback: false, monitor: false, fd: false, data_bitrate: 500000 }
	1 -> Channel { bitrate: 500000, enabled: true, loopback: false, monitor: false, fd: false, data_bitrate: 500000 }

% ./target/debug/can cfg -c 0 -b 250000
Channels:
	0 -> Channel { bitrate: 250000, enabled: true, loopback: false, monitor: false, fd: false, data_bitrate: 500000 }
	1 -> Channel { bitrate: 500000, enabled: true, loopback: false, monitor: false, fd: false, data_bitrate: 500000 }

CantactPRO CLI does not install on Ubuntu

Tried installing Cantact PRO CLI as mentioned at https://contact.io, got the following errors (see screenshots)

below is the version info:
testuser@testLat7480:~$ cat /etc/os-release | grep VERSION
VERSION="20.04.1 LTS (Focal Fossa)"
VERSION_ID="20.04"
VERSION_CODENAME=focal
Cantact1Error
Cantact2Error
Cantact3Error

cantact 0.0.6 Fails to Compile

Trying to install the CLI

cargo install cantact

yields

error[E0308]: mismatched types
  --> /Users/Caleb/.cargo/registry/src/github.com-1ecc6299db9ec823/cantact-0.0.6/src/main.rs:37:9
   |
36 |     let result = match matches.subcommand() {
   |                        -------------------- this expression has type `std::option::Option<(&str, &ArgMatches)>`
37 |         ("dump", Some(m)) => dump::cmd(m),
   |         ^^^^^^^^^^^^^^^^^ expected enum `std::option::Option`, found tuple
   |
   = note: expected enum `std::option::Option<(&str, &ArgMatches)>`
             found tuple `(_, _)`

error[E0308]: mismatched types
  --> /Users/Caleb/.cargo/registry/src/github.com-1ecc6299db9ec823/cantact-0.0.6/src/main.rs:38:9
   |
36 |     let result = match matches.subcommand() {
   |                        -------------------- this expression has type `std::option::Option<(&str, &ArgMatches)>`
37 |         ("dump", Some(m)) => dump::cmd(m),
38 |         ("send", Some(m)) => send::cmd(m),
   |         ^^^^^^^^^^^^^^^^^ expected enum `std::option::Option`, found tuple
   |
   = note: expected enum `std::option::Option<(&str, &ArgMatches)>`
             found tuple `(_, _)`

error[E0308]: mismatched types
  --> /Users/Caleb/.cargo/registry/src/github.com-1ecc6299db9ec823/cantact-0.0.6/src/main.rs:39:9
   |
36 |     let result = match matches.subcommand() {
   |                        -------------------- this expression has type `std::option::Option<(&str, &ArgMatches)>`
...
39 |         ("cfg", Some(m)) => cfg::cmd(m),
   |         ^^^^^^^^^^^^^^^^ expected enum `std::option::Option`, found tuple
   |
   = note: expected enum `std::option::Option<(&str, &ArgMatches)>`
             found tuple `(_, _)`

error: aborting due to 3 previous errors

For more information about this error, try `rustc --explain E0308`.
error: failed to compile `cantact v0.0.6`, intermediate artifacts can be found at `/var/folders/q8/htqqyj350d930yhcyk8d64t00000gn/T/cargo-installOcoO31`

Caused by:
  could not compile `cantact`

Not finding CANable device on Windows, Python 3.7

Hello. I am attempting to use this library to automate some of my hardware testing with the CANable device I have using Python. At first I tried using python-can and the SLCAN interface but I was not able to get that interface to work.

I then downloaded the https://github.com/ericevenchick/python-can/tree/cantact fork of python-can to attempt to use the native cantact interface. This didn't work either as Python would tell me that Relative module names not supported Which happened even if I just went into the Python REPL and ran

import can
can.interface.Bus("cantact", channel="COM8", bitrate=1000000)

Which after running the second line it would then error with the relative module error. So this issue could also be on that fork. I then just tried make it work with the base cantact API, so I just ran:

import cantact
cantact.Interface()

And it errored with SystemError: DeviceNotFound. I attempted to unplug and replug the CANable device as well as restart my computer and the issue persisted. If I opened the Windows Device Manager I was able to see that it recognized the device was plugged into the COM8 port, so I am not quite sure on what is happening and my Rust skills are not good enough to debug that side of this library.

Thanks for any help you can provice.

Cantact C reference

Heya !

So now I'm trying to get things working in a simple C/C++ app which imports the DLL
Some functions work (Receive callback, counting devices).
But the device crashes when sending a message with transmit.

My code is here:
https://github.com/elliotwoods/Cantact.NET/blob/master/NativeTest/CantactNativeTest.cpp
I used the BusMaster implementation as a reference.

Sending messages works in cangaroo for me, but I noticed that they use their own driver code there:
https://github.com/HubertD/cangaroo/tree/master/src/driver/CandleApiDriver/api

udsoncan.py fails with pyo3_runtime.PanicException: index out of bounds: the len is 0 but the index is 0

This time I'm running cantact on a freshly installed RaspberryPi instead of OSX... cantact remains unusable out of the box as of version 0.1.1, despite following the README.md and install instructions to the letter. Would you mind reproducing it on your end please? :/

On this fresh system, it fails pretty much the same way as #12, the underlying Rust-PyO3 driver needs more work @ericevenchick.

$ cat udsoncan_simple.py
#!/usr/bin/env python3
import can
import isotp
import udsoncan
from udsoncan.connections import PythonIsoTpConnection
from udsoncan.client import Client, Response, Request

from udsoncan.exceptions import *
from udsoncan.services import *

udsoncan.setup_logging()

bus = can.interface.Bus(bustype="cantact", channel="0", bitrate=500000)
addr = isotp.Address(addressing_mode=isotp.AddressingMode.Normal_29bits, txid=0x18CAFFEE, rxid=0x18CAFFEB)
tp = isotp.CanStack(bus, address=addr)
conn = PythonIsoTpConnection(tp)
client = Client(conn)

conn.open()
client.ecu_reset(ECUReset.ResetType.hardReset)
print("done")
conn.close()

Here's the output:

$ ./udsoncan_simple.py
2021-05-31 15:46:37 [INFO] Connection: Connection opened
2021-05-31 15:46:37 [INFO] UdsClient: ECUReset<0x11> - Requesting reset of type 0x01 (hardReset)
2021-05-31 15:46:37 [DEBUG] Connection: Sending 2 bytes : [b'1101']
thread '<unnamed>' panicked at 'index out of bounds: the len is 0 but the index is 0', src/python.rs:128:13
note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace
Exception in thread Thread-1:
Traceback (most recent call last):
  File "/usr/lib/python3.7/threading.py", line 917, in _bootstrap_inner
    self.run()
  File "/usr/lib/python3.7/threading.py", line 865, in run
    self._target(*self._args, **self._kwargs)
  File "/usr/local/lib/python3.7/dist-packages/udsoncan/connections.py", line 513, in rxthread_task
    self.isotp_layer.process()
  File "/usr/local/lib/python3.7/dist-packages/isotp/protocol.py", line 457, in process
    self.txfn(msg)
  File "/usr/local/lib/python3.7/dist-packages/isotp/protocol.py", line 888, in _tx_canbus_3plus
    self.bus.send(can.Message(arbitration_id=msg.arbitration_id, data = msg.data, is_extended_id=msg.is_extended_id, is_fd=msg.is_fd, bitrate_switch=msg.bitrate_switch))
  File "/usr/local/lib/python3.7/dist-packages/can/interfaces/cantact.py", line 112, in send
    msg.data,
pyo3_runtime.PanicException: index out of bounds: the len is 0 but the index is 0

Failed ECUReset and app.shutdown() brings down cantact can0 SocketCAN interface?

After running this simple UDS code mostly borrowed from the official python-isotp documentation, with the only caveat that I'm using Extended_29bits addressing instead of Normal_11bits... @ericevenchick did you test your example code with Extended_29bits?:

#!/usr/bin/env python3
import time
import logging
import threading

import can
import isotp
import udsoncan

from udsoncan.connections import PythonIsoTpConnection
from udsoncan.client import Client, Response, Request
from udsoncan.exceptions import *
from udsoncan.services import *

from can.interfaces.socketcan import SocketcanBus

udsoncan.setup_logging()

BUILTIN_CANID=0xBEEEBEEE
OEM_CANID_TX=0xCAFECAFE
OEM_CANID_RX=0xBEEFBEEF

#bus = can.interface.Bus(bustype="cantact", channel="0", bitrate=500000)
#addr = isotp.Address(addressing_mode=isotp.AddressingMode.Extended_29bits, txid=OEM_CANID_TX, rxid=OEM_CANID_RX)
#tp = isotp.CanStack(bus, address=addr)
#conn = PythonIsoTpConnection(tp)
#client = Client(conn)

#conn.open()
#client.ecu_reset(ECUReset.ResetType.hardReset) <--- hangs cantact/disassociates SocketCAN interface
#client.ecu_reset(ECUReset.ResetType.softReset)
#print("done")
#conn.close()

class ThreadedApp:
   def __init__(self):
      self.exit_requested = False
      self.bus = can.interface.Bus(bustype="cantact", channel="0", bitrate=500000)
      #self.bus = SocketcanBus(channel='can0')
      addr = isotp.Address(isotp.AddressingMode.Extended_29bits, target_address=0,
                                                                 #rxid=OEM_CANID_RX,
                                                                 #txid=OEM_CANID_TX)
                                                                 rxid=BUILTIN_CANID,
                                                                 txid=OEM_CANID_TX)
      self.stack = isotp.CanStack(self.bus, address=addr, error_handler=self.my_error_handler)

   def start(self):
      self.exit_requested = False
      self.thread = threading.Thread(target = self.thread_task)
      self.thread.start()

   def stop(self):
      self.exit_requested = True
      if self.thread.isAlive():
         self.thread.join()

   def my_error_handler(self, error):
      logging.warning('IsoTp error happened : %s - %s' % (error.__class__.__name__, str(error)))

   def thread_task(self):
      while self.exit_requested == False:
         self.stack.process()                # Non-blocking
         time.sleep(self.stack.sleep_time()) # Variable sleep time based on state machine state

   def shutdown(self):
      self.stop()
      self.bus.shutdown()


if __name__ == '__main__':
   app = ThreadedApp()
   app.start()

   print('Waiting for payload - maximum 5 sec')
   t1 = time.time()
   while time.time() - t1 < 5:
      if app.stack.available():
         payload = app.stack.recv()
         print("Received payload : %s" % (payload))
         break
      time.sleep(0.2)

   print("Exiting")
   app.shutdown()

The application runs successfully until the end but udsoncan.log reads:

2021-08-28 21:39:37 [INFO] Connection: Connection opened
2021-08-28 21:39:37 [INFO] UdsClient: ECUReset<0x11> - Requesting reset of type 0x03 (softReset)
2021-08-28 21:39:37 [DEBUG] Connection: Sending 2 bytes : [b'1103']
2021-08-28 21:39:37 [DEBUG] Connection: Received 3 bytes : [b'7f117f']
2021-08-28 21:39:37 [WARNING] UdsClient: [NegativeResponseException] : ECUReset service execution returned a negative response ServiceNotSupportedInActiveSession (0x7f)

After that, the status lights on the Cantact PRO turn off and the SocketCAN can0 interface is gone and it cannot be brought back until a reboot is performed:

$ ip link show can0
Device "can0" does not exist.

$ cat can_start.sh
#!/bin/sh -x

sudo ip link set can0 type can bitrate 500000
sudo ifconfig can0 up

$ ./can_start.sh
+ sudo ip link set can0 type can bitrate 500000
Cannot find device "can0"
+ sudo ifconfig can0 up
can0: ERROR while getting interface flags: No such device

If all the lights turn off, this sounds like a firmware issue? I'll execute step by step next, but app.shutdown() seems to be the culprit because the latest print("Exiting") is displayed right before all the lights in the Cantact PRO go off.

@ericevenchick Could you please use this specific example on your end? I'm running all this on a Raspberry Pi 1 with the latest cantact release and pyton-isotp 1.7 and ... well, following all the installation instructions on the README to the letter :)

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

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

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.