lukevp / ESC-POS-.NET

Efficient, Easy to Use Thermal Printing & POS (Windows/Linux/OSX, WiFi/BT/USB/Ethernet)
MIT License
523 stars 171 forks source link

Printer stopped sending status update events #266

Open TheGreenAirplane opened 8 months ago

TheGreenAirplane commented 8 months ago

I have an XPrinter XP-80C printer, plugged into my compputer via USB and set up via a virutal COM port. I have an app that uses the printer, with the following code for setup:

_printer = new SerialPrinter(portName: _port, baudRate: _baudRate); Thread.Sleep(500); e = new EPSON();

// Only register status monitoring once. if (!_hasEnabledStatusMonitoring) { _printer.StatusChanged += StatusChanged; _hasEnabledStatusMonitoring = true; } _printer?.Write(e.Initialize()); _printer?.Write(e.Enable()); if (enableStatusBackMonitoring) { _printer.Write(e.EnableAutomaticStatusBack()); }

I'm currently developing the app, which means switching it on and off constantly, so the above code runs over and over again. It's been working fine so far (for about a week), but yesterday the status events just stopped coming. (printing still worked as before) I restarted my app several times but the StatusChanged event was simply never raised. In the end I had to turn the printer off and on again using the power button. This helped, and it's an acceptable solution for development, but if this happens in production I have a serious problem. Also, due to the nature of this issue it's impossible to reliably reproduce it.

Is there anything I can do to make sure this doesn't happen?

igorocampos commented 6 months ago

You would have to debug the code while facing the said issue.

You can start putting a break point in this method.

Or if the method is never called, go up from there and see where it stops getting the status update and maybe you will figure out why that is happening.