How to Manage Serial Port Connections During Terminal Sleep Mode

From wizarPOS
Revision as of 02:52, 17 December 2021 by Mahong (talk | contribs) (Created page with "When the temrinal enter the sleep mode, it will disconnect the power of the usb, which will make the connection broken. At that time, any serial port function can not work,...")
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)

When the temrinal enter the sleep mode, it will disconnect the power of the usb, which will make the connection broken.

At that time, any serial port function can not work, even after the terminal restore from sleep mode, wake up.

So the serial port should be closed before enter sleep mode. Then open the serial port any time after wakeup, the serial port should work fine.


Here is the code about how to monitor the screen on/off:

ntentFilter filter = new IntentFilter();
filter.addAction(Intent.ACTION_SCREEN_ON);
filter.addAction(Intent.ACTION_SCREEN_OFF);
registerReceiver(receiver, filter);

when receive screen off, close the serial port.