Coder Social home page Coder Social logo

Comments (3)

Jeija avatar Jeija commented on July 18, 2024

That behaviour is perfectly fine. What is happening is that the GET message goes across the digiline and the RTC answers. The luacontroller receives that anwer. Every time the luacontroller receives an answer the code is executed again. In your case, that makes the luacontroller send the GET signal again. Do you see where this leads? It creates an endless loop of the RTC responding and the luacontroller asking again.

Instead, you could use this code (tested with an RTC on channel "rtc"):

if (event.type ~= "digiline") then
  digiline_send("rtc", "GET")
else
  print("Time from RTC: " .. event.msg)
end

from digilines.

raptikCZ avatar raptikCZ commented on July 18, 2024

ok, thats i need - endless loop and it is normal in normal life like in PLC :) but i didnt expect burning of luacontroler here :) in normal world, you cant burn your cpu by this because you are limited by bus speed, cpu clock etc and communication libraries are mostly adjusted for this...

i trying to automate lighting of house in my minetest (before i have it with standart solar panel)

then it is not problem of digilines,but code is runing too fast when i just send get and read answer.
i tried it to send get, check digilines and set port of luacontr. - but it burned too and i didnt find any wait or delay function in lua lang. (but must admit that i forgot to make same with for)

but your code worked and after this i have periodic run:
(your code runs only once)

interrupt(1,"svetlo")
if (event.type ~= "digiline" ) then
digiline_send("sensor", "GET")
else
digiline_send("scrn1" , "light " .. event.msg .. " level")
end

thanks for help, and i must little learn about luacontroler :)

from digilines.

ssieb avatar ssieb commented on July 18, 2024

You don't want that either. The interrupt line will be executed on every trigger, so they will pile up. You only want one interrupt delay at a time. Look at the different event.type options.

from digilines.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.