Please enable javascript, or click here to visit my ecommerce web site powered by Shopify.
Jump to: navigation, search

Rockpi4/use-rs485-can-hat-on-rock-pi-4

< Rockpi4
Revision as of 12:03, 20 August 2021 by Hong (Talk | contribs)

    ROCK Pi 4 > use-rs485-can-hat-on-rock-pi-4

Introduction

This guide tells The SPI interface of the development board is converted into can interface through RS485 CAN HAT interface

Install needed packages

  • update Kernel
   sudo apt-get install -y rockchip-overlay
   sudo apt-get install -y linux-headers-4.4.179-11-rockchip-g7ebe2c58142e 
   sudo apt-get install -y linux-image-4.4.179-11-rockchip-g7ebe2c58142e 
   sudo apt-get install -y linux-firmware-image-4.4.179-11-rockchip-g7ebe2c58142e

Download routine

At board terminal:

   $ sudo apt update
   $ sudo apt install -y linux-4.4-rock-pi-4-latest
   $ sudo apt-get install p7zip-full
   $ wget http://www.waveshare.net/w/upload/d/de/RS485_CAN_HAT_Code.7z
   $ 7z x RS485_CAN_HAT_Code.7z -r -o./RS485_CAN_HAT_Code
   $ sudo chmod 777 -R RS485_CAN_HAT_Code/


Connection mode

   H-H
   L-L

Block reception

  • open the board terminal, and run:
  $cd RS485_CAN_HAT_Code/CAN/wiringPi/receive/
  $make clean
  $make
  $sudo ./can_receive

Can see

   root@rockpi4b:/home/rock# ./can_receive
   this is a can receive demo


Send

  • open the another board terminal and run:
    $cd RS485_CAN_HAT_Code/CAN/wiringPi/send/
    $make clean
    $make
    $sudo ./can_send


Can see

    # ./can_receive
    this is a can receive demo
    can_id = 0x123
    can_dlc = 8
    data[0] = 1
    data[1] = 2
    data[2] = 3
    data[3] = 4
    data[4] = 5
    data[5] = 6
    data[6] = 7
    data[7] = 8


   $ ./can_send
   this is a can send demo
   can_id
   = 0x123
   can_dlc = 8
   data[0] = 1
   data[1] = 2
   data[2] = 3
   data[3] = 4
   data[4] = 5
   data[5] = 6
   data[6] = 7
   data[7] = 8
  $ ./can_send