Advertisement
samuelask

Bootloader

Mar 8th, 2025 (edited)
130
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 1.08 KB | None | 0 0
  1. -- EEPROM Bootloader for Kino Drone (Minimalist)
  2. local drone = component.list("drone")()
  3. drone = drone and component.proxy(drone)
  4. local function boot()
  5.     local e = {} -- Event buffer
  6.     local m = component.list("modem")()
  7.     if not m then return end -- No modem found, exit
  8.    
  9.     local modem = component.proxy(m)
  10.     modem.open(123)  -- Open the wireless communication port
  11.     drone.setStatusText("Waiting for Software Update")
  12.     while true do
  13.         local _, _, sender, _, _, message = computer.pullSignal()
  14.         if message == "upload" then
  15.             local program = ""
  16.             while true do
  17.                 local _, _, _, _, _, chunk = computer.pullSignal()
  18.                 if chunk == "end" then break end -- End of transmission
  19.                 program = program .. chunk
  20.             end
  21.            
  22.             local func, err = load(program)
  23.             if func then
  24.                 func() -- Run the Kino script
  25.             else
  26.                 modem.broadcast(123, "kino_update_error: " .. err)
  27.             end
  28.         end
  29.     end
  30. end
  31.  
  32. boot()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement