#!/bin/bash

# From http://www.trinityos.com/HAM/US-Interface/us-interface-navigator-and-linux.html#navigator-config

# bit 	Description	Setting
# ---   --------------- ----------------------------------------------------------
# 0	CH.1 attenuator	"0" for 15db attenuation or "1" for default:no attenuation
# 1	CH.2 attenuator	"0" for 15db attenuation or "1" for default:no attenuation
# 2	RF attenuator	"0" for 20db attenuation or "1" for default:no attenuation
# 3	WinKey PTT	"0" for default:no PTT or "1" for WinKey PTT
# 4	LED brightness	"0" for DIM or "1" for default:normal brightness
# 5	CAT LED behavior	"0" for steady or "1" for default:on-access polling
# 6	FSK polarity	"0" for reverse or "1" for default:normal polarity
# 7	FSK side tone	"0" for no tone or "1" for default:tone
# 8	FSK PTT	"0" for no PTT or "1" for default:PTT
# 9	FSK BAUD rate	"1" for default:45.45, "2" for 75, or "3" for 100 baud
# 10	FSK stop bits	"1" for default:1 bit, "2" for 1.5 bits, or " 3" for 2 bits

PORT="/dev/USI_CFG"

echo -e "\nSetting $PORT to 1200 baud"
stty -F $PORT speed 1200 > /dev/null

echo -e "  - Initializing the CONFIG port"
# do it twice as I'ved seen this is needed
echo -e "KT/r" > $PORT
echo -e "KT/r" > $PORT

echo -e "  - Reset the US Navigator to defaults"
echo -e "KL11111111112/r" > $PORT

#DIM the LEDs
#echo -e "KL11100111113/r" > $PORT

#If you'd like to save these settings as the default
echo -e "  - Saving as defaults"
echo -e "KS/r" > $PORT

echo -e "\nDone\n"
