01-23-07 06:23 PM
I am working on a project where my *nix box will talk to a PLC. (A PLC
is sort of a brain-damaged computer...)
The PLC in question returns the date in the following 6 byte sequence:
0 year (0-99) current year (BCD value)
1 month (1-12) current month (BCD value)
2 day (1-31) current day (BCD value)
3 hour (0-23) current hour (BCD value)
4 minute (0-59) current minute (BCD value)
5 second (0-59) current second (BCD value)
The year is assumed to start at 2000.
I need to convert this monster to a *nix type long int (32 bit) date and
back.
On the PLC I have a BCD to int conversion which will take byte-pairs and
covert them to 16 bit ints. I can multiply, divide, etc.
From this I need to build the *nix date....
I can't quite get my head around the conversion algorithm. Most
resources on the web use stuff like PERL and awk, none of which I have
available.
So.... Anyone know the algorithm for calculating the *nix date?
Thanks,
--Yan
[ Post a follow-up to this message ]
|