You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
When I connect a ublox device to the official u-center software, I don't have to specify the baudrate as it will just iterate through all possible baudrates to find the correct one. I would like to see the same feature integrated in this driver.
This driver could offer the option to set the uart1/baudrate to auto instead of just a number.
If this is detected, the node at start would simply try to listen to the port for some target message (e.g. UBX-MON-VER) with the desired baudrate and if successfully received, use the current rate. If not received, try the next baudrate.
Has anyone ever done something like that?
A quick & dirty prompt search gave me the following snippet to give an example of the logic I am imagining. Beware that this snipped is untested:
#!/bin/bash
DEVICE="/dev/ttyACM0" # Change this to match your serial device
BAUD_RATES=(9600 19200 38400 57600 115200 230400 460800 921600)
UBX_MON_VER_HEX="b5620a0400000e34" # UBX-MON-VER polling message
function send_poll() {
local baud=$1
echo "[*] Trying baud rate: $baud"
# Send UBX-MON-VER polling message and listen for reply
timeout 2s socat -T1 -d -d \
"EXEC:echo -ne \"$(echo $UBX_MON_VER_HEX | sed 's/../\\x&/g')\",pty,rawer" \
"PTY,link=/tmp/vserial,rawer" 2>/dev/null &
sleep 0.5
# Set baud rate and read output
stty -F $DEVICE $baud raw -echo
head -c 200 < $DEVICE | hexdump -C > /tmp/ublox_resp_${baud}.txt &
PID=$!
# Wait and kill if still running
sleep 1.5
kill $PID 2>/dev/null
if grep -q "b5 62" /tmp/ublox_resp_${baud}.txt; then
echo "[+] UBX response found at baud rate: $baud"
return 0
else
echo "[-] No UBX response at $baud"
return 1
fi
}
for rate in "${BAUD_RATES[@]}"; do
if send_poll $rate; then
echo "✅ Detected baud rate: $rate"
exit 0
fi
done
echo "❌ Failed to detect baud rate."
exit 1
Activity