简体   繁体   English

如何有效运行后台数据处理和日志记录(Debian,Beaglebone Black)

[英]How to effectively run a background Processing and Logging of Data (Debian, Beaglebone Black)

I'm looking for some help with an implementation problem I'm facing. 我正在寻找有关我所面临的实现问题的帮助。 I'm an experienced C/C++ programmer in embedded environments and RTOSs, but when it comes to linux I'm a newbie. 我是嵌入式环境和RTOS方面经验丰富的C / C ++程序员,但是在linux方面,我是新手。

I have a beaglebone black running Debian. 我有一个运行Debian的beaglebone黑色。 I need to log and process data from sensors connected to the I2C bus and the ADC. 我需要记录和处理来自连接到I2C总线和ADC的传感器的数据。 I have written the handler functions for collecting the data from the sensors connected, no problem there, they work fine. 我已经编写了处理程序函数,用于从连接的传感器收集数据,在那里没问题,它们工作正常。 I want to implement (similar to a RTOS) a timer interrupt that can throw the process to my handler functions so they can do their things and I want this to run in the background. 我想实现(类似于RTOS)计时器中断,该计时器中断可以将进程扔给我的处理程序函数,以便它们可以执行其操作,并且我希望此操作在后台运行。 ie I don't want to tie up the shell or whatever so the user can do other things. 即我不想捆绑外壳或其他任何东西,以便用户可以做其他事情。 I was reading that timer_create is a way do this within Debian, or using fork()-exec() but I thought I'd ask people experienced in Linux first before going down any particular path! 我读到的是timer_create是在Debian中或使用fork()-exec()进行此操作的一种方法,但我想我应该先问一下Linux方面的经验的人,然后再采取任何特殊的方式! Also, not 100% sure how to use either of these functions. 同样,不是100%确定如何使用这两个功能。

side-note: I know that timers etc. are not highly accurate in Linux unless you are implementing pre-emptive kernels or whatever, which is a whole other problem in itself, but the time constraints of this problem are somewhere near 10-50ms which is not extremely tight. 旁注:我知道除非在实现抢占式内核之类的东西,否则计时器等在Linux中不是很准确,这本身就是一个另外的问题,但是此问题的时间限制在10-50ms左右,不是很紧

Thanks 谢谢

to make a daemon process , just take this as a reference: 进行守护进程,只需将此作为参考:

https://github.com/memcached/memcached/blob/master/daemon.c https://github.com/memcached/memcached/blob/master/daemon.c

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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