Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

getStatus() for Epson not functioning? #256

Open
nucleardreamer opened this issue Jun 21, 2024 · 0 comments
Open

getStatus() for Epson not functioning? #256

nucleardreamer opened this issue Jun 21, 2024 · 0 comments

Comments

@nucleardreamer
Copy link

I was running the getStatus() method (with a serial interface) and it only ever returns undefined every time. I'm not sure I understand how this is supposed to work exactly, maybe someone can explain! Also, if it's just my printer you can tell me to go kick rocks.

In the Epson config, we have TRANSMIT_PAPER_STATUS set to the hex buffer of 0x1d, 0x72, 0x01 (which corresponds to this docs page for transmitting status. However, I don't see any serial read in the codebase here, I'm not sure how the interface parses responses?

If I didn't miss the obvious and there is serial reading, it might be better to use the real-time status for the whole printer in these DLE EOT commands (0x10, 0x04, 0x04 specifically)

I have a little bash script I had written as a PoC, but it would be much nicer to have this in the library!

#!/bin/bash

# this is my path, replace obviously
PRINTER="/dev/usb/lp2"

check_printer_access() {
    if [ ! -w "$PRINTER" ]; then
        echo "Error: Cannot access $PRINTER. Make sure you have the right permissions."
        exit 1
    fi
}

get_printer_status() {
    # referenced here: https://download4.epson.biz/sec_pubs/pos/reference_en/escpos/dle_eot.html
    echo -en '\x10\x04\x04' > "$PRINTER"
    sleep 0.1
    response=$(xxd -b "$PRINTER" | head -n 1 | awk '{print $2}')
    echo "$response"
}

interpret_status() {
    local binary="$1"
    
    echo "binary status: $binary"
    
    # check bits 2 and 3 for roll paper near-end sensor
    near_end="${binary:2:2}"
    case "$near_end" in
        "00") echo "NEAR-end sensor: paper adequate" ;;
        "11") echo "NEAR-end sensor: paper near-end" ;;
        *) echo "NEAR-end sensor: unknown status ($near_end)" ;;
    esac
    
    # check bits 5 and 6 for roll paper end sensor
    paper_end="${binary:5:2}"
    case "$paper_end" in
        "00") echo "END sensor: paper present" ;;
        "11") echo "END sensor: paper not present" ;;
        *) echo "END sensor: unknown status ($paper_end)" ;;
    esac
}

check_printer_access
status=$(get_printer_status)
interpret_status "$status"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant