Hi all,
Occassionally, my RA resets and I have been tryign to track how often it happens and when. I'd like to add something in the setup to timestamp everytime it happens. I think I can use a counter varible to show how many times it has reset ina memory location, but I'd also like to make a timestamp and put it in memory as well. Is there a way to record now() or millis() and deconvulute it to date/time? Or should I store each piece in a different memory location (day, month, year, hour, minute, second)? Seems like there must be a common way to do this.
Thanks,
Jon
Timestamp
-
- Posts: 37
- Joined: Thu May 22, 2014 3:25 am
Re: Timestamp
I have been looking for something like this also, to track when the last time certain ports were on.
- jsclownfish
- Posts: 378
- Joined: Mon Oct 24, 2011 7:52 pm
- Location: Saint Louis
Re: Timestamp
I think it can be done by saving all the pieces in seperate memory locations like this.....
But I was hoping there was an easier way.
-Jon
Code: Select all
void Timestamp() //function to play sound and delay before it plays again.
{
time_t t=now();
InternalMemory.write(110, day(t));
InternalMemory.write(111, month(t));
InternalMemory.write(112, year(t));
InternalMemory.write(113, hour(t));
InternalMemory.write(114, minute(t));
InternalMemory.write(115, second(t));
//counter
resets=InternalMemory.read(116); //last number
resets++; //add one
InternalMemory.write(116,resets); //store new number
//elapsed time
InternalMemory.write(117,((now())-(InternalMemory.read(117)))); //elapsed time since a change(not sure if this would work)
}
But I was hoping there was an easier way.
-Jon
Re: Timestamp
now() is a unsigned long variable.
I never used it, but you can use like this:
And read like this:
I never used it, but you can use like this:
Code: Select all
InternalMemory.write_dword(110,now());
Code: Select all
InternalMemory.read_dword(110);
Roberto.