AFCProject / AFCProject/afc-spool-scan

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

Open Beginner friendly
#2 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
Shell
Stars
10
Forks
3
Avg merge
2d 22h
Merged PRs (30d)
1

Description

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

Contributor guide

No contributing guide indexed for this repository

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Inspect process_line() in usb-qr-scanner-read.sh, starting with its prefix comparison and the post_next_spool_id call. Done means a lowercase web+spoolman:s-N scan is recognized and sends SPOOL_ID=N to Moonraker without changing the existing URL handling.

Written by the indexing model from the issue text.

Assessment

Tech stack
bash
Domain
backend
Issue type
Bug
Difficulty
1/5
Estimated time
Under an hour
Activity status
Quiet
Clarity
Clearly specified
Newbie friendliness
85/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.