How to Manage Serial Port Connections During Terminal Sleep Mode

From wizarPOS
Revision as of 03:01, 17 December 2021 by Mahong (talk | contribs)

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:

intentFilter 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.