<content url="file://$MODULE_DIR$">
<sourceFolder url="file://$MODULE_DIR$/src/main/java" isTestSource="false" />
<sourceFolder url="file://$MODULE_DIR$/src/test/java" isTestSource="true" />
+ <sourceFolder url="file://$MODULE_DIR$/src/main/resources" type="java-resource" />
<excludeFolder url="file://$MODULE_DIR$/target" />
</content>
<orderEntry type="inheritedJdk" />
private void detached(HidDevice hidDevice) {
UsbDevice attachedDevice = hidDevices.get(hidDevice);
if (attachedDevice != null) {
- hidDevices.remove(attachedDevice);
+ // UI only supports one device for now
+ hidDevices.clear();
LOGGER.info("Detached SCSI2SD");
new StorageDevice(
this.storageDeviceList.size(),
devTypeEnum,
- capacity * 512L,
+ capacity,
devTypeEnum == StorageDeviceType.NOR_FLASH
)
);
writeCmd[4] = HidPacketProtocol.intToUint8(sector >> 8); // Sector number
writeCmd[5] = HidPacketProtocol.intToUint8(sector); // Sector number
- var buf = new byte[512];
is.readNBytes(writeCmd, 6, 512);
protocolDevice.sendHIDPacket(writeCmd, 1);
configs.add(disk);
}
- var sdCapacity = device.getSdCapacity();
+ var sdCapacity = device.getStorageDevices().get(0).get_capacity();
var fallbackSize = Math.max(2l*1024*1024*1024/512, lastSectorUsed + DiskList.reservedSize);
var diskList = new DiskList(sdCapacity > 0 ? sdCapacity : fallbackSize);
configs.forEach(c -> diskList.add(c));
root.setBoardConfig(boardConfig);
int maxDisks = 7;
- var sdCapacity = 0;
+ long sdCapacity = 0;
List<UsbDevice> deviceList = this.usbDeviceManager.getDevices();
if (!deviceList.isEmpty())
{
maxDisks = deviceList.get(0).getMaxDisks();
- sdCapacity = deviceList.get(0).getSdCapacity();
+ sdCapacity = deviceList.get(0).getStorageDevices().get(0).get_capacity();
}
var lastSectorUsed = 0l;
private void writeImageToDevice()
{
+ List<UsbDevice> deviceList = this.usbDeviceManager.getDevices();
+ if (deviceList.isEmpty()) {
+ return;
+ }
+
FileChooser fileChooser = new FileChooser();
fileChooser.setTitle("Open disk image");
}
try {
- this.getDevice().writeImage(theFile, 0);
+ // TODO allow selection of device.
+ this.getDevice().writeImage(
+ deviceList.get(0).getStorageDevices().size() - 1,
+ theFile,
+ 0);
} catch (Exception e) {
Alert alert = new Alert(Alert.AlertType.ERROR);
@FXML private Label hwVersion;
@FXML private Label fwVersion;
@FXML private Label sdCapacity;
+ @FXML private Label flashCapacity;
public StatusTabController(ScreensConfiguration screens, UsbDeviceManager usbDeviceManager) {
this.screens = screens;
hwVersion.setText(device.getHardwareDescription());
fwVersion.setText(device.getFirmwareDescription());
+ showCapacity(device, StorageDeviceType.SD, sdCapacity);
+ showCapacity(device, StorageDeviceType.NOR_FLASH, flashCapacity);
+ }
+
+ private void showCapacity(UsbDevice device, StorageDeviceType storageDeviceType, Label label) {
StringBuilder sdSizeStr = new StringBuilder();
- long sectors = device.getSdCapacity();
- float gbSize = sectors * 512.0f / 1024 / 1024 / 1024;
- sdSizeStr.append(String.format("%.1f", gbSize)).append("GiB")
- .append(" (").append(sectors).append(" sectors)");
- if (sectors < (2 * 1024 * 1024 *1024 / 512)) {
+ var storageDevices = device.getStorageDevices();
+ long sectors = storageDevices.stream()
+ .filter(sd -> sd.get_storageDeviceType() == storageDeviceType)
+ .map(sd -> sd.get_capacity())
+ .reduce(0l, Long::sum);
+
+ if (sectors >= 2097152) {
+ float gbSize = sectors * 512.0f / 1024 / 1024 / 1024;
+ sdSizeStr.append(String.format("%.1f", gbSize)).append("GiB");
+ } else {
+ float mbSize = sectors * 512.0f / 1024 / 1024;
+ sdSizeStr.append(String.format("%.1f", mbSize)).append("MiB");
+ }
+
+ sdSizeStr.append(" (").append(sectors).append(" sectors)");
+ if (storageDeviceType == StorageDeviceType.SD &&
+ sectors < (2 * 1024 * 1024 *1024 / 512)) {
sdSizeStr.append(" ! Obsolete Card");
}
- sdCapacity.setText(sdSizeStr.toString());
+ label.setText(sdSizeStr.toString());
}
public void handleUsbDisconnected(UsbDeviceDisconnectedEvent usbDeviceDisconnectedEvent) {
<RowConstraints minHeight="10.0" prefHeight="30.0" vgrow="SOMETIMES" />
<RowConstraints minHeight="10.0" prefHeight="30.0" vgrow="SOMETIMES" />
<RowConstraints minHeight="10.0" prefHeight="30.0" vgrow="SOMETIMES" />
+ <RowConstraints minHeight="10.0" prefHeight="30.0" vgrow="SOMETIMES" />
</rowConstraints>
<children>
<Label text="Status" />
<Label alignment="TOP_LEFT" text="Hardware Version" GridPane.rowIndex="1" />
<Label text="Firmware Version" GridPane.rowIndex="2" />
<Label text="SD Capacity" GridPane.rowIndex="3" />
+ <Label text="NOR Flash Capacity" GridPane.rowIndex="4" />
<Label text="-" fx:id="status" GridPane.columnIndex="1" />
<Label text="-" fx:id="hwVersion" GridPane.columnIndex="1" GridPane.rowIndex="1" />
<Label text="-" fx:id="sdCapacity" GridPane.columnIndex="1" GridPane.rowIndex="3" />
+ <Label text="-" fx:id="flashCapacity" GridPane.columnIndex="1" GridPane.rowIndex="4" />
+
</children>
</GridPane>
</children>