v0.2-development intermediate results of friday codings

This commit is contained in:
Dmitry Isaenko 2019-02-16 04:34:30 +03:00
parent f7e2ae9771
commit 49bd078bc5
11 changed files with 684 additions and 339 deletions

View file

@ -0,0 +1,55 @@
package nsusbloader.Controllers;
import nsusbloader.NSLDataTypes.FileStatus;
import java.io.File;
public class NSLRowModel {
private String status; // 0 = unknown, 1 = uploaded, 2 = bad file
private File nspFile;
private String nspFileName;
private boolean markForUpload;
NSLRowModel(File nspFile, boolean checkBoxValue){
this.nspFile = nspFile;
this.markForUpload = checkBoxValue;
this.nspFileName = nspFile.getName();
this.status = "";
}
// Model methods start
public String getStatus(){
return status;
}
public String getNspFileName(){
return nspFileName;
}
public boolean isMarkForUpload() {
return markForUpload;
}
// Model methods end
public void setMarkForUpload(boolean value){
markForUpload = value;
}
public void setStatus(FileStatus status){ // TODO: Localization
switch (status){
case FAILED:
this.status = "Upload failed";
break;
case UPLOADED:
this.status = "Uploaded";
markForUpload = false;
break;
case INCORRECT:
this.status = "File incorrect";
markForUpload = false;
break;
}
}
public File getNspFile(){
return nspFile;
}
}

View file

@ -0,0 +1,146 @@
package nsusbloader.Controllers;
import javafx.beans.property.SimpleBooleanProperty;
import javafx.beans.value.ChangeListener;
import javafx.beans.value.ObservableValue;
import javafx.collections.FXCollections;
import javafx.collections.ObservableList;
import javafx.fxml.FXML;
import javafx.fxml.Initializable;
import javafx.scene.control.Label;
import javafx.scene.control.TableCell;
import javafx.scene.control.TableColumn;
import javafx.scene.control.TableView;
import javafx.scene.control.cell.CheckBoxTableCell;
import javafx.scene.control.cell.PropertyValueFactory;
import javafx.util.Callback;
import nsusbloader.NSLDataTypes.FileStatus;
import java.io.File;
import java.net.URL;
import java.util.ArrayList;
import java.util.List;
import java.util.ResourceBundle;
public class NSTableViewController implements Initializable {
@FXML
private TableView<NSLRowModel> table;
private ObservableList<NSLRowModel> rowsObsLst;
@Override
public void initialize(URL url, ResourceBundle resourceBundle) {
rowsObsLst = FXCollections.observableArrayList();
table.setPlaceholder(new Label());
TableColumn<NSLRowModel, String> statusColumn = new TableColumn<>("Status"); // TODO: Localization
TableColumn<NSLRowModel, String> fileNameColumn = new TableColumn<>("File Name"); // TODO: Localization
TableColumn<NSLRowModel, Boolean> uploadColumn = new TableColumn<>("Upload?"); // TODO: Localization
statusColumn.setMinWidth(70.0);
fileNameColumn.setMinWidth(270.0);
uploadColumn.setMinWidth(70.0);
statusColumn.setCellValueFactory(new PropertyValueFactory<>("status"));
fileNameColumn.setCellValueFactory(new PropertyValueFactory<>("nspFileName"));
// ><
uploadColumn.setCellValueFactory(new Callback<TableColumn.CellDataFeatures<NSLRowModel, Boolean>, ObservableValue<Boolean>>() {
@Override
public ObservableValue<Boolean> call(TableColumn.CellDataFeatures<NSLRowModel, Boolean> paramFeatures) {
NSLRowModel model = paramFeatures.getValue();
SimpleBooleanProperty booleanProperty = new SimpleBooleanProperty(model.isMarkForUpload());
booleanProperty.addListener(new ChangeListener<Boolean>() {
@Override
public void changed(ObservableValue<? extends Boolean> observableValue, Boolean oldValue, Boolean newValue) {
model.setMarkForUpload(newValue);
// TODO: add reference to this general class method which will validate protocol and restict selection
}
});
return booleanProperty;
}
});
uploadColumn.setCellFactory(new Callback<TableColumn<NSLRowModel, Boolean>, TableCell<NSLRowModel, Boolean>>() {
@Override
public TableCell<NSLRowModel, Boolean> call(TableColumn<NSLRowModel, Boolean> paramFeatures) {
CheckBoxTableCell<NSLRowModel, Boolean> cell = new CheckBoxTableCell<>();
return cell;
}
});
table.setItems(rowsObsLst);
table.getColumns().addAll(statusColumn, fileNameColumn, uploadColumn);
rowsObsLst.add(new NSLRowModel(new File("/tmp/dump_file"), true));
rowsObsLst.add(new NSLRowModel(new File("/home/loper/тяжелые будни.mp4"), false));
rowsObsLst.add(new NSLRowModel(new File("/home/loper/стихи.txt"), false));
rowsObsLst.add(new NSLRowModel(new File("/home/loper/стихи_2"), false));
rowsObsLst.add(new NSLRowModel(new File("/home/loper/стихи_1"), false));
}
/**
* Add files when user selected them
* */
public void addFiles(List<File> files, String protocol){
rowsObsLst.clear();
if (protocol.equals("TinFoil")){
for (File nspFile: files){
rowsObsLst.add(new NSLRowModel(nspFile, true));
}
}
else {
rowsObsLst.clear();
for (File nspFile: files){
rowsObsLst.add(new NSLRowModel(nspFile, false));
}
rowsObsLst.get(0).setMarkForUpload(true);
}
}
/**
* Return files ready for upload. Requested from NSLMainController only
* @return null if no files marked for upload
* List<File> if there are files
* */
public List<File> getFiles(){
List<File> files = new ArrayList<>();
if (rowsObsLst.isEmpty())
return null;
else {
for (NSLRowModel model: rowsObsLst){
if (model.isMarkForUpload())
files.add(model.getNspFile());
}
if (!files.isEmpty())
return files;
else
return null;
}
}
/**
* Update files in case something is wrong. Requested from UsbCommunications _OR_ PFS
* */
public void reportFileStatus(String fileName, FileStatus status){
for (NSLRowModel model: rowsObsLst){
if (model.getNspFileName().equals(fileName)){
model.setStatus(status);
}
}
}
/**
* Called if selected different USB protocol
* */
public void protocolChangeEvent(String protocol){
if (rowsObsLst.isEmpty())
return;
if (protocol.equals("TinFoil")){
for (NSLRowModel model: rowsObsLst)
model.setMarkForUpload(true);
}
else {
for (NSLRowModel model: rowsObsLst)
model.setMarkForUpload(false);
rowsObsLst.get(0).setMarkForUpload(true);
}
table.refresh();
}
}

