The bug
The process_line() function in usb-qr-scanner-read.sh defines the prefix as uppercase:
SPOOLMAN_PREFIX="WEB+SPOOLMAN:S-"
However, the scanner outputs the scanned code in lowercase (e.g. web+spoolman:s-1). The comparison [[ "$line" == "$SPOOLMAN_PREFIX"* ]] never matches, so post_next_spool_id is never called and no spool is loaded.
To Reproduce
- Generate a spoolman barcode (e.g.
web+spoolman:s-1)
- Scan it with the USB scanner
- Service logs show
Scanned code: web+spoolman:s-1 but Magic code Scanned is never printed and no gcode is sent to Moonraker
Expected behavior
Scanning a web+spoolman:s-N barcode should call SET_NEXT_SPOOL_ID SPOOL_ID=N via Moonraker.
Fix
Convert the scanned line to uppercase before comparison so the match is case-insensitive:
process_line() {
local line="$1"
local line_upper="${line^^}"
if [[ "$line_upper" == "WEB+SPOOLMAN:S-"* ]]; then
echo "Magic code Scanned"
SPOOL_ID="${line_upper#WEB+SPOOLMAN:S-}"
post_next_spool_id "${SPOOL_ID}"
elif [[ "$line" == "http"* ]]; then
echo "URL Scanned"
SPOOL_ID=`echo $line | cut -d'/' -f6`
post_next_spool_id "${SPOOL_ID}"
fi
}
Environment
- Scanner: MINJCODE MJ2818A
- AFC / Box Turtle MMU
- Moonraker + Klipper on RatRig running Kalico
- OS: debian
The bug
The
process_line()function inusb-qr-scanner-read.shdefines the prefix as uppercase:SPOOLMAN_PREFIX="WEB+SPOOLMAN:S-"However, the scanner outputs the scanned code in lowercase (e.g.
web+spoolman:s-1). The comparison[[ "$line" == "$SPOOLMAN_PREFIX"* ]]never matches, sopost_next_spool_idis never called and no spool is loaded.To Reproduce
web+spoolman:s-1)Scanned code: web+spoolman:s-1butMagic code Scannedis never printed and no gcode is sent to MoonrakerExpected behavior
Scanning a
web+spoolman:s-Nbarcode should callSET_NEXT_SPOOL_ID SPOOL_ID=Nvia Moonraker.Fix
Convert the scanned line to uppercase before comparison so the match is case-insensitive:
Environment