diff --git a/History.txt b/History.txt index 16c97c67..4ed0c2c3 100644 --- a/History.txt +++ b/History.txt @@ -5,6 +5,13 @@ Company : SHTRIH-M www.shtrih-m.ru (495) 787-6090 Url : https://github.com/shtrih-m/javapos_shtrih +******************************************************************************** + + 13.12.2022 + deviceServiceVersion = 1013682 + + [-] Fixed error with PPP port close + ******************************************************************************** 05.12.2022 diff --git a/Source/Core/src/com/shtrih/fiscalprinter/port/PPPThread.java b/Source/Core/src/com/shtrih/fiscalprinter/port/PPPThread.java index 4a5d316b..badcb3e5 100644 --- a/Source/Core/src/com/shtrih/fiscalprinter/port/PPPThread.java +++ b/Source/Core/src/com/shtrih/fiscalprinter/port/PPPThread.java @@ -104,6 +104,7 @@ public void stop() { } catch (Exception e) { logger.error(e); } + logger.debug("PPP thread stopped"); } public boolean waitForContext(long timeout, long timeToSleep) throws InterruptedException diff --git a/Source/Core/src/com/shtrih/jpos/monitoring/MonitoringServerX5.java b/Source/Core/src/com/shtrih/jpos/monitoring/MonitoringServerX5.java index 8ad9dc1a..1670ec2e 100644 --- a/Source/Core/src/com/shtrih/jpos/monitoring/MonitoringServerX5.java +++ b/Source/Core/src/com/shtrih/jpos/monitoring/MonitoringServerX5.java @@ -63,7 +63,7 @@ public void stop() throws Exception { public void run() { try { ServerSocket serverSocket = new ServerSocket(port); - while (!thread.isInterrupted()) { + while (!Thread.currentThread().isInterrupted()) { try { serverSocket.setSoTimeout(AcceptTimeout); Socket socket = serverSocket.accept(); diff --git a/Source/FiscalPrinterService/src/com/shtrih/util/ServiceVersion.java b/Source/FiscalPrinterService/src/com/shtrih/util/ServiceVersion.java index 1b16f8c9..91470fce 100644 --- a/Source/FiscalPrinterService/src/com/shtrih/util/ServiceVersion.java +++ b/Source/FiscalPrinterService/src/com/shtrih/util/ServiceVersion.java @@ -1,5 +1,5 @@ package com.shtrih.util; public class ServiceVersion { - public static final String VERSION = "681"; + public static final String VERSION = "681-1-g38e69718"; } \ No newline at end of file diff --git a/Source/android/FptrServiceAndroid/src/com/shtrih/fiscalprinter/port/PPPPort.java b/Source/android/FptrServiceAndroid/src/com/shtrih/fiscalprinter/port/PPPPort.java index d43ca56a..b74c957a 100644 --- a/Source/android/FptrServiceAndroid/src/com/shtrih/fiscalprinter/port/PPPPort.java +++ b/Source/android/FptrServiceAndroid/src/com/shtrih/fiscalprinter/port/PPPPort.java @@ -11,6 +11,7 @@ import com.shtrih.util.CompositeLogger; import com.shtrih.util.Localizer; import com.shtrih.util.StaticContext; +import com.shtrih.util.Hex; import java.io.IOException; import java.io.InputStream; @@ -35,6 +36,7 @@ public class PPPPort implements PrinterPort, PrinterPort.IPortEvents { private IPortEvents events; private Socket socket = null; private LocalSocket localSocket = null; + private boolean stopFlag = false; private Thread dispatchThread = null; private PPPThread pppThread = null; private int openTimeout = 3000; @@ -67,7 +69,9 @@ public synchronized void open(int timeout) throws Exception { logger.debug("open: OK"); } - public synchronized void connect(int timeout) throws Exception { + public synchronized void connect(int timeout) throws Exception + { + logger.debug("connect..."); if (isOpened()) return; openTimeout = timeout; localSocketName = UUID.randomUUID().toString(); @@ -85,6 +89,7 @@ public synchronized void connect(int timeout) throws Exception { if (events != null) { events.onConnect(); } + logger.debug("connect: OK"); } public void openSocket() throws Exception @@ -103,7 +108,9 @@ public void openSocket() throws Exception } } - public void startPPPThread() throws Exception { + public void startPPPThread() throws Exception + { + logger.debug("startPPPThread()..."); if (pppThread != null) { return; } @@ -122,6 +129,7 @@ public void startPPPThread() throws Exception { pppThread = new PPPThread(config); pppThread.start(); pppThread.waitForStatus("RUNNING", 5000); + logger.debug("startPPPThread(): OK"); } public void openLocalSocket(int timeout) throws Exception { @@ -191,6 +199,7 @@ public void startDispatchThread() { if (dispatchThread != null) return; logger.debug("startDispatchThread"); + stopFlag = false; dispatchThread = new Thread(new Runnable() { @Override public void run() { @@ -202,13 +211,16 @@ public void run() { } public void stopDispatchThread() { - if (dispatchThread == null) return; - logger.debug("stopDispatchThread"); + if (dispatchThread == null) return; + stopFlag = true; dispatchThread.interrupt(); try { dispatchThread.join(); - } catch (InterruptedException e) { + } catch (InterruptedException e) + { + logger.error("stopDispatchThread ", e); + Thread.currentThread().interrupt(); } dispatchThread = null; logger.debug("stopDispatchThread: OK"); @@ -233,18 +245,23 @@ public void closeSocket() { public void dispatchProc() { logger.debug("dispatchProc.start"); try { - while (true) { + while (!stopFlag) + { Thread.sleep(0); dispatchPackets(); } - } catch (InterruptedException e) { + } catch (InterruptedException e) + { + logger.error("dispatchProc: ", e); + Thread.currentThread().interrupt(); } catch (Exception e) { logger.error("dispatchProc: ", e); } logger.debug("dispatchProc.end"); } - public void dispatchPackets() throws Exception { + public void dispatchPackets() throws Exception + { int count; byte[] data; @@ -256,7 +273,6 @@ public void dispatchPackets() throws Exception { OutputStream os = localSocket.getOutputStream(); if (os != null) { os.write(data, 0, count); - os.flush(); } } // read localSocket diff --git a/Source/android/tinyJavaPosTester/src/com/shtrih/tinyjavapostester/MainActivity.java b/Source/android/tinyJavaPosTester/src/com/shtrih/tinyjavapostester/MainActivity.java index b8202af9..c79bec42 100644 --- a/Source/android/tinyJavaPosTester/src/com/shtrih/tinyjavapostester/MainActivity.java +++ b/Source/android/tinyJavaPosTester/src/com/shtrih/tinyjavapostester/MainActivity.java @@ -582,6 +582,12 @@ protected String doInBackground(Void... params) { printer.setLibraryContext(getApplicationContext()); // printer.addStatusUpdateListener(new FptrEventListener()); printer.claim(3000); + /* + for (int i=0;i<10;i++){ + printer.setDeviceEnabled(true); + printer.setDeviceEnabled(false); + } + */ printer.setDeviceEnabled(true); model.ScocUpdaterStatus.set(""); printer.setParameter3(SmFptrConst.SMFPTR_DIO_PARAM_FIRMWARE_UPDATE_OBSERVER, this.params.observer);