fixed require issues caused by using bootloader

This commit is contained in:
Mikayla Fischler 2022-05-14 13:32:42 -04:00
parent 6b74db70bd
commit d3a926b25a
7 changed files with 31 additions and 5 deletions

View File

@ -2,6 +2,8 @@
-- Nuclear Generation Facility SCADA Coordinator -- Nuclear Generation Facility SCADA Coordinator
-- --
require("/initenv").init_env()
local log = require("scada-common.log") local log = require("scada-common.log")
local ppm = require("scada-common.ppm") local ppm = require("scada-common.ppm")
local util = require("scada-common.util") local util = require("scada-common.util")

18
initenv.lua Normal file
View File

@ -0,0 +1,18 @@
--
-- Initialize the Boot Environment
--
-- initialize booted environment
local init_env = function ()
local _require = require("cc.require")
local _env = setmetatable({}, { __index = _ENV })
-- overwrite require/package globals
require, package = _require.make(_env, "/")
-- reset terminal
term.clear()
term.setCursorPos(1, 1)
end
return { init_env = init_env }

View File

@ -1,3 +1,5 @@
-- --
-- SCADA Coordinator Access on a Pocket Computer -- SCADA Coordinator Access on a Pocket Computer
-- --
require("/initenv").init_env()

View File

@ -2,6 +2,8 @@
-- Reactor Programmable Logic Controller -- Reactor Programmable Logic Controller
-- --
require("/initenv").init_env()
local log = require("scada-common.log") local log = require("scada-common.log")
local mqueue = require("scada-common.mqueue") local mqueue = require("scada-common.mqueue")
local ppm = require("scada-common.ppm") local ppm = require("scada-common.ppm")

View File

@ -2,6 +2,8 @@
-- RTU: Remote Terminal Unit -- RTU: Remote Terminal Unit
-- --
require("/initenv").init_env()
local log = require("scada-common.log") local log = require("scada-common.log")
local mqueue = require("scada-common.mqueue") local mqueue = require("scada-common.mqueue")
local ppm = require("scada-common.ppm") local ppm = require("scada-common.ppm")

View File

@ -1,6 +1,6 @@
local util = require("scada-common.util") local util = require("scada-common.util")
local BOOTLOADER_VERSION = "0.1" local BOOTLOADER_VERSION = "0.2"
local println = util.println local println = util.println
local println_ts = util.println_ts local println_ts = util.println_ts
@ -43,9 +43,7 @@ else
return false return false
end end
if exit_code then if not exit_code then
println_ts("BOOT> APPLICATION EXITED OK")
else
println_ts("BOOT> APPLICATION CRASHED") println_ts("BOOT> APPLICATION CRASHED")
end end

View File

@ -2,6 +2,8 @@
-- Nuclear Generation Facility SCADA Supervisor -- Nuclear Generation Facility SCADA Supervisor
-- --
require("/initenv").init_env()
local log = require("scada-common.log") local log = require("scada-common.log")
local ppm = require("scada-common.ppm") local ppm = require("scada-common.ppm")
local util = require("scada-common.util") local util = require("scada-common.util")