简体   繁体   中英

Node js tasks, collecting data, serving web and sending data from beaglebone

I am starting a project and searching for the technology to use, I would like to use node js and javascript for the whole project but my app needs to collect data from sensors at specific time intervals, let's say 10ms, send collected data to a web service and serve a web page for configuration. My question is if i can, with node js, be confident that the time interval is going to be fulfilled and how can i acomplished this. Thanks in advance.

Node will do just fine for this. As node is a JavaScript runtime, you have access to all of the JavaScript language. Doing something at a 10ms interval is trivial:

setInterval(function () {
  // do your check for updates
}, 10); 

Usage of setInterval is not a good idea, because it does not wait for end of handler execution and can start another one immediately after previous. It means that you will not have guarantee of interval, setInterval just put your handler into event loop using specified interval, but your handler may work more time that interval for some reason and event loop queue just could be overflowed.

I think it is better to use schedulers with setTimeout like this one

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM