I want to record the values of each properties at a defined rate and store it to a file, so that I can plot them vs. time later.
In main.p, I used set_timer_interval(1000); so that SENSOR_TIMER will trigger every 1 second. Then in sensors.p, I have a case SENSOR_TIMER:. IT is here that I want to report the property values.
I want to write csv output to a text file that I can read later.
for instance, I want my output file to look like this:
time,property1_value,property2_value,...
0,100,30,
1,100,29
2,100,28
3,50,27
Where I need HELP:
I don't understand how to create a formatted string to output to a text file. I want something like this printf statement, but i want it to go to a file. printf("%d,%d,%d",time,value1,value2) and that doesn't seem possible.
If this doesn't work, I fallback is to use Log.inc functionality.
I have the following code in my main:init()
device_change(device_sd);
new file_name[]="samplefile.txt";
file_delete(file_name);
log_set_file(file_name);
log_enable(MSG_ALL);
Message(MSG_SCRIPT, "script_message");
Info("info_message");
Message(MSG_SENSOR, "sensor_message");
Can someone tell me why my samplefile.txt is blank after I run this? I can write to the file with file_puts. Thanks!