summaryrefslogtreecommitdiff
path: root/meta-amd/meta-ethanolx/recipes-amd/amd-fpga/files/ip-to-fpga.sh
blob: a4d0a98c8d825b7c45dc247a5242acc5f3685093 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
#!/bin/bash

OLD_IP=""

while true
do
  IP=$(ip a | awk '/inet.*global/ {split ($2,A,"/"); print A[1]}')

  if [ "${IP}" != "${OLD_IP}" ]
  then
    if [ -n "${IP}" ]
    then
      IP_1=$(echo "${IP}" | cut -d "." -f 1)
      IP_2=$(echo "${IP}" | cut -d "." -f 2)
      IP_3=$(echo "${IP}" | cut -d "." -f 3)
      IP_4=$(echo "${IP}" | cut -d "." -f 4)
    else
      IP_1=0
      IP_2=0
      IP_3=0
      IP_4=0
    fi

    echo "Transfer current IP address (${IP_1}.${IP_2}.${IP_3}.${IP_4}) to the FPGA"

    i2cset -y 2 0x50 0 "${IP_1}"
    i2cset -y 2 0x50 1 "${IP_2}"
    i2cset -y 2 0x50 2 "${IP_3}"
    i2cset -y 2 0x50 3 "${IP_4}"
    OLD_IP=${IP}
  fi
  sleep 5
done