TavernerPOS - Source Code

Clone: 

git clone http://www.librarysmith.co.uk/tavernerPOS

 

Index » tavernerPOS : Commitdiff c68789

Fix Windows batch file error.

Matt Smith [15-12-03 00:45]
Fix Windows batch file error.
Refactor Terminal ID MAC address system to not try and enumerate loopback (which is was doing on Debian Systems).
diff --git a/etc/tavernerpos.bat b/etc/tavernerpos.bat
index 7215e8c..3c37e87 100755
--- a/etc/tavernerpos.bat
+++ b/etc/tavernerpos.bat
@@ -1,3 +1,3 @@
 @echo off

-java -jar java -jar ./tavernerPOS.jar
\ No newline at end of file
+java  -jar ./tavernerPOS.jar
\ No newline at end of file
diff --git a/src/com/floreantpos/config/TerminalConfig.java b/src/com/floreantpos/config/TerminalConfig.java
index a083501..a4dbf49 100755
--- a/src/com/floreantpos/config/TerminalConfig.java
+++ b/src/com/floreantpos/config/TerminalConfig.java
@@ -54,7 +54,7 @@ public class TerminalConfig {

 		if (isAutoTerminalID()==true) {
 			int terminalID=NetInfo.getTerminalIDFromMACAddr();
-			if (terminalID!=-1l) {
+			if (terminalID!=-1) {
 				return(terminalID);
 			}
 		}
diff --git a/src/com/floreantpos/getnetinfo/NetInfo.java b/src/com/floreantpos/getnetinfo/NetInfo.java
index f26f3c8..514a4c7 100755
--- a/src/com/floreantpos/getnetinfo/NetInfo.java
+++ b/src/com/floreantpos/getnetinfo/NetInfo.java
@@ -27,15 +27,42 @@ public class NetInfo {

 	 public static String getMACAddr() {

-			InetAddress ip;
 			try {
+				byte[] mac = null;
+				NetworkInterface network = null;
+				int c=0;
+				while((network==null) && (c<100)) {
+					System.out.print("Auto Terminal ID - Trying Network Interface: "+c+"\n");
+					network = NetworkInterface.getByIndex(c);
+					if (network != null)  {
+						mac = network.getHardwareAddress();
+
+						if (mac == null) {
+							network=null;
+							c++;
+							continue;
+						}
+
+						if (network.isLoopback()) {
+							network=null;
+							c++;
+							continue;
+						}
+
+					}
+					c++;
+				}

-				ip = InetAddress.getLocalHost();
-
-				NetworkInterface network = NetworkInterface.getByInetAddress(ip);
-
-				byte[] mac = network.getHardwareAddress();
-
+				if (network==null) {
+					System.out.print("MAC (interface) could not be determined for deriving TerminalID.\n");
+					return(null);
+				}
+
+				if (mac==null) {
+					System.out.print("MAC (hardware address) could not be determined for deriving TerminalID.\n");
+					return(null);
+				}
+
 				StringBuilder sb = new StringBuilder();
 				for (int i = 0; i < mac.length; i++) {
 					//sb.append(String.format("%02X%s", mac[i], (i < mac.length - 1) ? "-" : ""));
@@ -43,16 +70,14 @@ public class NetInfo {
 				}
 				return(sb.toString());

-			} catch (UnknownHostException e) {
-
-				//e.printStackTrace();

 			} catch (SocketException e){

 				//e.printStackTrace();

 			}
-
+
+
 			return(null);

 		   }
@@ -63,7 +88,8 @@ public class NetInfo {
 	 	 String terminalID = null;
 		  if ( mac != null) {
 		 	 terminalID=mac.replace("-","");
-			 terminalID=terminalID.substring(terminalID.length() - 10);
+			 System.out.println("MAC Address: "+terminalID);
+			 terminalID=terminalID.substring(terminalID.length() - 8);
 		 	} else return(-1);
 			return(Integer.parseInt(terminalID));
 		  }

Comments   

# Kitchen-receipt not printingJulio Ponce 2016-08-01 16:37
Good day I was Wondering if the button add in home screen to print kitchen receipt is avaliable in version 1.4, after clicking SAVE button wont print kitchen receipt, any help you can provide is welcome.

Best regards Julio
Reply | Reply with quote | Quote
# RE: Kitchen-receipt not printingMatt Smith 2016-08-01 17:52
Quoting Julio Ponce:
Good day I was Wondering if the button add in home screen to print kitchen receipt is avaliable in version 1.4, after clicking SAVE button wont print kitchen receipt, any help you can provide is welcome.

Best regards Julio


Hi,

As far as I'm aware none of that code has been changed that pertains to kitchen printers. Was it working on a previous build of TavernerPos?

Matt
Reply | Reply with quote | Quote

Add comment


Security code
Refresh