Connecting To A CAN Sensor

### 1. Identify the Hardware/Circuit ID of the physical CAN interface Begin by finding the CAN hardware and circuit identifier. PolySync supports two types of CAN hardware devices, Kvaser and off-the-shelf. Kvaser uses `linuxcan` libraries to communicate with hardware, while most other off-the-shelf hardware uses `SocketCAN` libraries for communication. If you are using Kvaser hardware, input the following into your terminal window to parse the hardware and circuit IDs: ```bash $ /usr/src/linuxcan/canlib/examples/listChannels ``` The following example output should be visible: ```bash Found 1 channel. channel 0 = Kvaser Leaf Light v2, 73-30130-00685-0, (0)21718, 3.3.0.769 ``` In the above example, the hardware identifier is printed near the end, in this case it's _21718_. The circuit identifier is an index for multi-channel CAN hardware interfaces. The _(0)_ preceding the hardware identifier represents the circuit ID. If you are using SocketCAN hardware, you will only need to find the hardware identifier. Available devices can be queried from the system with `ifconfig -a`, and are typically represented as `can0`, `can1`, etc. The following devices map to the listed values in PolySync: | SocketCAN Channel | PolySync HW ID | | ------------- | ------------- | | `can0` | 1 | | `can1` | 2 | | `can2` | 3 | | `canN` | N+1 | Now it’s time to configure the sensor node’s IO Parameters in the SDF Configurator . To start the SDF Configurator from the terminal, input the following: ```bash $ polysync-sdf-configurator ``` ### 2. Add a sensor node and configure the node with the data from the previous step in the SDF Configurator To add a new sensor node press the **Add Sensor Node** button in the bottom-left of the SDF Configurator. Select the sensor from the drop-down list and give the node a name. Once the node has been created in the SDF, the supported parameters for the node are automatically populated by the SDF Configurator with default values. ### 3. Use the Dynamic Driver to query the RADAR for the sensor ID Now that you’ve properly configured the circuit ID and hardware ID for the node, you will need to obtain the [sensor identifier](/articles/?p=1028) In order to query the sensor, the PolySync dynamic driver will use the '-g' flag. This can only be done after the hardware and circuit IDs are entered into the SDF Configurator. ```bash $ polysync-dynamic-driver -n 1 -g ``` When invoking the dynamic driver, you will use the node ID that defines the sensor node. The node ID can be found in the upper right corner of the node configuration within the SDF Configurator (above). The information is logged to the file **$PSYNC_HOME/polysync.log**, and to standard output depending on your logging configuration. ### 4. Finish configuring the node by entering the sensor ID in the SDF Configurator In this final step, you will need to copy the decimal value of the sensor identifier─provided in the output of the dynamic driver node─to the SDF Configurator "Sensor 0 Identifier." ![SDFConfigurator](https://help.polysync.io/releases/2.0.8//wp-content/uploads/2016/07/SDF-Configurator_002.png) Now the PolySync Manager can be started. ```bash $ polysync-manager -n ``` The node can also be manually started by referencing the SDF Configurator node ID within the `polysync-dynamic-driver` command. This is done by starting the PolySync manager in wall-clock mode (no arguments) and then running the `polysync-dynamic-driver` command with the -n flag. Running this command will print all of the parameters supported by the dynamic driver interface. The -n flag tells the dynamic driver which node ID (found in the SDF Configurator) to reference. ```bash $ polysync-manager $ polysync-dynamic-driver -n 1 ``` ### 5. Data visualization To visualize your data, start PolySync Studio and launch the 3D view or trace plugins. ```bash $ polysync-studio ``` ### Conclusion Congratulations! You have now successfully connected a CAN RADAR sensor and visualized its output using Studio.