#!/bin/bash
. test.common
test_start "ptp4l and phc2sys with various PI servo configurations"
wander=1e-9
limit=4000
max_sync_time=2000
for jitter in 1e-8 1e-7 1e-6 1e-5; do
kp=$(awk 'BEGIN {x=1.5 / sqrt('$jitter'/'$wander'); print x < 0.7 ? x : 0.7}')
ki=$(awk 'BEGIN {x=1.2 / ('$jitter'/'$wander'); print x < 0.3 ? x : 0.3}')
time_rms_limit=$(awk 'BEGIN {print 1.5e-8 * ('$jitter'/1e-8)**0.75}')
freq_rms_limit=$(awk 'BEGIN {print 1.5e-8 * ('$jitter'/1e-8)**0.5}')
time_max_limit=$(awk 'BEGIN {print 8 * '$time_rms_limit'}')
freq_max_limit=$(awk 'BEGIN {print 8 * '$freq_rms_limit'}')
master_conf=""
slave_conf="-P $kp -I $ki"
nodes=1
master_node=0
run_phc2sys || test_fail
check_sync || test_fail
master_conf="delay_mechanism P2P"
slave_conf="delay_mechanism P2P
pi_proportional_const $kp
pi_integral_const $ki"
nodes=2
master_node=1
run_ptp4l || test_fail
check_sync || test_fail
done
test_pass