Last active
July 9, 2024 22:48
-
-
Save simeononsecurity/4b7d24a4a33e0e9731a2af6bad9cfb5f to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #!/bin/bash | |
| #sudo curl -sSL -H "Cache-Control: no-cache" -H "Pragma: no-cache" https://gist.githubusercontent.com/simeononsecurity/4b7d24a4a33e0e9731a2af6bad9cfb5f/raw/unicore.sh | bash | |
| # Branding message | |
| echo "###########################################################" | |
| echo "# #" | |
| echo "# Visit https://simeononsecurity.com for more info #" | |
| echo "# Please consider donating at #" | |
| echo "# https://github.com/sponsors/SimeonOnSecurity #" | |
| echo "# #" | |
| echo "###########################################################" | |
| echo "# #" | |
| echo "# Source: https://simeononsecurity.com/other/onocoy-gps-gnss-reciever-basestation-on-a-budget/" | |
| echo "# #" | |
| echo "###########################################################" | |
| echo "" | |
| # Function to send commands to a device | |
| send_commands() { | |
| local device=$1 | |
| # Commands to be sent | |
| local commands=( | |
| "FRESET" | |
| "UNLOG" | |
| "UNILOGLIST" | |
| "saveconfig" | |
| "CONFIG ANTIJAM FORCE" | |
| "saveconfig" | |
| "CONFIG RTK TIMEOUT 600" | |
| "CONFIG RTK RELIABILITY 4 4" | |
| "CONFIG MMP ENABLE" | |
| "CONFIG RTCMCLOCKOFFSET ENABLE" | |
| "saveconfig" | |
| "CONFIG PSRVELDRPOS ENABLE" | |
| "mode base time 60 2 2.5" | |
| "config signalgroup 2" | |
| "saveconfig" | |
| "config RTCMB1CB2a enable" | |
| "saveconfig" | |
| "saveconfig" | |
| "CONFIG UNDULATION 0" | |
| "saveconfig" | |
| "gngga 1" | |
| "gnrmc 1" | |
| "gpgsv 1" | |
| "gpgsa 1" | |
| "UNMASK GPS" | |
| "UNMASK BDS" | |
| "UNMASK GLO" | |
| "UNMASK GAL" | |
| "UNMASK QZSS" | |
| "UNMASK IRNSS" | |
| "UNMASK ALL" | |
| "saveconfig" | |
| "rtcm1005 30" | |
| "rtcm1033 30" | |
| "rtcm1077 1" | |
| "rtcm1087 1" | |
| "rtcm1097 1" | |
| "rtcm1117 1" | |
| "rtcm1127 1" | |
| "saveconfig" | |
| "rtcm1007 30" | |
| "rtcm1019 1" | |
| "rtcm1020 1" | |
| "rtcm1033 30" | |
| "rtcm1042 1" | |
| "rtcm1044 1" | |
| "rtcm1045 1" | |
| "rtcm1046 1" | |
| "rtcm1077 1" | |
| "rtcm1087 1" | |
| "rtcm1097 1" | |
| "rtcm1107 1" | |
| "rtcm1117 1" | |
| "rtcm1127 1" | |
| "rtcm1137 1" | |
| "saveconfig" | |
| "CONFIG SBAS ENABLE Auto" | |
| "CONFIG SBAS TIMEOUT 600" | |
| "saveconfig" | |
| ) | |
| # Open the device with the correct settings | |
| exec 3<>"$device" | |
| # Send each command | |
| for cmd in "${commands[@]}"; do | |
| echo -e "$cmd\r\n" >&3 | |
| sleep 0.1 | |
| done | |
| # Read responses | |
| while read -r line <&3; do | |
| echo "$device: $line" | |
| done | |
| # Close the device | |
| exec 3<&- | |
| } | |
| # Check if any /dev/ttyUSB* devices are present | |
| if ls /dev/ttyUSB* 1> /dev/null 2>&1; then | |
| # Iterate over each /dev/ttyUSB* device | |
| for device in /dev/ttyUSB*; do | |
| if [ -c "$device" ]; then | |
| echo "Configuring $device..." | |
| # Set the device to 115200 8N1 | |
| stty -F "$device" 115200 cs8 -cstopb -parenb | |
| send_commands "$device" & | |
| else | |
| echo "$device is not a character device, skipping..." | |
| fi | |
| done | |
| # Wait for all background jobs to finish | |
| wait | |
| echo "Configuration complete." | |
| else | |
| echo "Error: No /dev/ttyUSB* devices detected." | |
| exit 1 | |
| fi |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment