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.

35 lines
785 B

2 years ago
2 years ago
2 years ago
  1. -- This file takes as input a script and a label
  2. -- it will ask the local eeprom machine to flash it to an eeprom
  3. local computer = computer or require("computer")
  4. local net = net or require("net")
  5. local WEB_PORT = 30
  6. local function webflash(bytes, label)
  7. if label == nil then
  8. net.broadcast(WEB_PORT, "/flash", bytes)
  9. else
  10. net.broadcast(WEB_PORT, "/flash", bytes, label)
  11. end
  12. local pkt, err = net.recv{WEB_PORT}
  13. return pkt.data[1], tostring(pkt.data[2])
  14. end
  15. local args = {...}
  16. print("Reading " .. args[1])
  17. local file = assert(io.open(args[1], "rb"))
  18. local bios = file:read("*a")
  19. file:close()
  20. print("Sending " .. tostring(#bios) .. " bytes")
  21. resp, msg = webflash(bios, args[2])
  22. print("Reponse:")
  23. print(resp, msg)
  24. computer.beep(1000)