View file

@ -1,5 +1,5 @@
/** /**
Name: NSL-USBFoil Name: NS-USBloader
@author Dmitry Isaenko @author Dmitry Isaenko
License: GNU GPL v.3 License: GNU GPL v.3
@see https://github.com/developersu/ @see https://github.com/developersu/

View file

@ -2,15 +2,14 @@ package nsusbloader;
import javafx.collections.FXCollections; import javafx.collections.FXCollections;
import javafx.collections.ObservableList; import javafx.collections.ObservableList;
import javafx.event.ActionEvent;
import javafx.fxml.FXML; import javafx.fxml.FXML;
import javafx.fxml.Initializable; import javafx.fxml.Initializable;
import javafx.scene.control.Button; import javafx.scene.control.*;
import javafx.scene.control.ChoiceBox;
import javafx.scene.control.ProgressBar;
import javafx.scene.control.TextArea;
import javafx.scene.layout.Pane; import javafx.scene.layout.Pane;
import javafx.scene.layout.Region; import javafx.scene.layout.Region;
import javafx.stage.FileChooser; import javafx.stage.FileChooser;
import nsusbloader.Controllers.NSTableViewController;
import java.io.File; import java.io.File;
import java.net.URL; import java.net.URL;
@ -36,11 +35,13 @@ public class NSLMainController implements Initializable {
private ChoiceBox<String> choiceProtocol; private ChoiceBox<String> choiceProtocol;
@FXML @FXML
private Button switchThemeBtn; private Button switchThemeBtn;
private Region btnSwitchImage;
@FXML @FXML
private Pane specialPane; private Pane specialPane;
@FXML
private NSTableViewController tableFilesListController;
private Thread usbThread; private Thread usbThread;
private String previouslyOpenedPath; private String previouslyOpenedPath;
@ -69,19 +70,22 @@ public class NSLMainController implements Initializable {
uploadStopBtn.getStyleClass().add("buttonUp"); uploadStopBtn.getStyleClass().add("buttonUp");
uploadStopBtn.setGraphic(btnUpStopImage); uploadStopBtn.setGraphic(btnUpStopImage);
ObservableList<String> choiceProtocolList = FXCollections.observableArrayList(); ObservableList<String> choiceProtocolList = FXCollections.observableArrayList("TinFoil", "GoldLeaf");
choiceProtocolList.setAll("TinFoil", "GoldLeaf");
choiceProtocol.setItems(choiceProtocolList); choiceProtocol.setItems(choiceProtocolList);
choiceProtocol.getSelectionModel().select(0); // TODO: shared settings choiceProtocol.getSelectionModel().select(0); // TODO: shared settings
choiceProtocol.setOnAction(e->tableFilesListController.protocolChangeEvent(choiceProtocol.getSelectionModel().getSelectedItem()));
this.previouslyOpenedPath = null; this.previouslyOpenedPath = null;
this.btnSwitchImage = new Region(); Region btnSwitchImage = new Region();
btnSwitchImage.getStyleClass().add("regionLamp"); btnSwitchImage.getStyleClass().add("regionLamp");
switchThemeBtn.setGraphic(btnSwitchImage); switchThemeBtn.setGraphic(btnSwitchImage);
this.switchThemeBtn.setOnAction(e->switchTheme()); this.switchThemeBtn.setOnAction(e->switchTheme());
}
}
/**
* Changes UI theme on the go
* */
private void switchTheme(){ private void switchTheme(){
if (switchThemeBtn.getScene().getStylesheets().get(0).equals("/res/app.css")) { if (switchThemeBtn.getScene().getStylesheets().get(0).equals("/res/app.css")) {
switchThemeBtn.getScene().getStylesheets().remove("/res/app.css"); switchThemeBtn.getScene().getStylesheets().remove("/res/app.css");

View file

@ -1,5 +1,6 @@
package nsusbloader.PFS; package nsusbloader.PFS;
import nsusbloader.NSLDataTypes.MsgType;
import nsusbloader.ServiceWindow; import nsusbloader.ServiceWindow;
import java.io.*; import java.io.*;
@ -18,7 +19,6 @@ public class PFSProvider {
private static final byte[] PFS0 = new byte[]{(byte)0x50, (byte)0x46, (byte)0x53, (byte)0x30}; // PFS0, and what did you think? private static final byte[] PFS0 = new byte[]{(byte)0x50, (byte)0x46, (byte)0x53, (byte)0x30}; // PFS0, and what did you think?
private BlockingQueue<String> msgQueue; private BlockingQueue<String> msgQueue;
private enum MsgType {PASS, FAIL, INFO, WARNING}
private ResourceBundle rb; private ResourceBundle rb;
private RandomAccessFile randAccessFile; private RandomAccessFile randAccessFile;
@ -106,7 +106,6 @@ public class PFSProvider {
for (int i=0; i<filesCount; i++){ for (int i=0; i<filesCount; i++){
if (randAccessFile.read(ncaInfoArr) == 24) { if (randAccessFile.read(ncaInfoArr) == 24) {
printLog("Read NCA inside NSP: " + i, MsgType.PASS); printLog("Read NCA inside NSP: " + i, MsgType.PASS);
//hexDumpUTF8(ncaInfoArr); // TODO: DEBUG
} }
else { else {
printLog("Read NCA inside NSP: "+i, MsgType.FAIL); printLog("Read NCA inside NSP: "+i, MsgType.FAIL);
@ -149,7 +148,6 @@ public class PFSProvider {
printLog("Final padding check", MsgType.PASS); printLog("Final padding check", MsgType.PASS);
else else
printLog("Final padding check", MsgType.WARNING); printLog("Final padding check", MsgType.WARNING);
//hexDumpUTF8(bufForInt); // TODO: DEBUG
// Calculate position including header for body size offset // Calculate position including header for body size offset
bodySize = randAccessFile.getFilePointer()+header; bodySize = randAccessFile.getFilePointer()+header;
@ -174,7 +172,6 @@ public class PFSProvider {
if (new String(exchangeTempArray, StandardCharsets.UTF_8).toLowerCase().endsWith(".tik")) if (new String(exchangeTempArray, StandardCharsets.UTF_8).toLowerCase().endsWith(".tik"))
this.ticketID = i; this.ticketID = i;
this.ncaFiles[i].setNcaFileName(Arrays.copyOf(exchangeTempArray, exchangeTempArray.length)); this.ncaFiles[i].setNcaFileName(Arrays.copyOf(exchangeTempArray, exchangeTempArray.length));
//hexDumpUTF8(exchangeTempArray); // TODO: DEBUG
} }
randAccessFile.close(); randAccessFile.close();
} }
@ -256,7 +253,7 @@ public class PFSProvider {
msgQueue.put(message); msgQueue.put(message);
} }
}catch (InterruptedException ie){ }catch (InterruptedException ie){
ie.printStackTrace(); ie.printStackTrace(); //TODO: INFORM
} }
} }

View file

@ -3,6 +3,7 @@ package nsusbloader;
import javafx.concurrent.Task; import javafx.concurrent.Task;
import javafx.scene.control.ProgressBar; import javafx.scene.control.ProgressBar;
import javafx.scene.control.TextArea; import javafx.scene.control.TextArea;
import nsusbloader.NSLDataTypes.MsgType;
import nsusbloader.PFS.PFSProvider; import nsusbloader.PFS.PFSProvider;
import org.usb4java.*; import org.usb4java.*;
@ -18,7 +19,6 @@ import java.util.HashMap;
import java.util.List; import java.util.List;
import java.util.concurrent.BlockingQueue; import java.util.concurrent.BlockingQueue;
import java.util.concurrent.LinkedBlockingQueue; import java.util.concurrent.LinkedBlockingQueue;
import java.util.concurrent.TimeUnit;
import static nsusbloader.RainbowHexDump.hexDumpUTF8; import static nsusbloader.RainbowHexDump.hexDumpUTF8;
@ -26,8 +26,7 @@ class UsbCommunications extends Task<Void> {
private final int DEFAULT_INTERFACE = 0; private final int DEFAULT_INTERFACE = 0;
private BlockingQueue<String> msgQueue; private BlockingQueue<String> msgQueue;
private BlockingQueue<Double> progressQueue ; private BlockingQueue<Double> progressQueue;
private enum MsgType {PASS, FAIL, INFO, WARNING}
private MessagesConsumer msgConsumer; private MessagesConsumer msgConsumer;
private HashMap<String, File> nspMap; private HashMap<String, File> nspMap;
@ -268,9 +267,7 @@ class UsbCommunications extends Task<Void> {
//-------------------------------------------------------------------------------------------------------------- //--------------------------------------------------------------------------------------------------------------
if (protocol.equals("TinFoil")) { if (protocol.equals("TinFoil")) {
if (!sendListOfNSP()) new TinFoil();
return null;
proceedCommands();
} else { } else {
new GoldLeaf(); new GoldLeaf();
} }
@ -280,29 +277,17 @@ class UsbCommunications extends Task<Void> {
return null; return null;
} }
/** /**
* Correct exit * Tinfoil processing
* */ * */
private void close(){ private class TinFoil{
// close handler in the end TinFoil(){
if (handlerNS != null) { if (!sendListOfNSP())
// Try to release interface return;
int result = LibUsb.releaseInterface(handlerNS, DEFAULT_INTERFACE); proceedCommands();
if (result != LibUsb.SUCCESS)
printLog("Release interface\n Returned: "+result+" (sometimes it's not an issue)", MsgType.WARNING);
else
printLog("Release interface", MsgType.PASS);
LibUsb.close(handlerNS);
printLog("Requested handler close", MsgType.INFO);
}
// close context in the end
if (contextNS != null) {
LibUsb.exit(contextNS);
printLog("Requested context close", MsgType.INFO);
}
msgConsumer.interrupt();
} }
/**
* Send what NSP will be transferred
* */
private boolean sendListOfNSP(){ private boolean sendListOfNSP(){
// Send list of NSP files: // Send list of NSP files:
// Proceed "TUL0" // Proceed "TUL0"
@ -529,90 +514,10 @@ class UsbCommunications extends Task<Void> {
return true; return true;
} }
/**
* Sending any byte array to USB device
* @return 'true' if no issues
* 'false' if errors happened
* */
private boolean writeToUsb(byte[] message){
ByteBuffer writeBuffer = ByteBuffer.allocateDirect(message.length); //writeBuffer.order() equals BIG_ENDIAN;
writeBuffer.put(message);
// DONT EVEN THINK OF USING writeBuffer.rewind(); // well..
IntBuffer writeBufTransferred = IntBuffer.allocate(1);
int result;
result = LibUsb.bulkTransfer(handlerNS, (byte) 0x01, writeBuffer, writeBufTransferred, 0); // last one is TIMEOUT. 0 stands for unlimited. Endpoint OUT = 0x01
if (result != LibUsb.SUCCESS){
switch (result){
case LibUsb.ERROR_TIMEOUT:
printLog("Data transfer (write) issue\n Returned: ERROR_TIMEOUT", MsgType.FAIL);
break;
case LibUsb.ERROR_PIPE: //WUT?? I dunno man looks overkill in here..
printLog("Data transfer (write) issue\n Returned: ERROR_PIPE", MsgType.FAIL);
break;
case LibUsb.ERROR_OVERFLOW:
printLog("Data transfer (write) issue\n Returned: ERROR_OVERFLOW", MsgType.FAIL);
break;
case LibUsb.ERROR_NO_DEVICE:
printLog("Data transfer (write) issue\n Returned: ERROR_NO_DEVICE", MsgType.FAIL);
break;
default:
printLog("Data transfer (write) issue\n Returned: "+result, MsgType.FAIL);
}
printLog("Execution stopped", MsgType.FAIL);
return false;
}else {
if (writeBufTransferred.get() != message.length){
printLog("Data transfer (write) issue\n Requested: "+message.length+"\n Transferred: "+writeBufTransferred.get(), MsgType.FAIL);
return false;
}
else {
return true;
}
}
} }
/** /**
* Reading what USB device responded. * Tinfoil processing
* @return byte array if data read successful
* 'null' if read failed
* */ * */
private byte[] readFromUsb(){
ByteBuffer readBuffer = ByteBuffer.allocateDirect(512);// //readBuffer.order() equals BIG_ENDIAN; DON'T TOUCH. And we will always allocate readBuffer for max-size endpoint supports (512 bytes)
// We can limit it to 32 bytes, but there is a non-zero chance to got OVERFLOW from libusb.
IntBuffer readBufTransferred = IntBuffer.allocate(1);
int result;
result = LibUsb.bulkTransfer(handlerNS, (byte) 0x81, readBuffer, readBufTransferred, 0); // last one is TIMEOUT. 0 stands for unlimited. Endpoint IN = 0x81
if (result != LibUsb.SUCCESS){
switch (result){
case LibUsb.ERROR_TIMEOUT:
printLog("Data transfer (read) issue\n Returned: ERROR_TIMEOUT", MsgType.FAIL);
break;
case LibUsb.ERROR_PIPE: //WUT?? I dunno man looks overkill in here..
printLog("Data transfer (read) issue\n Returned: ERROR_PIPE", MsgType.FAIL);
break;
case LibUsb.ERROR_OVERFLOW:
printLog("Data transfer (read) issue\n Returned: ERROR_OVERFLOW", MsgType.FAIL);
break;
case LibUsb.ERROR_NO_DEVICE:
printLog("Data transfer (read) issue\n Returned: ERROR_NO_DEVICE", MsgType.FAIL);
break;
default:
printLog("Data transfer (read) issue\n Returned: "+result, MsgType.FAIL);
}
printLog("Execution stopped", MsgType.FAIL);
return null;
} else {
int trans = readBufTransferred.get();
byte[] receivedBytes = new byte[trans];
readBuffer.get(receivedBytes);
/* DEBUG START----------------------------------------------------------------------------------------------*
hexDumpUTF8(receivedBytes);
// DEBUG END----------------------------------------------------------------------------------------------*/
return receivedBytes;
}
}
private class GoldLeaf{ private class GoldLeaf{
// CMD G L U C ID 0 0 0 // CMD G L U C ID 0 0 0
private final byte[] CMD_ConnectionRequest = new byte[]{0x47, 0x4c, 0x55, 0x43, 0x00, 0x00, 0x00, 0x00}; // Write-only command private final byte[] CMD_ConnectionRequest = new byte[]{0x47, 0x4c, 0x55, 0x43, 0x00, 0x00, 0x00, 0x00}; // Write-only command
@ -807,8 +712,118 @@ class UsbCommunications extends Task<Void> {
return true; return true;
} }
} }
//------------------------------------------------------------------------------------------------------------------ //------------------------------------------------------------------------------------------------------------------
/**
* Correct exit
* */
private void close(){
// close handler in the end
if (handlerNS != null) {
// Try to release interface
int result = LibUsb.releaseInterface(handlerNS, DEFAULT_INTERFACE);
if (result != LibUsb.SUCCESS)
printLog("Release interface\n Returned: "+result+" (sometimes it's not an issue)", MsgType.WARNING);
else
printLog("Release interface", MsgType.PASS);
LibUsb.close(handlerNS);
printLog("Requested handler close", MsgType.INFO);
}
// close context in the end
if (contextNS != null) {
LibUsb.exit(contextNS);
printLog("Requested context close", MsgType.INFO);
}
msgConsumer.interrupt();
}
/**
* Sending any byte array to USB device
* @return 'true' if no issues
* 'false' if errors happened
* */
private boolean writeToUsb(byte[] message){
ByteBuffer writeBuffer = ByteBuffer.allocateDirect(message.length); //writeBuffer.order() equals BIG_ENDIAN;
writeBuffer.put(message);
// DONT EVEN THINK OF USING writeBuffer.rewind(); // well..
IntBuffer writeBufTransferred = IntBuffer.allocate(1);
int result;
result = LibUsb.bulkTransfer(handlerNS, (byte) 0x01, writeBuffer, writeBufTransferred, 0); // last one is TIMEOUT. 0 stands for unlimited. Endpoint OUT = 0x01
if (result != LibUsb.SUCCESS){
switch (result){
case LibUsb.ERROR_TIMEOUT:
printLog("Data transfer (write) issue\n Returned: ERROR_TIMEOUT", MsgType.FAIL);
break;
case LibUsb.ERROR_PIPE: //WUT?? I dunno man looks overkill in here..
printLog("Data transfer (write) issue\n Returned: ERROR_PIPE", MsgType.FAIL);
break;
case LibUsb.ERROR_OVERFLOW:
printLog("Data transfer (write) issue\n Returned: ERROR_OVERFLOW", MsgType.FAIL);
break;
case LibUsb.ERROR_NO_DEVICE:
printLog("Data transfer (write) issue\n Returned: ERROR_NO_DEVICE", MsgType.FAIL);
break;
default:
printLog("Data transfer (write) issue\n Returned: "+result, MsgType.FAIL);
}
printLog("Execution stopped", MsgType.FAIL);
return false;
}else {
if (writeBufTransferred.get() != message.length){
printLog("Data transfer (write) issue\n Requested: "+message.length+"\n Transferred: "+writeBufTransferred.get(), MsgType.FAIL);
return false;
}
else {
return true;
}
}
}
/**
* Reading what USB device responded.
* @return byte array if data read successful
* 'null' if read failed
* */
private byte[] readFromUsb(){
ByteBuffer readBuffer = ByteBuffer.allocateDirect(512);// //readBuffer.order() equals BIG_ENDIAN; DON'T TOUCH. And we will always allocate readBuffer for max-size endpoint supports (512 bytes)
// We can limit it to 32 bytes, but there is a non-zero chance to got OVERFLOW from libusb.
IntBuffer readBufTransferred = IntBuffer.allocate(1);
int result;
result = LibUsb.bulkTransfer(handlerNS, (byte) 0x81, readBuffer, readBufTransferred, 0); // last one is TIMEOUT. 0 stands for unlimited. Endpoint IN = 0x81
if (result != LibUsb.SUCCESS){
switch (result){
case LibUsb.ERROR_TIMEOUT:
printLog("Data transfer (read) issue\n Returned: ERROR_TIMEOUT", MsgType.FAIL);
break;
case LibUsb.ERROR_PIPE: //WUT?? I dunno man looks overkill in here..
printLog("Data transfer (read) issue\n Returned: ERROR_PIPE", MsgType.FAIL);
break;
case LibUsb.ERROR_OVERFLOW:
printLog("Data transfer (read) issue\n Returned: ERROR_OVERFLOW", MsgType.FAIL);
break;
case LibUsb.ERROR_NO_DEVICE:
printLog("Data transfer (read) issue\n Returned: ERROR_NO_DEVICE", MsgType.FAIL);
break;
case LibUsb.ERROR_IO:
printLog("Data transfer (read) issue\n Returned: ERROR_IO", MsgType.FAIL);
break;
default:
printLog("Data transfer (read) issue\n Returned: "+result, MsgType.FAIL);
}
printLog("Execution stopped", MsgType.FAIL);
return null;
} else {
int trans = readBufTransferred.get();
byte[] receivedBytes = new byte[trans];
readBuffer.get(receivedBytes);
/* DEBUG START----------------------------------------------------------------------------------------------*
hexDumpUTF8(receivedBytes);
// DEBUG END----------------------------------------------------------------------------------------------*/
return receivedBytes;
}
}
/** /**
* This is what will print to textArea of the application. * This is what will print to textArea of the application.
* */ * */

View file

@ -4,6 +4,8 @@
<?import javafx.scene.control.Button?> <?import javafx.scene.control.Button?>
<?import javafx.scene.control.ChoiceBox?> <?import javafx.scene.control.ChoiceBox?>
<?import javafx.scene.control.ProgressBar?> <?import javafx.scene.control.ProgressBar?>
<?import javafx.scene.control.Tab?>
<?import javafx.scene.control.TabPane?>
<?import javafx.scene.control.TextArea?> <?import javafx.scene.control.TextArea?>
<?import javafx.scene.control.ToolBar?> <?import javafx.scene.control.ToolBar?>
<?import javafx.scene.layout.AnchorPane?> <?import javafx.scene.layout.AnchorPane?>
@ -18,11 +20,17 @@
<AnchorPane maxHeight="-Infinity" maxWidth="-Infinity" minHeight="-Infinity" minWidth="-Infinity" prefHeight="400.0" prefWidth="600.0" xmlns="http://javafx.com/javafx/8.0.141" xmlns:fx="http://javafx.com/fxml/1" fx:controller="nsusbloader.NSLMainController"> <AnchorPane maxHeight="-Infinity" maxWidth="-Infinity" minHeight="-Infinity" minWidth="-Infinity" prefHeight="400.0" prefWidth="600.0" xmlns="http://javafx.com/javafx/8.0.141" xmlns:fx="http://javafx.com/fxml/1" fx:controller="nsusbloader.NSLMainController">
<children> <children>
<VBox AnchorPane.bottomAnchor="0.0" AnchorPane.leftAnchor="0.0" AnchorPane.rightAnchor="0.0" AnchorPane.topAnchor="0.0"> <VBox AnchorPane.bottomAnchor="0.0" AnchorPane.leftAnchor="0.0" AnchorPane.rightAnchor="0.0" AnchorPane.topAnchor="0.0">
<children>
<TabPane prefHeight="200.0" prefWidth="200.0" side="RIGHT" tabClosingPolicy="UNAVAILABLE" VBox.vgrow="ALWAYS">
<tabs>
<Tab closable="false">
<content>
<VBox prefHeight="200.0" prefWidth="100.0">
<children> <children>
<ToolBar> <ToolBar>
<items> <items>
<Pane HBox.hgrow="ALWAYS" />
<ChoiceBox fx:id="choiceProtocol" prefWidth="120.0" /> <ChoiceBox fx:id="choiceProtocol" prefWidth="120.0" />
<Pane HBox.hgrow="ALWAYS" />
<Button fx:id="switchThemeBtn" mnemonicParsing="false" /> <Button fx:id="switchThemeBtn" mnemonicParsing="false" />
</items> </items>
</ToolBar> </ToolBar>
@ -38,12 +46,36 @@
<children> <children>
<Pane fx:id="specialPane" GridPane.columnIndex="1" /> <Pane fx:id="specialPane" GridPane.columnIndex="1" />
</children> </children>
<VBox.margin>
<Insets bottom="2.0" />
</VBox.margin>
</GridPane> </GridPane>
<fx:include fx:id="tableFilesList" source="TableView.fxml" VBox.vgrow="ALWAYS" />
</children>
</VBox>
</content>
<graphic>
<SVGPath content="M21,19V17H8V19H21M21,13V11H8V13H21M8,7H21V5H8V7M4,5V7H6V5H4M3,5A1,1 0 0,1 4,4H6A1,1 0 0,1 7,5V7A1,1 0 0,1 6,8H4A1,1 0 0,1 3,7V5M4,11V13H6V11H4M3,11A1,1 0 0,1 4,10H6A1,1 0 0,1 7,11V13A1,1 0 0,1 6,14H4A1,1 0 0,1 3,13V11M4,17V19H6V17H4M3,17A1,1 0 0,1 4,16H6A1,1 0 0,1 7,17V19A1,1 0 0,1 6,20H4A1,1 0 0,1 3,19V17Z" />
</graphic>
</Tab>
<Tab closable="false">
<content>
<VBox prefHeight="200.0" prefWidth="100.0">
<children>
<TextArea fx:id="logArea" editable="false" VBox.vgrow="ALWAYS"> <TextArea fx:id="logArea" editable="false" VBox.vgrow="ALWAYS">
<VBox.margin> <VBox.margin>
<Insets bottom="2.0" left="5.0" right="5.0" top="5.0" /> <Insets bottom="2.0" left="5.0" right="5.0" top="5.0" />
</VBox.margin> </VBox.margin>
</TextArea> </TextArea>
</children>
</VBox>
</content>
<graphic>
<SVGPath content="M19,3H14.82C14.4,1.84 13.3,1 12,1C10.7,1 9.6,1.84 9.18,3H5A2,2 0 0,0 3,5V19A2,2 0 0,0 5,21H19A2,2 0 0,0 21,19V5A2,2 0 0,0 19,3M12,3A1,1 0 0,1 13,4A1,1 0 0,1 12,5A1,1 0 0,1 11,4A1,1 0 0,1 12,3M7,7H17V5H19V19H5V5H7V7Z" />
</graphic>
</Tab>
</tabs>
</TabPane>
<ProgressBar fx:id="progressBar" prefWidth="Infinity" progress="0.0"> <ProgressBar fx:id="progressBar" prefWidth="Infinity" progress="0.0">
<VBox.margin> <VBox.margin>
<Insets left="5.0" right="5.0" top="2.0" /> <Insets left="5.0" right="5.0" top="2.0" />

View file

@ -0,0 +1,14 @@
<?xml version="1.0" encoding="UTF-8"?>
<?import javafx.geometry.Insets?>
<?import javafx.scene.control.TableView?>
<?import javafx.scene.layout.HBox?>
<HBox xmlns="http://javafx.com/javafx/8.0.141" xmlns:fx="http://javafx.com/fxml/1" fx:controller="nsusbloader.Controllers.NSTableViewController">
<children>
<TableView fx:id="table" editable="true" HBox.hgrow="ALWAYS" />
</children>
<padding>
<Insets bottom="2.0" left="5.0" right="5.0" top="5.0" />
</padding>
</HBox>

View file

@ -120,6 +120,46 @@
// Text color of focused item in the list // Text color of focused item in the list
.choice-box .menu-item:focused > .label { -fx-text-fill: #2d2d2d; } .choice-box .menu-item:focused > .label { -fx-text-fill: #2d2d2d; }
.tab-pane .tab SVGPath{
-fx-fill: #66d053;
}
.tab-pane .tab{
-fx-background-color: #4f4f4f;
}
.tab-pane .tab:selected{
-fx-background-color: #2d2d2d;
}
.table-view {
-fx-background-color: #2d2d2d;
-fx-background-image: url(app_logo.png);
-fx-background-position: center;
-fx-background-repeat: no-repeat;
-fx-border-color: #00ffc9;
-fx-border-radius: 3;
-fx-border-width: 2;
}
.table-view .column-header {
-fx-background-color: transparent;
}
.table-view .column-header-background .label{
-fx-background-color: transparent;
-fx-text-fill: white;
}
.table-view .column-header-background, .table-view .filler{
-fx-background-color: #4f4f4f;
}
.table-row-cell:filled:selected {
-fx-background: -fx-control-inner-background ;
-fx-background-color: -fx-table-cell-border-color, -fx-background ;
-fx-background-insets: 0, 0 0 1 0 ;
-fx-table-cell-border-color: derive(-fx-color, 5%);
}
.table-row-cell:odd:filled:selected {
-fx-background: -fx-control-inner-background-alt ;
}
.regionUpload{ .regionUpload{
-fx-shape: "M8,21V19H16V21H8M8,17V15H16V17H8M8,13V11H16V13H8M19,9H5L12,2L19,9Z"; -fx-shape: "M8,21V19H16V21H8M8,17V15H16V17H8M8,13V11H16V13H8M19,9H5L12,2L19,9Z";
-fx-background-color: #a2e019; -fx-background-color: #a2e019;

View file

@ -121,6 +121,47 @@
// Text color of focused item in the list // Text color of focused item in the list
.choice-box .menu-item:focused > .label { -fx-text-fill: #2d2d2d; } .choice-box .menu-item:focused > .label { -fx-text-fill: #2d2d2d; }
.tab-pane .tab SVGPath{
-fx-fill: #2c2c2c;
}
.tab-pane .tab{
-fx-background-color: #fefefe;
}
.tab-pane .tab:selected{
-fx-background-color: #ebebeb;
}
.table-view {
-fx-background-color: #fefefe;
-fx-background-image: url(app_logo.png);
-fx-background-position: center;
-fx-background-repeat: no-repeat;
-fx-border-color: #00ffc9;
-fx-border-radius: 3;
-fx-border-width: 2;
}
.table-view .column-header {
-fx-background-color: transparent;
}
.table-view .column-header-background .label{
-fx-background-color: transparent;
-fx-text-fill: white;
}
.table-view .column-header-background, .table-view .filler{
-fx-background-color: #fefefe;
}
// Remove visible selection 1
.table-row-cell:filled:selected {
-fx-background: -fx-control-inner-background ;
-fx-background-color: -fx-table-cell-border-color, -fx-background ;
-fx-background-insets: 0, 0 0 1 0 ;
-fx-table-cell-border-color: derive(-fx-color, 5%);
}
// Remove visible selection 2
.table-row-cell:odd:filled:selected {
-fx-background: -fx-control-inner-background-alt ;
}
.regionUpload{ .regionUpload{
-fx-shape: "M8,21V19H16V21H8M8,17V15H16V17H8M8,13V11H16V13H8M19,9H5L12,2L19,9Z"; -fx-shape: "M8,21V19H16V21H8M8,17V15H16V17H8M8,13V11H16V13H8M19,9H5L12,2L19,9Z";
-fx-background-color: #a2e019; -fx-background-color: #a2e019;
@ -128,6 +169,7 @@
-fx-min-height: -size; -fx-min-height: -size;
-fx-min-width: 20; -fx-min-width: 20;
} }
.regionStop{ .regionStop{
-fx-shape: "M12,2C17.53,2 22,6.47 22,12C22,17.53 17.53,22 12,22C6.47,22 2,17.53 2,12C2,6.47 6.47,2 12,2M15.59,7L12,10.59L8.41,7L7,8.41L10.59,12L7,15.59L8.41,17L12,13.41L15.59,17L17,15.59L13.41,12L17,8.41L15.59,7Z"; -fx-shape: "M12,2C17.53,2 22,6.47 22,12C22,17.53 17.53,22 12,22C6.47,22 2,17.53 2,12C2,6.47 6.47,2 12,2M15.59,7L12,10.59L8.41,7L7,8.41L10.59,12L7,15.59L8.41,17L12,13.41L15.59,17L17,15.59L13.41,12L17,8.41L15.59,7Z";
-fx-background-color: #fb582c; -fx-background-color: #fb582c;

Binary file not shown.

After

Width:  |  Height:  |  Size: 13 KiB