Skip to content

jtollet/SP-150-Toner

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

2 Commits
 
 
 
 
 
 

Repository files navigation

SP-150 Toner

This repo contains:

  • ricoh_toner_level.c: a C utility that reads the Ricoh SP 150 STS field from the USB DeviceID and decodes toner/status information.
  • usbricoh: a CUPS backend wrapper that injects marker and state attributes into CUPS while delegating printing to the stock usb backend.

STS observations

The DeviceID contains a base64-encoded STS: field. Observed length is 108 base64 chars (decoded length 81 bytes).

Offset Field Observed meaning Notes
0x00 Toner level level = byte & 0x7f Range observed 0–127; used as percent by Windows/macOS tooling.
0x09 Status code Paper-out signature when 0xBD 0xBD observed when job present + paper out. Other values like 0x00, 0x01, 0x02 seen during normal/idle transitions.
0x0B Flags Toner low/empty bits flags & 0x06: 0x02 = near end, 0x06 = end. Matches Windows logic.
0x2A Job name ASCII job name Null-terminated ASCII; present when a job is active.
0x4A Status aux 0x05 during paper-out Observed with paper-out signature.
0x4B Status aux 0x0F during paper-out Observed with paper-out signature.
0x50 Counter Monotonic increment Observed to increment between samples.

Paper-out was detected when all of the following were true:

  • JOB_PRESENT=1 (job name present)
  • O09=0xBD, O4A=0x05, O4B=0x0F

Build and install

Build the C utility:

gcc -O2 -o ricoh_toner_level ricoh_toner_level.c

Install:

sudo install -m 0755 ricoh_toner_level /usr/local/bin/ricoh_toner_level
sudo install -m 0744 usbricoh /usr/lib/cups/backend/usbricoh

usbricoh uses the stock CUPS USB backend; keep /usr/lib/cups/backend/usb unchanged.

Create a CUPS queue

Find your device URI:

lpinfo -v | rg usbricoh

Create a new queue (replace placeholders):

sudo lpadmin -p SP-150-toner -E \
  -v 'usbricoh://RICOH/SP%20150?serial=<SERIAL>' \
  -P /path/to/PPD/for/SP-150.ppd

How it integrates with CUPS

usbricoh runs ricoh_toner_level --status before the print job starts and emits:

  • ATTR: marker-* (toner level)
  • STATE: +toner-low / STATE: +toner-empty
  • STATE: +media-empty with INFO: Paper out when the paper-out signature is observed

It always emits STATE: -toner-low -toner-empty -media-empty first to clear stale states.

Verifying from IPP

ipptool -tv ipp://localhost/printers/SP-150-toner \
  /usr/share/cups/ipptool/get-printer-attributes.test \
  | rg -n 'marker-|printer-state-reasons'

Look for:

  • marker-levels (toner percent)
  • printer-state-reasons=media-empty when paper is out

Notes

  • The STS interpretation is empirical and based on observed behavior on Linux, macOS, and Windows drivers.
  • The toner percent is used directly as the level with no additional scaling.

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors