Signed-off-by: David Rebbe <drebbe@intrepidcs.com> |
||
|---|---|---|
| .. | ||
| src | ||
| CMakeLists.txt | ||
| README.md | ||
README.md
libicsneo C++ Example
This is an example console application which uses libicsneo to connect to an Intrepid Control Systems hardware device. It has both interactive and simple examples for sending and receiving CAN & CAN FD traffic.
Building
This example shows how to use the C++ version of libicsneo with CMake. It will build libicsneo along with your project.
First, you need to clone the repository onto your local machine. Run:
git clone https://github.com/intrepidcs/libicsneo-examples --recursive
Alternatively, if you cloned without the --recursive flag, you must enter the libicsneo-examples folder and run the following:
git submodule update --recursive --init
If you haven't done this, third-party/libicsneo will be empty and you won't be able to build!
Windows using Visual Studio 2017+
- Launch Visual Studio and open the
libicsneo-examplesfolder. - Choose
File->Open->CMake... - Navigate to the
libicsneocpp-examplefolder and select theCMakeLists.txtthere. - Visual Studio will process the CMake project.
- Choose the dropdown attached to the green play button (labelled "select startup item...") in the toolbar.
- Select
libicsneocpp-simple-example.exe - Press the green play button to compile and run the example.
Ubuntu 18.04 LTS
- Install dependencies with
sudo apt updatethensudo apt install build-essential cmake libusb-1.0-0-dev libpcap0.8-dev - Change directories to your
libicsneo-examples/libicsneocpp-examplefolder and create a build directory by runningmkdir -p build - Enter the build directory with
cd build - Run
cmake ..to generate your Makefile.- Hint! Running
cmake -DCMAKE_BUILD_TYPE=Debug ..will generate the proper scripts to build debug, andcmake -DCMAKE_BUILD_TYPE=Release ..will generate the proper scripts to build with all optimizations on.
- Hint! Running
- Run
make libicsneocpp-interactive-exampleto build.- Hint! Speed up your build by using multiple processors! Use
make libicsneocpp-interactive-example -j#where#is the number of cores/threads your system has plus one. For instance, on a standard 8 thread Intel i7, you might use-j9for an ~8x speedup.
- Hint! Speed up your build by using multiple processors! Use
- Now run
sudo ./libicsneocpp-interactive-exampleto run the example.- Hint! In order to run without sudo, you will need to set up the udev rules. Copy
libicsneo-examples/third-party/libicsneo/99-intrepidcs.rulesto/etc/udev/rules.d, then runudevadm control --reload-rules && udevadm triggerafterwards. While the program will still run without setting up these rules, it will fail to open any devices.
- Hint! In order to run without sudo, you will need to set up the udev rules. Copy
- If you wish to run the simple example instead, replace any instances of "interactive" with "simple" in steps 5 and 6.
macOS
Instructions coming soon™