This commit is contained in:
Adrian Siekierka 2025-06-01 19:46:48 +02:00
parent 49b128ec69
commit 5d35d7f9e1
3 changed files with 25 additions and 6 deletions

View File

@ -1,5 +1,6 @@
## Fixes/improvements ## Fixes/improvements
* [#3682] Add error handling to the `flash` OpenOS program
* [#3764] Fix left and right names being swapped in the Rack GUI * [#3764] Fix left and right names being swapped in the Rack GUI
* [#3779] Fix `os.sleep(0)` causing `too long without yielding` (Ocawesome101) * [#3779] Fix `os.sleep(0)` causing `too long without yielding` (Ocawesome101)
* (1.12) [#3774] Fix Jukebox driver (kebufu) * (1.12) [#3774] Fix Jukebox driver (kebufu)

View File

@ -15,6 +15,8 @@ end
local function printRom() local function printRom()
local eeprom = component.eeprom local eeprom = component.eeprom
io.write(eeprom.get()) io.write(eeprom.get())
return nil
end end
local function readRom() local function readRom()
@ -37,6 +39,8 @@ local function readRom()
if not options.q then if not options.q then
io.write("All done!\nThe label is '" .. eeprom.getLabel() .. "'.\n") io.write("All done!\nThe label is '" .. eeprom.getLabel() .. "'.\n")
end end
return nil
end end
local function writeRom() local function writeRom()
@ -60,7 +64,10 @@ local function writeRom()
io.write("Please do NOT power down or restart your computer during this operation!\n") io.write("Please do NOT power down or restart your computer during this operation!\n")
end end
eeprom.set(bios) local result, reason = eeprom.set(bios)
if reason then
return nil, reason
end
local label = args[2] local label = args[2]
if not options.q and not label then if not options.q and not label then
@ -68,7 +75,11 @@ local function writeRom()
label = io.read() label = io.read()
end end
if label and #label > 0 then if label and #label > 0 then
eeprom.setLabel(label) local result, reason = eeprom.setLabel(label)
if reason then
return nil, reason
end
if not options.q then if not options.q then
io.write("Set label to '" .. eeprom.getLabel() .. "'.\n") io.write("Set label to '" .. eeprom.getLabel() .. "'.\n")
end end
@ -77,12 +88,19 @@ local function writeRom()
if not options.q then if not options.q then
io.write("All done! You can remove the EEPROM and re-insert the previous one now.\n") io.write("All done! You can remove the EEPROM and re-insert the previous one now.\n")
end end
return nil
end end
local result, reason
if options.l then if options.l then
printRom() result, reason = printRom()
elseif options.r then elseif options.r then
readRom() result, reason = readRom()
else else
writeRom() result, reason = writeRom()
end end
if reason then
io.stderr:write(reason..'\n')
return 1
end

View File

@ -76,7 +76,7 @@ class EEPROM extends prefab.ManagedEnvironment with DeviceInfo {
return result(Unit, "storage is readonly") return result(Unit, "storage is readonly")
} }
label = args.optString(0, "EEPROM").trim.take(24) label = args.optString(0, "EEPROM").trim.take(24)
if (label.length == 0) label = "EEPROM" if (label.isEmpty) label = "EEPROM"
result(label) result(label)
} }