Victor Liu | c85025d | 2022-02-15 08:19:10 -0800 | [diff] [blame] | 1 | #!/vendor/bin/sh |
| 2 | if [ -z "$2" ] |
| 3 | then |
| 4 | echo "usage is $0 input-calibration output_calibration" |
| 5 | exit 0 |
| 6 | fi |
| 7 | OUTPUT_CALIB="$2" |
| 8 | if [ ! -f "$OUTPUT_CALIB" ]; then |
| 9 | touch $OUTPUT_CALIB |
| 10 | chmod 0600 $OUTPUT_CALIB |
| 11 | file="$1" |
| 12 | while IFS=, read -r f1 f2 |
| 13 | do |
| 14 | case $f1 in |
| 15 | "UWB_cal_tx_xtal_reg_final_value") |
| 16 | if [ $((0x$f2)) -gt 63 ]; then |
| 17 | f2=63 |
| 18 | fi |
| 19 | echo 'xtal_trim=0x'$f2 >> $OUTPUT_CALIB |
| 20 | ;; |
| 21 | "UWB_TX1RX1_CH5_tx_ant_delay_cal_data") |
| 22 | echo 'ant0.ch5.prf64.ant_delay=0x'$f2 >> $OUTPUT_CALIB |
| 23 | ;; |
| 24 | "UWB_TX1RX1_CH5_rx_ant_delay_cal_data") |
| 25 | echo 'ant1.ch5.prf64.ant_delay=0x'$f2 >> $OUTPUT_CALIB |
| 26 | ;; |
| 27 | "UWB_TX1RX1_CH9_tx_ant_delay_cal_data") |
| 28 | echo 'ant0.ch9.prf64.ant_delay=0x'$f2 >> $OUTPUT_CALIB |
| 29 | ;; |
| 30 | "UWB_TX1RX1_CH9_rx_ant_delay_cal_data") |
| 31 | echo 'ant1.ch9.prf64.ant_delay=0x'$f2 >> $OUTPUT_CALIB |
| 32 | ;; |
| 33 | "UWB_RX2_CH5_cal_pdoa_data") |
| 34 | # float value * 2048 |
| 35 | #/vendor/bin/sh does not support "bc" |
| 36 | base=2048 |
| 37 | ones=${f2%%.*} |
| 38 | dec=${f2#*.} |
| 39 | ones="$(($ones*$base))" |
| 40 | if [ ${#dec} -eq 2 ]; then |
| 41 | dec="$(($dec*$base/100))" |
| 42 | echo 'ant1.ant3.ch5.pdoa_offset='$(($ones+$dec)) >> $OUTPUT_CALIB |
| 43 | fi |
| 44 | ;; |
| 45 | "UWB_RX2_CH9_cal_pdoa_data") |
| 46 | base=2048 |
| 47 | ones=${f2%%.*} |
| 48 | dec=${f2#*.} |
| 49 | ones="$(($ones*$base))" |
| 50 | if [ ${#dec} -eq 2 ]; then |
| 51 | dec="$(($dec*$base/100))" |
| 52 | echo 'ant1.ant3.ch9.pdoa_offset='$(($ones+$dec)) >> $OUTPUT_CALIB |
| 53 | fi |
| 54 | esac |
| 55 | done <"$file" |
| 56 | exit 0 |
| 57 | fi |