specNum=$(jq -j--arg b ${module_id}'.modules."\($b)".specNum'$MODULECFG)
if["$specNum"!="null"];then
jq --argjson v $specNum'.ctrlCfg.cfg.specNum = $v'$CRTL_FILE> currentValue &&mv currentValue $CRTL_FILE
fi
# Chip config file
JSON_FILE=$cfgdir/$chipName.json
fi
echo""
jq -r--argjson a ${i}--arg b ${module_id}'.modules."\($b)".chips[$a].GlobalConfig | keys[] as $k | "\($k) \(.[$k])"'$MODULECFG |
while IFS=" "read-r-a value;do
key=${value[0]}
val=${value[1]}
currentValue=$(jq --arg k ${key}'.RD53A.GlobalConfig."\($k)"'$JSON_FILE)
if["$currentValue"=="null"];
then
jq --argjson v $val--arg k $key'.RD53A.GlobalConfig."\($k)" = $v'$JSON_FILE> currentValue &&mv currentValue $JSON_FILE
echo-e"[ warn ][so] Added key $(darkblue \"$key\") with value $(darkblue \"$val\") in the chip config file (GlobalConfig section)"
elif["$currentValue"!=$val];
then
jq --argjson v $val--arg k $key'.RD53A.GlobalConfig."\($k)" = $v'$JSON_FILE> currentValue &&mv currentValue $JSON_FILE
echo-e"[ info ][so] Changed $(darkblue \"$key\") from $(darkblue \"$currentValue\") to $(darkblue \"$val\") in the chip config file (GlobalConfig section)"
fi
done
echo""
# Modify config files according to config.json
for((i=0; i<$nChips; i++ ))
do
# Parameter section
jq -r--argjson a ${i}--arg b ${module_id}'.modules."\($b)".chips[$a].Parameter | keys[] as $k | "\($k) \(.[$k])"'$MODULECFG |
while IFS=" "read-r-a value;do
key=${value[0]}
val=${value[1]}
# Chip config file
chipName="$(jq -j--argjson a ${i}--arg b ${module_id}'.modules."\($b)".chips[$a].connectivity.name'$MODULECFG)"
JSON_FILE=$cfgdir/$chipName.json
currentValue=$(jq -r--arg k ${key}'.RD53A.Parameter."\($k)"'$JSON_FILE)
echo-e"[ info ][so] Looking for cfg updates in chip $i's configs..."
jq -r--argjson a ${i}--arg b ${module_id}'.modules."\($b)".chips[$a].GlobalConfig | keys[] as $k | "\($k) \(.[$k])"'$MODULECFG |
while IFS=" "read-r-a value;do
key=${value[0]}
val=${value[1]}
if["$currentValue"=="null"];
then
jq --argjson v $val--arg k $key'.RD53A.Parameter."\($k)" = $v'$JSON_FILE> currentValue &&mv currentValue $JSON_FILE
echo-e"[ warn ][so] Added key $(darkblue \"$key\") with value $(darkblue \"$val\") in the chip config file (Parameter section)"
currentValue=$(jq --arg k ${key}'.RD53A.GlobalConfig."\($k)"'$JSON_FILE)
elif["$currentValue"!="$val"];
then
if![["$val"=~ ^[0-9]+$ ]];then
jq --arg v $val--arg k $key'.RD53A.Parameter."\($k)" = "\($v)"'$JSON_FILE> currentValue &&mv currentValue $JSON_FILE
if["$currentValue"=="null"];
then
jq --argjson v $val--arg k $key'.RD53A.GlobalConfig."\($k)" = $v'$JSON_FILE> currentValue &&mv currentValue $JSON_FILE
echo-e"[ warn ][so] Added key $(darkblue \"$key\") with value $(darkblue \"$val\") in the chip config file (GlobalConfig section)"
else
jq --argjson v $val--arg k $key'.RD53A.Parameter."\($k)" = $v'$JSON_FILE> currentValue &&mv currentValue $JSON_FILE
fi
echo-e"[ info ][so] Changed $(darkblue \"$key\") from $(darkblue \"$currentValue\") to $(darkblue \"$val\") in the chip config file (Parameter section)"
fi
done
elif["$currentValue"!=$val];
then
jq --argjson v $val--arg k $key'.RD53A.GlobalConfig."\($k)" = $v'$JSON_FILE> currentValue &&mv currentValue $JSON_FILE
echo-e"[ info ][so] Changed $(darkblue \"$key\") from $(darkblue \"$currentValue\") to $(darkblue \"$val\") in the chip config file (GlobalConfig section)"
fi
done
# Connectivity file:
echo""
echo-e"[ info ][so] Linking chip cfg file in the connectivity file (chip $i)"
jq -e--argjson a ${i}--arg v $JSON_FILE'.chips[$a].config = "\($v)"'$CNCT_FILE> currentValue &&mv currentValue $CNCT_FILE
# Parameter section
jq -r--argjson a ${i}--arg b ${module_id}'.modules."\($b)".chips[$a].Parameter | keys[] as $k | "\($k) \(.[$k])"'$MODULECFG |
while IFS=" "read-r-a value;do
key=${value[0]}
val=${value[1]}
jq -r--argjson a ${i}--arg b ${module_id}'.modules."\($b)".chips[$a].connectivity | keys[] as $k | "\($k) \(.[$k])"'$MODULECFG |
while IFS=" "read-r-a value;do
key=${value[0]}
val=${value[1]}
currentValue=$(jq -r--arg k ${key}'.RD53A.Parameter."\($k)"'$JSON_FILE)
currentValue=$(jq -r--argjson a ${i}--arg k ${key}'.chips[$a]."\($k)"'$CNCT_FILE)
if["$currentValue"=="null"];
then
jq --argjson v $val--arg k $key'.RD53A.Parameter."\($k)" = $v'$JSON_FILE> currentValue &&mv currentValue $JSON_FILE
echo-e"[ warn ][so] Added key $(darkblue \"$key\") with value $(darkblue \"$val\") in the chip config file (Parameter section)"
if["$currentValue"=="null"];
then
jq --argjson a ${i}--argjson v $val--arg k $key'.chips[$a]."\($k)" = $v'$CNCT_FILE> currentValue &&mv currentValue $CNCT_FILE
echo-e"[ warn ][so] Added key $(darkblue \"$key\") with value $(darkblue \"$val\") in the connectivity file (chip $i)"
elif["$currentValue"!="$val"];
then
if![["$val"=~ ^[0-9]+$ ]];then
jq --argjson a ${i}--arg v $val--arg k $key'.chips[$a]."\($k)" = "\($v)"'$CNCT_FILE> currentValue &&mv currentValue $CNCT_FILE
else
jq --argjson a ${i}--argjson v $val--arg k $key'.chips[$a]."\($k)" = $v'$CNCT_FILE> currentValue &&mv currentValue $CNCT_FILE
fi
elif["$currentValue"!="$val"];
then
if![["$val"=~ ^[0-9]+$ ]];then
jq --arg v $val--arg k $key'.RD53A.Parameter."\($k)" = "\($v)"'$JSON_FILE> currentValue &&mv currentValue $JSON_FILE
echo-e"[ info ][so] Changed $(darkblue \"$key\") from $(darkblue \"$currentValue\") to $(darkblue \"$val\") in the connectivity file (chip $i)"
else
jq --argjson v $val--arg k $key'.RD53A.Parameter."\($k)" = $v'$JSON_FILE> currentValue &&mv currentValue $JSON_FILE
fi
done
echo-e"[ info ][so] Changed $(darkblue \"$key\") from $(darkblue \"$currentValue\") to $(darkblue \"$val\") in the chip config file (Parameter section)"
fi
done
# Connectivity file:
jq -e--argjson a ${i}--arg v $JSON_FILE'.chips[$a].config = "\($v)"'$CNCT_FILE> currentValue &&mv currentValue $CNCT_FILE
jq -r--argjson a ${i}--arg b ${module_id}'.modules."\($b)".chips[$a].connectivity | keys[] as $k | "\($k) \(.[$k])"'$MODULECFG |
while IFS=" "read-r-a value;do
key=${value[0]}
val=${value[1]}
currentValue=$(jq -r--argjson a ${i}--arg k ${key}'.chips[$a]."\($k)"'$CNCT_FILE)
if["$currentValue"=="null"];
then
jq --argjson a ${i}--argjson v $val--arg k $key'.chips[$a]."\($k)" = $v'$CNCT_FILE> currentValue &&mv currentValue $CNCT_FILE
echo-e"[ warn ][so] Added key $(darkblue \"$key\") with value $(darkblue \"$val\") in the connectivity file (chip $i)"
# Create an entry with the module serial number (to associate the config