blob: a4d0a98c8d825b7c45dc247a5242acc5f3685093 [file] [log] [blame]
Konstantin Aladyshev19abd962023-02-09 12:21:32 +03001#!/bin/bash
2
3OLD_IP=""
4
5while true
6do
7 IP=$(ip a | awk '/inet.*global/ {split ($2,A,"/"); print A[1]}')
8
9 if [ "${IP}" != "${OLD_IP}" ]
10 then
11 if [ -n "${IP}" ]
12 then
13 IP_1=$(echo "${IP}" | cut -d "." -f 1)
14 IP_2=$(echo "${IP}" | cut -d "." -f 2)
15 IP_3=$(echo "${IP}" | cut -d "." -f 3)
16 IP_4=$(echo "${IP}" | cut -d "." -f 4)
17 else
18 IP_1=0
19 IP_2=0
20 IP_3=0
21 IP_4=0
22 fi
23
24 echo "Transfer current IP address (${IP_1}.${IP_2}.${IP_3}.${IP_4}) to the FPGA"
25
26 i2cset -y 2 0x50 0 "${IP_1}"
27 i2cset -y 2 0x50 1 "${IP_2}"
28 i2cset -y 2 0x50 2 "${IP_3}"
29 i2cset -y 2 0x50 3 "${IP_4}"
30 OLD_IP=${IP}
31 fi
32 sleep 5
33done