Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- -- EEPROM Bootloader for Kino Drone (Minimalist)
- local drone = component.list("drone")()
- local chunkloader = component.list("chunkloader")()
- drone = drone and component.proxy(drone)
- chunkloader = chunkloader and component.proxy(chunkloader)
- drone.setStatusText("Waiting")
- drone.setLightColor(16711680)
- if not chunkloader then
- drone.setStatusText("ER-ChkL")
- computer.shutdown()
- elseif chunkloader then
- chunkloader.setActive(true)
- end
- local function boot()
- local e = {} -- Event buffer
- local modem = component.list("modem")()
- if not modem then return end -- No modem found, exit
- modem = modem and component.proxy(modem)
- modem.open(123) -- Open the wireless communication port
- modem.setWakeMessage("kino_wake")
- modem.broadcast(123, "wake_ack")
- while true do
- local _, _, sender, _, _, message = computer.pullSignal()
- if message == "upload" then
- local program = ""
- while true do
- local _, _, _, _, _, chunk = computer.pullSignal()
- if chunk == "end" then break end -- End of transmission
- program = program .. chunk
- end
- local func, err = load(program)
- if func then
- func() -- Run the Kino script
- else
- modem.send(sender, 123, "kino_update_error: " .. err)
- end
- elseif message == "kino_wake" then
- modem.send(sender, 123, "wake_ack")
- end
- end
- end
- boot()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement