Giter Site home page Giter Site logo

get-the-paper-status-by-python's Introduction

Get the paper status by python

最近工作上突然被指派一個任務是去寫個程式來偵測印表機的狀態(是否有缺紙)結合line notify推撥訊息,但網路上查python在這方面的相關資源實在是很少,本來不想再花時間造輪子的,但剛好 python-escpos 這個library 沒有implement讀取紙張狀態這個功能,於是我使用 pySerial 來實作這個功能,完成後我把程式放在這希望之後可以幫助到有需要的人,適用於支援 ESC/POS 指令的印表機,程式中含有詳細註解可以幫助理解,若有任何問題歡迎和我聯繫。

使用 python 的 pySerial 模組進行序列通訊,取得印表機紙捲的狀態。

Using pySerial to get the paper status of escpos printers.

需求套件 / Requirement

This script requires pyserial library. You can install it easily by:

pip install pyserial

Detailed information can be found in pySerial installation.

ESC/POS 指令介紹

ESC/POS 指令可以傳送三種格式來和印表機進行序列通訊,分別是ASCII、十六進制(Hex)、十進制(Decimal),照著指令可以進一步去做到控制印表機進行列印、查詢印表機的狀態等等的動作,這次要做的內容是查詢印表機的紙捲狀態(有兩個指令可以查看),介紹如下:

第一個是 DLE EOT n (實時查看)

image

n = 4 是傳輸紙卷感測器狀態

image

第二個是 GS r n

image

image

References

Tested printers

  • APPOSTAR KPM-2520

License

Mit License Copyright (c) 2022 Daoxue Wu

get-the-paper-status-by-python's People

Contributors

daoxuewu avatar

Stargazers

 avatar  avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.