1.Check the Faro module
   #ls /dev/ttyUSB* 

2.Install can-utils
   # sudo apt-get install can-utils

3.Build faro_can.ko
   # cd ./faro-socketcan/
   # make

4.Build farocand
   # cd ./faro-can-utils/
   # make

5. Check version faro_can.ko
   # modinfo ./faro_can.ko
      filename: /your_folder/faro_can.ko
      version: x.x.x
      .......

6. Load module
   # sudo modprobe can
   # sudo modprobe can_raw
   # sudo insmod ./faro-socketcan/faro_can.ko
   # sudo ./faro-can-utils/farocand -s22 -S921600 /dev/ttyUSB0 faro_can0 faro_can1
   # sudo ifconfig faro_can1 up
   # sudo ifconfig faro_can0 up

7.Trap CAN frame by candump
   # candump faro_can0 faro_can1 -t z
   # candump faro_can0 faro_can1 -t A

8. Send Command by cansend
   # cansend faro_can0 123#1122334455667788
   # cansend faro_can1 123#1122334455667788

9. Change baud rate
   # sudo ip link set faro_can0 down
   # sudo ip link set faro_can1 down
   # sudo ./faro-can-utils/farocand -s05 -S921600 /dev/ttyUSB0 faro_can0 faro_can1
   # sudo ip link set faro_can0 up
   # sudo ip link set faro_can1 up   

10.Remove farocand
   #sudo ip link set faro_can0 down
   #sudo ip link set faro_can1 down
   #sudo ifconfig faro_can0 down
   #sudo ifconfig faro_can1 down
   #sudo killall farocand
   #sleep 5
   #sudo rmmod faro_can
   #sudo rmmod can_raw
   #sudo rmmod can

11. Get the total number of CAN transmit/receive data and CAN errors
   # cat /proc/net/dev | grep 'Inter\|face\|faro'

12. Get the firmware version of FARO/GADN module
   # cat /sys/class/net/faro_can0/faro_fw_version

13. Change a port baud rate
   # sudo bash -c 'echo 0 > /sys/class/net/faro_can0/faro_speed'
   # sudo bash -c 'echo 8 > /sys/class/net/faro_can1/faro_speed'

14. Get port index
   # cat /sys/class/net/faro_can0/faro_port
   # cat /sys/class/net/faro_can1/faro_port

15. Get baud rate and active mode of 2 port
   # cat /sys/class/net/faro_can0/faro_get_all_br

16. Get lastest can error
   # cat /sys/class/net/faro_can0/faro_can_error
   # cat /sys/class/net/faro_can1/faro_can_error

17. Set can error
   # sudo bash -c 'echo 0 > /sys/class/net/faro_can0/faro_can_error'
   # sudo bash -c 'echo 0 > /sys/class/net/faro_can1/faro_can_error'

#============================================#
CAN baud rate setting defineition
   0: 1 MBPS
   1: 800 KPS
   2: 500 KBPS
   3: 250 KBPS
   4: 200 KBPS
   5: 125 KBPS
   8: Disable uploading data to the computer and switch CAN in the FARO/GADN module to silent mode. 

CAN error definition
   #define HAL_CAN_ERROR_NONE            (0x00000000U)  /*!< No error                                             */
   #define HAL_CAN_ERROR_EWG             (0x00000001U)  /*!< Protocol Error Warning                               */
   #define HAL_CAN_ERROR_EPV             (0x00000002U)  /*!< Error Passive                                        */
   #define HAL_CAN_ERROR_BOF             (0x00000004U)  /*!< Bus-off error                                        */
   #define HAL_CAN_ERROR_STF             (0x00000008U)  /*!< Stuff error                                          */
   #define HAL_CAN_ERROR_FOR             (0x00000010U)  /*!< Form error                                           */
   #define HAL_CAN_ERROR_ACK             (0x00000020U)  /*!< Acknowledgment error                                 */
   #define HAL_CAN_ERROR_BR              (0x00000040U)  /*!< Bit recessive error                                  */
   #define HAL_CAN_ERROR_BD              (0x00000080U)  /*!< Bit dominant error                                   */
   #define HAL_CAN_ERROR_CRC             (0x00000100U)  /*!< CRC error                                            */
   #define HAL_CAN_ERROR_RX_FOV0         (0x00000200U)  /*!< Rx FIFO0 overrun error                               */
   #define HAL_CAN_ERROR_RX_FOV1         (0x00000400U)  /*!< Rx FIFO1 overrun error                               */
   #define HAL_CAN_ERROR_TX_ALST0        (0x00000800U)  /*!< TxMailbox 0 transmit failure due to arbitration lost */
   #define HAL_CAN_ERROR_TX_TERR0        (0x00001000U)  /*!< TxMailbox 1 transmit failure due to tranmit error    */
   #define HAL_CAN_ERROR_TX_ALST1        (0x00002000U)  /*!< TxMailbox 0 transmit failure due to arbitration lost */
   #define HAL_CAN_ERROR_TX_TERR1        (0x00004000U)  /*!< TxMailbox 1 transmit failure due to tranmit error    */
   #define HAL_CAN_ERROR_TX_ALST2        (0x00008000U)  /*!< TxMailbox 0 transmit failure due to arbitration lost */
   #define HAL_CAN_ERROR_TX_TERR2        (0x00010000U)  /*!< TxMailbox 1 transmit failure due to tranmit error    */
   #define HAL_CAN_ERROR_TIMEOUT         (0x00020000U)  /*!< Timeout error                                        */
   #define HAL_CAN_ERROR_NOT_INITIALIZED (0x00040000U)  /*!< Peripheral not initialized                           */
   #define HAL_CAN_ERROR_NOT_READY       (0x00080000U)  /*!< Peripheral not ready                                 */
   #define HAL_CAN_ERROR_NOT_STARTED     (0x00100000U)  /*!< Peripheral not started                               */
   #define HAL_CAN_ERROR_PARAM           (0x00200000U)  /*!< Parameter error                                      */



