This forum uses cookies
This forum makes use of cookies to store your login information if you are registered, and your last visit if you are not. Cookies are small text documents stored on your computer; the cookies set by this forum can only be used on this website and pose no security risk. Cookies on this forum also track the specific topics you have read and when you last read them. Please confirm that you accept these cookies being set.

Problems saving scripts
#1
Hi, I have been having a few problems saving the "Common functions" script and an event-based script recently. My problem is that every time I try to save, the LM webpage becomes unreachable (Ping still works), but only after a few minutes does it come back online. Could the scripts crash LM? If you need the actual backup, I can send it through private messages.

Firmware version: 20240426

Common function code:
Code:
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345
-- user function library -- send an e-mail function mail(to, subject, message)   -- make sure these settings are correct   local settings = {     -- "from" field, only e-mail must be specified here     from = 'example@gmail.com',     -- smtp username     user = 'example@gmail.com',     -- smtp password     password = 'mypassword',     -- smtp server     server = 'smtp.gmail.com',     -- smtp server port     port = 465,     -- enable tls, required for gmail smtp     secure = 'tlsv1_2',   }   local smtp = require('socket.smtp')   if type(to) ~= 'table' then     to = { to }   end   for index, email in ipairs(to) do     to[ index ] = '<' .. tostring(email) .. '>'   end   -- fixup from field   local from = '<' .. tostring(settings.from) .. '>'   -- message headers and body   settings.source = smtp.message({     headers = {       to = table.concat(to, ', '),       subject = subject,       ['From'] = from,       ['Content-type'] = 'text/html; charset=utf-8',     },     body = message   })   settings.from = from   settings.rcpt = to   return smtp.send(settings) end -- sunrise / sunset calculation function rscalc(latitude, longitude, when)   local pi = math.pi   local doublepi = pi * 2   local rads = pi / 180.0   local TZ = function(when)     local ts = os.time(when)     local utcdate, localdate = os.date('!*t', ts), os.date('*t', ts)     localdate.isdst = false     local diff = os.time(localdate) - os.time(utcdate)     return math.floor(diff / 60) / 60   end   local range = function(x)     local a = x / doublepi     local b = doublepi * (a - math.floor(a))     return b < 0 and (doublepi + b) or b   end   when = when or os.date('*t')   local y2k = { year = 2000, month = 1, day = 1 }   local y2kdays = math.floor((os.time(when) - os.time(y2k)) / 86400)   local meanlongitude = range(280.461 * rads + 0.9856474 * rads * y2kdays)   local meananomaly = range(357.528 * rads + 0.9856003 * rads * y2kdays)   local lambda = range(meanlongitude + 1.915 * rads * math.sin(meananomaly) + rads / 50 * math.sin(2 * meananomaly))   local obliq = 23.439 * rads - y2kdays * rads / 2500000   local alpha = math.atan2(math.cos(obliq) * math.sin(lambda), math.cos(lambda))   local declination = math.asin(math.sin(obliq) * math.sin(lambda))   local LL = meanlongitude - alpha   if meanlongitude < pi then     LL = LL + doublepi   end   local dfo = pi / 216.45   if latitude < 0 then     dfo = -dfo   end   local fo = math.tan(declination + dfo) * math.tan(latitude * rads)   -- polar day / night   if fo < -1 or fo > 1 then     return 1, 23 * 60 + 59   end   local ha = 12 * math.asin(fo) / pi + 6   local timezone = TZ(when)   local equation = 12 + timezone + 24 * (1 - LL / doublepi) - longitude / 15   local sunrise, sunset = equation - ha, equation + ha   if sunrise > 24 then     sunrise = sunrise - 24   end   if sunset > 24 then     sunset = sunset - 24   end   return math.floor(sunrise * 60), math.ceil(sunset * 60) end function get_st_add(ga)   new_ga = ""   gas = string.split(ga, "/")     gas[3] = tonumber(gas[3])+1     --log(gas)   for k,v in ipairs(gas) do     if k == 3 then       new_ga = new_ga..tostring(v)     else         new_ga = new_ga..v.."/"     end   end   return new_ga end --- BEFORE SUNRISE --- function before_sr(offset--- offset= min_offset   off= offset.hour * 60 + offset.min     sr,ss = rscalc(44.060, 11.844)   t = os.date("*t")   time = t.hour*60 + t.min   if sr - off > time then     return true   else     return false   end end --- AFTER SUNSET --- function after_ss(offset)   off= offset.hour * 60 + offset.min     sr,ss = rscalc(44.060, 11.844)   t = os.date("*t")   time = t.hour*60 + t.min   if ss + off < time then     return true   else     return false   end end function birthday(compleanno)     d = os.date("*t")     birth = grp.getvalue(compleanno)     if d.year < birth.year then       birth.year = birth.year - 100     end     if d.day == birth.day and d.month == birth.month then       return {true, d.year-birth.year}     else       return {false, d.year-birth.year}     end end       --- LED CHE GUIDANO VERSO LE POSTAZIONI --- function guide_me(n_led, colore, lampeggio, range, time_step, path, debug, ip)   if range == nil then range = 15 end   if time_step == nil then time_step = 0.5 end   if path == nil then path = "i" end   if debug == nil then debug = false end   if lampeggio == nil then lampeggio = true end   if ip == nil then ip = "10.11.24.115" end     step = math.ceil(n_led/range)        ----- RICHIESTA POST HTTP GENERICA -----     function basic_post_req(body_req)             res, err = http.request({       url = 'http://'..ip..'/json/state',       method = "POST",       body = body_req,       headers = {["Content-Type"] = "text/plain"}       })       return res,err     end   if path == "i" then       for i = 1, step, 1 do -- es. 13 step           --basic_post_req('{"on": true, "bri": 10}')           led_on = {start = range*(i-1), stop = range*i}           led_off = {start = 0, stop = range*(i-1)}           if debug == true then log(led_on, led_off, i) end           if i == step and lampeggio then               for k = 1, 3, 1 do                 basic_post_req('{"seg":[{"i":['..led_off.start..', '..led_off.stop..', "000000", '..led_on.start..', '..led_on.stop..', "'..colore..'"]}], "bri": 255, tt: 500}')                 os.sleep(1)                 basic_post_req('{"seg":[{"i":['..led_off.start..', '..led_off.stop..', "000000", '..led_on.start..', '..led_on.stop..', "'..colore..'"]}], "bri": 50, tt: 500}')                 os.sleep(1)             end         elseif i == 1 then           basic_post_req('{"seg":[{"i":['..led_off.start..', '..led_off.stop..', "000000", '..led_on.start..', '..led_on.stop..', "'..colore..'"]}], "on": true, bri: 150}')               os.sleep(time_step)           else               basic_post_req('{"seg":[{"i":['..led_off.start..', '..led_off.stop..', "000000", '..led_on.start..', '..led_on.stop..', "'..colore..'"]}], bri: 150}')               os.sleep(time_step)           end     end   else         for i = 1, step, 1 do -- es. 13 step           --basic_post_req('{"on": true, "bri": 10}')           led_on = {start = range*(i-1)+140, stop = range*i+140}           led_off = {start = range*(i-2)+140, stop = range*(i-1)+140}           if debug == true then log(led_on, led_off, i) end           if i == step and lampeggio then               for k = 1, 3, 1 do                 basic_post_req('{"seg":[{"i":['..led_off.start..', '..led_off.stop..', "000000", '..led_on.start..', '..led_on.stop..', "'..colore..'"]}], "bri": 255, tt: 500}')                 os.sleep(1)                 basic_post_req('{"seg":[{"i":['..led_off.start..', '..led_off.stop..', "000000", '..led_on.start..', '..led_on.stop..', "'..colore..'"]}], "bri": 50, tt: 500}')                 os.sleep(1)             end         elseif i == 1 then         led_on = {start = range*(i-1)+140, stop = range*i+140}               led_off = {start = 0, stop = range*(i-1)+140}           basic_post_req('{"seg":[{"i":['..led_off.start..', '..led_off.stop..', "000000", '..led_on.start..', '..led_on.stop..', "'..colore..'"]}], "on": true, bri: 150}')               os.sleep(time_step)           else               basic_post_req('{"seg":[{"i":['..led_off.start..', '..led_off.stop..', "000000", '..led_on.start..', '..led_on.stop..', "'..colore..'"]}], bri: 150}')               os.sleep(time_step)           end     end   end   basic_post_req('{"on": false}') end function broadcast_c4()   pl_select = grp.tag("PLAYER_SELECT_AUDIO")     mute = grp.tag("PLAYER_MUTE_AUDIO")     vol = grp.tag("VOLUME_AUDIO")     if not grp.getvalue("5/1/104") then     for i, o in ipairs(pl_select) do       --grp.write(o.address, 6)       grp.write(mute[i].address, false)       grp.write(vol[i].address, 40)     end   else     for i, o in ipairs(pl_select) do         if not i == 8 then           --grp.write(o.address, 6)           grp.write(mute[i].address, false)           --grp.write(vol[i].address, 40)       end     end   end   end function no_martini_no_party_bd(colore, value)     player_select = {"7/2/6", "7/2/26", "7/2/46", "7/2/66", "7/2/86", "7/2/106", "7/2/126", "7/2/146", "7/2/166"}          --colore = 0xff0000     tempo_canzone35          if value then       grp.write('1/2/1', false)       grp.write('0/1/1', true)       --os.sleep(1)       --broadcast_c4()     grp.write("7/0/2", 31)       grp.write('1/3/250', true)       grp.write('1/3/251', 100)       grp.write('1/3/254', 90)       grp.write('1/3/253', 0)       grp.write('1/3/252', colore)             os.sleep(tempo_canzone)             grp.write('1/3/250', false)       if grp.getvalue('4/4/22') then         --grp.write("1/2/16", true)         grp.write("1/2/31", true)       else             grp.write("0/1/1", false)       end     end end function hex_c(val)      hexcolor = string.format("%X",tostring(val))     while hexcolor:len() < 6 do         hexcolor = "0"..hexcolor     end     return hexcolor end function blink(light, time, range, bool)   if bool == nil then       step = math.floor(time/range)       for i=1,step, 1 do         grp.write(light, true)         os.sleep(range)         grp.write(light, false)         os.sleep(range)       end   else     while bool do       grp.write(light, true)         os.sleep(range)         grp.write(light, false)         os.sleep(range)       end   end end function last_d_month(month, year)   bis = tonumber(year)%4     if bis == 0 then     d_m = {31,29,31,30,31,30,31,31,30,31,30,31}     return d_m[tonumber(month)]   else     d_m = {31,28,31,30,31,30,31,31,30,31,30,31}     return d_m[tonumber(month)]   end end
Reply
#2
Send backup to PM, what is the memory level?
------------------------------
Ctrl+F5
Reply
#3
(20.05.2025, 15:25)Daniel Wrote: Send backup to PM, what is the memory level?

I sent you a link to the backup, memory level is at 31%
Reply
#4
Disk is 100%, no more space.
------------------------------
Ctrl+F5
Reply
#5
(20.05.2025, 15:43)Daniel Wrote: Disk is 100%, no more space


Uhh  Huh   where can I see this? 


Is it not the one shown in the picture I attached?

Attached Files Thumbnail(s)
   
Reply
#6
The next tab, partition, or on the main screen of LogicMachine on the bottom right.
------------------------------
Ctrl+F5
Reply
#7
(20.05.2025, 16:36)Daniel Wrote: The next tab, partition, or on the main screen of LogicMachine on the bottom right.
This one?

Attached Files Thumbnail(s)
   
Reply
#8
Do you have anything that can be sending requests to LM from the same PC? It's possible that access is blocked for 1 minute due to incorrect credentials.

Try a different PC and see if you can replicate this issue there.
Reply
#9
(20.05.2025, 17:15)Andrea Becagli Wrote:
(20.05.2025, 16:36)Daniel Wrote: The next tab, partition, or on the main screen of LogicMachine on the bottom right.
This one?

OK you have different hardware without Disk(SPI) this is only shown on my test LM.  Try different PC as Admin suggested, it works for me.
------------------------------
Ctrl+F5
Reply


Forum Jump: