5.3 KiB
libicsneo Java Example
This is an example console application which uses icsneojava to connect to an Intrepid Control Systems hardware device. It has both interactive and simple examples for sending and receiving CAN & CAN FD traffic.
Cloning
This will create a copy of the repository on your local machine.
Run:
git clone https://github.com/intrepidcs/libicsneo-examples -b v0.2.0-dev --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
Building the DLL's
icsneoc
First, we are going to build the icsneoc library into a .dll file that is used by the Java wrapper to access the library functions.
- Change directories to the
libicsneo-examples/third-party/libicsneofolder. - Create a build directory by running
mkdir -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
cmake --build .to build the library.- Hint! Speed up your build by using multiple processors! Use
make -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
- The
icsneoc.dllfile will be generated inlibicsneo-examples/third-party/libicsneo/build/Debug. Move this file to the/C/Windows/System32folder.
icsneojava
Next, we are going to build the wrapper functions into a .dll file that is used to access the library functions in Java.
- Change directories to the
libicsneo-examples/libicsneojava-examplefolder. - Create a build directory by running
mkdir -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
cmake --build .to build the library.- Hint! Speed up your build by using multiple processors! Use
make -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
- The
icsneojava.dllfile will be generated inlibicsneo-examples/libicsneojava-example/build/Debug. Move this file to the/C/Windows/System32folder.
Building and running the example program
- Change directories to the
libicsneo-examples/libicsneojava-example/srcfolder. - Run
javac Run.java - Run
java Run
Ubuntu 18.04 LTS
Building the .so's
icsneoc
- Install dependencies with
sudo apt updatethensudo apt install build-essential cmake libusb-1.0-0-dev libpcap0.8-dev - Change directories to
libicsneo-examples/third-party/libicsneoand 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
maketo build the library.- Hint! Speed up your build by using multiple processors! Use
make -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
- Run
sudo cp libicsneoc.so /usr/libso that it can be found via the default ubuntu .so search path. For more information, see the ld.so.8 man page.
icsneojava
Next, we are going to build the wrapper functions into a .so file that is used to access the library functions in Java.
- Change directories to the
libicsneo-examples/libicsneojava-examplefolder. - Create a build directory by running
mkdir -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
cmake --build .to build the library.- Hint! Speed up your build by using multiple processors! Use
make -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
- The
icsneojava.sofile will be generated inlibicsneo-examples/libicsneojava-example/build/Debug. Runsudo cp libicsneojava.so /usr/libso that it can be found via the default ubuntu .so search path. For more information, see the ld.so.8 man page.
Building and running the example program
- Change directories to the
libicsneo-examples/libicsneojava-example/srcfolder. - Run
javac Run.java - Run
java Run