From 4b48c8be3e2bcfb36c5196ee5dc7528a69e5708c Mon Sep 17 00:00:00 2001 From: Oleg Elk <45400511+lumber1000@users.noreply.github.com> Date: Mon, 15 Mar 2021 17:00:14 +0300 Subject: [PATCH] Update DeviceConnection.java - waitingTime calculation bug fixed (data length was always zero - that caused problems with image printing) - removed unnecessary floating-point arithmetic in waitingTime calculation --- .../com/dantsu/escposprinter/connection/DeviceConnection.java | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/escposprinter/src/main/java/com/dantsu/escposprinter/connection/DeviceConnection.java b/escposprinter/src/main/java/com/dantsu/escposprinter/connection/DeviceConnection.java index 030b007..42a178d 100644 --- a/escposprinter/src/main/java/com/dantsu/escposprinter/connection/DeviceConnection.java +++ b/escposprinter/src/main/java/com/dantsu/escposprinter/connection/DeviceConnection.java @@ -53,9 +53,9 @@ public void send(int addWaitingTime) throws EscPosConnectionException { try { this.stream.write(this.data); this.stream.flush(); - this.data = new byte[0]; - int waitingTime = addWaitingTime + (int) Math.floor(this.data.length / 16f); + int waitingTime = addWaitingTime + this.data.length / 16; + this.data = new byte[0]; if(waitingTime > 0) { Thread.sleep(waitingTime); }