liminix

Unnamed repository; edit this file 'description' to name the repository.
Log | Files | Refs | README | LICENSE

boot.lua (870B)


      1 
      2 function send_command(s, timeout)
      3 --   print("sending " .. string.gsub(s, "([^%g])", function(s) return string.format("{%02x}", string.byte(s)) end) .. "\r\n")
      4    local s =  s .. "\r"
      5    while write(s) < #s do
      6       print("partioal write")
      7       s = string.sub(#s + 1)
      8    end
      9    
     10    local l, matched
     11    local total=0
     12    local count = 0
     13    
     14    repeat 
     15       l, matched = read(1,1000)
     16       if matched and matched:match("BusyBox") then
     17          return false
     18       end
     19       total = total + l
     20       if l == 0  then
     21          -- print(string.format("reached idle after %d bytes for for %10q\r\n", total, s))
     22          return true
     23       end
     24    until false
     25    
     26    return true
     27 end
     28 
     29 function send_script(f)
     30   for line in f:lines() do
     31     if not send_command(line) then return end
     32   end
     33 end
     34 
     35 send_command("version")
     36 local f = io.open("result/boot.scr")
     37 send_script(f)
     38 f:close()
     39 
     40