0

i got this project a lil one i would like to use in my job, it would make thinks easier when i'm detecting if a printer is connected, what's the point of this?

We have like 26 printers to print purchase ticket from clients sales, the point is that some times this printers disconnect (maybe user do it by accident), and my co worker had the idea to do an app that tell us when they get disconnected.

Here is the thing, they are all connected through RS232 serial port, and that means i can't make a ping to the printer like a normal network printer, so the idea is to have a program that tell us when they are disconnected by making this app run in every single computer.

I just need the way to know if the printer disconnect or not, i was navigating and i found this codes.

import serial
from serial import ReaderThread
try:
    s = serial.Serial('COM1')
    res = s.read()
    print(res)
except Exception as ex:
    print("Error: " + str(ex))

and this one

import win32com.client
wmi = win32com.client.GetObject("winmgmts:")
for serial in wmi.InstancesOf("Win32_SerialPort"):
       print (serial.Name, serial.Description, serial.DeviceID)

i checked the documentation from this imports, and test different parameters by they doesn't trigger when i disconnect the printer, also they are all running windows 10.

  • If all printers are the same you should have a look at their datasheet. If a command description is available, try sending some command which returns some status info or product info. This way you can check if the printer is alive and connected. Just opening a serial port does not work in your case, as your printer is not invoked/or asked if its okay with opening this port - therefore, you can not detect if the printer is disconnected. – ElectronicsStudent Mar 10 '23 at 02:40
  • the printers are fiscal, so it means documentation about development is only in hands of government approved developers, i don't know if i would be able to do that, i'll try and update the progress. – José Timaure Mar 10 '23 at 18:50
  • Hmmmmh i see. But i guess there maybe is some sort of interface description or equivalent available? – ElectronicsStudent Mar 11 '23 at 01:09

0 Answers0