Skip to content

Case mismatch causes web+spoolman: barcodes to never trigger spool loading #2

@supercrossed

Description

@supercrossed

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

  1. Generate a spoolman barcode (e.g. web+spoolman:s-1)
  2. Scan it with the USB scanner
  3. 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

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions