Improve logging, bumb version

This commit is contained in:
Andrew-71 2024-03-16 15:36:42 +03:00
parent 0fc3255934
commit 1bcf459db6

View file

@ -7,12 +7,13 @@ It was made out of project "GLONASS Tower" I wrote back in 2022 after first disc
TODO: Bring back cool logging! TODO: Bring back cool logging!
]] ]]
local UNS_VERSION = 0 local UNS_VERSION = 1
-- Simple logging. It's not ideal but will do as a "temporary" solution -- Simple logging. It's not ideal but will do as a "temporary" solution
local function log(message) local function log(message)
term.write(message) local time_str = os.date('%H:%M ')
term.write(time_str .. message)
term.setCursorPos(1, select(2, term.getCursorPos()) + 1) term.setCursorPos(1, select(2, term.getCursorPos()) + 1)
if select(2, term.getCursorPos()) >= select(2, term.getSize()) then if select(2, term.getCursorPos()) >= select(2, term.getSize()) then
term.scroll(1) term.scroll(1)
@ -46,10 +47,10 @@ else
log("error: modems.info file missing") log("error: modems.info file missing")
-- TODO: Automatic setup -- TODO: Automatic setup
print("Attempt automatic setup? (Y/n) : ") print("attempt automatic setup? (Y/n) : ")
local ans = read() local ans = read()
if ans:lower() == "y" or ans == "" then if ans:lower() == "y" or ans == "" then
log("Not implemented yet, sorry!") log("not implemented yet, sorry!")
else else
log("nothing to do") log("nothing to do")
os.exit() os.exit()
@ -78,7 +79,7 @@ while true do
event, side, channel, replyChannel, message, distance = os.pullEvent("modem_message") event, side, channel, replyChannel, message, distance = os.pullEvent("modem_message")
until channel == gps.CHANNEL_GPS and message == "PING" until channel == gps.CHANNEL_GPS and message == "PING"
log("recieved location request, d-" .. distance) log("recieved location request, d-" .. string.format("%.3f", distance))
for _, modem in ipairs(modems) do for _, modem in ipairs(modems) do
modem.modem.transmit(channel, replyChannel, modem.pos) modem.modem.transmit(channel, replyChannel, modem.pos)
log("modem <" .. modem.id .. "> transmitted location") log("modem <" .. modem.id .. "> transmitted location")