# README Raspbian

The simplyCAN software package is delivered as .tar.gz archive, which includes the following components:

- simplyCAN library (so, static lib)

- Header file

- busmonitor

- Demo applications for C and Python

- API documentation

- License

## Installation

- The USB interface is automatically installed when plugged in, without a driver installation. By default the device will be mapped to `/dev/ttyACMx`. To specify a different name, the following udev rule can be defined:

      SUBSYSTEM=="tty", ATTRS{idVendor}=="08d8", ATTRS{idProduct}=="001d", SYMLINK+="SIMPLY_CAN"

- If the `modemmanager` is installed on your system, it may grab the device after plugged in. During this time, the device cannot be used by your application. To prevent the modem manager to grab the device, the following udev rule can be defined:

      ATTRS{idVendor}=="08d8", ATTRS{idProduct}=="001d", ENV{ID_MM_DEVICE_IGNORE}="1"

- Create the udev file in /etc/udev/rules.d, typically named `60-simplyCAN.rules` (root access required). See also: https://wiki.debian.org/udev

- To activate the new rules, execute the following command: `udevadm control --reload-rules`

- If user rights for using the simplyCAN device are missing, add your user name to the dialout group:

      sudo usermod -a -G dialout $USER

## Usage of the Demo Applications

The demo applications are available for C and Python. First the serial port has to be adapted according to your hardware setup. To determine the used serial port, you can:

- use the simplyCAN bus monitor

- use the command `ls -l /dev/serial/by-id`

- use a udev rule (see above)

- use the function `retrieve_serial_port()` (C and Python)

### C Demo

- Adapt the `k_SERIAL_PORT` and `k_BAUDRATE` defines in `demo.c` according to your hardware setup:

      #ifdef __unix__
      #define k_SERIAL_PORT      "/dev/ttyACM0"
      #else
      #define k_SERIAL_PORT      "COM1"
      #endif
      #define k_BAUDRATE         (250)

- Compile the demo with `make` and run the executable located in bin/

### Python Demo

- The Python wrapper `simply_py.so` is built for Python 3.7 (32 bit).

- Adapt the COM port in `demo.py` according to your hardware setup:

      # main(simply_can.retrieve_serial_port())
      # main("/dev/ttyACM0", 250)    # for Linux
      main("COM6", 250)         # for Windows

  The value `250` is the used baudrate in kBaud.

- Run the demo with `python3 demo.py`.

## Copyright

(C) 2019-2022 HMS Technology Center Ravensburg GmbH
Helmut-Vetter-Strasse 2
88213 Ravensburg
Germany