Skip to content

Commit

Permalink
Fix for recognizing serial numbers
Browse files Browse the repository at this point in the history
  • Loading branch information
kx1t authored Oct 30, 2023
1 parent e94eac8 commit 23e8941
Showing 1 changed file with 1 addition and 16 deletions.
17 changes: 1 addition & 16 deletions rootfs/etc/s6-overlay/scripts/01-vdlm2dec
Original file line number Diff line number Diff line change
Expand Up @@ -59,22 +59,7 @@ if [[ -z "${SERIAL}" ]]; then
exit 1
fi

RTL_TEST_OUTPUT=$(timeout 1s rtl_test -d 0 2>&1 | grep -P '^\s+\d+:\s+\S+?,\s+\S+?,\s+SN:\s+\S+?\s*$' || true)

IFS=$'\n'
for RTL_TEST_OUTPUT_LINE in $RTL_TEST_OUTPUT; do
# Unset variables in case any regexes fail
unset RTL_DEVICE_ID RTL_DEVICE_MAKE RTL_DEVICE_MODEL RTL_DEVICE_SERIAL

# Pull variables from output via regex
RTL_DEVICE_NUMBER=$(echo "$RTL_TEST_OUTPUT_LINE" | grep -oP '^\s+\K\d+(?=:\s+\S+?,\s+\S+?,\s+SN:\s+\S+?\s*$)')
RTL_DEVICE_SERIAL=$(echo "$RTL_TEST_OUTPUT_LINE" | grep -oP '^\s+\d+:\s+\S+?,\s+\S+?,\s+SN:\s+\K\S+?(?=\s*$)')

# See if we've found the device we're looking for
if [[ -n "$SERIAL" && "$SERIAL" == "$RTL_DEVICE_SERIAL" ]]; then
OUTPUT_DEVICE_ID="$RTL_DEVICE_NUMBER"
fi
done
OUTPUT_DEVICE_ID="$(timeout 1s rtl_test -d $((RANDOM+99)) 2>&1 | grep -P -e "SN: $SERIAL" | sed -n 's/^\s*\([0-9]\+\):.*$/\1/p')"

if [[ -z "${OUTPUT_DEVICE_ID}" ]]; then
echo "Could not find device ID for serial '$SERIAL'"
Expand Down

0 comments on commit 23e8941

Please sign in to comment.