Browse Source

split webflash into library and client

master
Chris Mahoney 2 years ago
parent
commit
3fe4e45468
  1. 18
      lib/webflash.lua
  2. 16
      webflash-client.lua
  3. 28
      webflash.lua

18
lib/webflash.lua

@ -0,0 +1,18 @@
local computer = computer or require("computer")
local net = net or require("net")
local function webflash(bytes, label)
print("Broadcasting bios")
if label == nil then
net.broadcast(10, "eeprom-flash", bytes)
else
net.broadcast(10, "eeprom-flash", bytes, label)
end
computer.beep(200)
print("Waiting for response...")
local pkt, err = net.recv{10}
print("Status: " .. tostring(pkt.data[1]) .. " Message: " .. tostring(pkt.data[2]))
computer.beep(1000)
end

16
webflash-client.lua

@ -0,0 +1,16 @@
-- This file takes as input a script and a label
-- it will ask the local eeprom machine to flash it to an eeprom
require("webflash")
local args = {...}
print("Reading " .. args[1])
local file = assert(io.open(args[1], "rb"))
local bios = file:read("*a")
file:close()
computer.beep(100)
webflash(bios, args[2])

28
webflash.lua

@ -1,28 +0,0 @@
-- This file takes as input a script and a label
-- it will ask the eeprom machine to flash it to an eeprom
local computer = require("computer")
local net = require("net")
local args = {...}
print("Reading " .. args[1])
f = io.open(args[1])
local bytes = f:read()
f:close()
computer.beep(100)
print("Broadcasting bios")
if args[2] == nil then
net.broadcast(10, "eeprom-flash", bytes)
else
net.broadcast(10, "eeprom-flash", bytes, args[2])
end
computer.beep(200)
print("Waiting for response...")
local pkt, err = net.recv{10}
print("Status: " .. tostring(pkt.data[1]) .. " Slot: " .. tostring(pkt.data[2]))
computer.beep(1000)
Loading…
Cancel
Save