1
0
Эх сурвалжийг харах

Ability to specify output file directly

Baglio Tabifata 5 жил өмнө
parent
commit
bb5788e004

+ 4 - 4
src/main/java/info/hkzlab/dupal/analyzer/App.java

@@ -17,7 +17,7 @@ public class App {
     private static String serialDevice = null;
     private static PALSpecs pspecs = null;
     private static int outMask = -1;
-    private static String outDir = null;
+    private static String outFile = null;
 
     public static void main(String[] args) throws Exception {
         System.out.println("DuPAL Analyzer " + version);
@@ -30,7 +30,7 @@ public class App {
             }
 
             logger.error("Wrong number of arguments passed.\n"
-                    + "dupal_analyzer <serial_port> <pal_type> <output_dir> [hex_output_mask]\n"
+                    + "dupal_analyzer <serial_port> <pal_type> <output_file> [hex_output_mask]\n"
                     + "Where <pal_type> can be:\n" + supportedPALs.toString() + "\n");
 
             return;
@@ -40,7 +40,7 @@ public class App {
 
         DuPALManager dpm = new DuPALManager(serialDevice);
         DuPALCmdInterface dpci = new DuPALCmdInterface(dpm, pspecs);
-        DuPALAnalyzer dpan = new DuPALAnalyzer(dpci, outMask, outDir);
+        DuPALAnalyzer dpan = new DuPALAnalyzer(dpci, outMask, outFile);
 
         if (!dpm.enterRemoteMode()) {
             System.out.println("Unable to put DuPAL board in REMOTE MODE!");
@@ -69,7 +69,7 @@ public class App {
             System.exit(-1);
         }
 
-        outDir = args[2];
+        outFile = args[2];
 
         if(args.length >= 4) {
             outMask = Integer.parseInt(args[3], 16);

+ 5 - 10
src/main/java/info/hkzlab/dupal/analyzer/board/boardio/DuPALAnalyzer.java

@@ -1,6 +1,5 @@
 package info.hkzlab.dupal.analyzer.board.boardio;
 
-import java.io.File;
 import java.io.FileOutputStream;
 import java.io.IOException;
 import java.nio.charset.StandardCharsets;
@@ -19,19 +18,15 @@ import info.hkzlab.dupal.analyzer.utilities.BitUtils;
 public class DuPALAnalyzer {
     private static final Logger logger = LoggerFactory.getLogger(DuPALAnalyzer.class);
 
-    private static final String OUT_TABLE = "dupal_thrtable.tbl";
-
-    
-    private final String tblPath;
+    private final String outFile;
 
     private final DuPALCmdInterface dpci;
     private int ioAsOutMask;
     
-    public DuPALAnalyzer(final DuPALCmdInterface dpci, int ioAsOutMask, final String outPath) {
+    public DuPALAnalyzer(final DuPALCmdInterface dpci, int ioAsOutMask, final String outFile) {
         this.dpci = dpci;
         this.ioAsOutMask = ioAsOutMask;
-
-        tblPath = outPath + File.separator + OUT_TABLE;
+        this.outFile = outFile;
     } 
 
     public int detectIOTypeMask(final DuPALCmdInterface dpci) throws DuPALBoardException {
@@ -119,7 +114,7 @@ public class DuPALAnalyzer {
                 logger.info("Got " + osArray.length + " output states!");
             }
 
-            saveTableToFile(tblPath, header, table, footer);
+            saveTableToFile(outFile, header, table, footer);
         } catch(Exception e) {
             throw e;
         } finally {
@@ -133,7 +128,7 @@ public class DuPALAnalyzer {
         logger.info("saveTableToFile() -> Saving to " + destination);
 
         try {
-            fout = new FileOutputStream(tblPath);
+            fout = new FileOutputStream(outFile);
 
             fout.write(header.getBytes(StandardCharsets.US_ASCII));
             for(String row : rows) fout.write(row.getBytes(StandardCharsets.US_ASCII));