Konstantin Aladyshev | 19abd96 | 2023-02-09 12:21:32 +0300 | [diff] [blame] | 1 | #!/bin/bash |
| 2 | |
| 3 | OLD_IP="" |
| 4 | |
| 5 | while true |
| 6 | do |
| 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 |
| 33 | done |