c++ - Scheduling file operations in embedded Linux -


i'm sniffing wifi packets rssi (my interest probe request , data null, timestamp , source mac address), , need save results in pcap files further processing.

the problem need divide info multiple different files, creating 1 file per hour.
don't have idea how check elapsed time in program, except multithreading (while(1), sleep() , check clock() function). i'm using ubuntu, target platform router linux openwrt installed.

my first concert problems cross compilation + pthread.h, thread.h or else, or maybe there should no issues in openwrt?

and other side of question - isn't complicated use multithreading silly problem?
maybe there other solutions? (i.e. small pseudo-multithreading solution, or simpler tricks)?

you should use cron:

cron system daemon used execute desired tasks (in background) @ designated times.

basically, define script executed every hour syntax:

0 */1 * * * /path/to/script.sh 

check here more info: https://help.ubuntu.com/community/cronhowto

for openwrt specific setup, check here: http://martybugs.net/wireless/openwrt/cron.cgi

for specific case, can use following design:

  • cron jobs triggers every full hour
  • the custom script gets executed , uses ipc mechanism inform main app.
  • the main app has dedicated function in writter handler necessary reset writter (other function calls, file deletion, creating new file, etc.)

enter image description here

for overview of ipc methods started, check this wikipedia article.

for specific implementations can use boost.interprocess, sockets, pipes, , others.


Comments

Popular posts from this blog

java - WrongTypeOfReturnValue exception thrown when unit testing using mockito -

php - Magento - Deleted Base url key -

android - How to disable Button if EditText is empty ? -