OpenComputers Von Neumann Machine Programs
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

36 lines
785 B

-- This file takes as input a script and a label
-- it will ask the local eeprom machine to flash it to an eeprom
local computer = computer or require("computer")
local net = net or require("net")
local WEB_PORT = 30
local function webflash(bytes, label)
if label == nil then
net.broadcast(WEB_PORT, "/flash", bytes)
else
net.broadcast(WEB_PORT, "/flash", bytes, label)
end
local pkt, err = net.recv{WEB_PORT}
return pkt.data[1], tostring(pkt.data[2])
end
local args = {...}
print("Reading " .. args[1])
local file = assert(io.open(args[1], "rb"))
local bios = file:read("*a")
file:close()
print("Sending " .. tostring(#bios) .. " bytes")
resp, msg = webflash(bios, args[2])
print("Reponse:")
print(resp, msg)
computer.beep(1000)