Convert TSTAMP to human date and time

Viewed 91

I'm trying to read a device using Modbus RTU. The type of these fields is TSTAMP. When I read these fields, it returns an integer for each field. In the manual there is a table, with the addresses and types.

Each date consists of reading 2 addresses. For example: I want to read the "Volts" field so I need to read the address 8400-8402. Reading these fields returns the values 4622 and 9483.

How do I convert these 2 integers to date and time format?

MANUAL:

enter image description here

READING:

enter image description here

1 Answers

The format of a TSTAMP ought to be elsewhere in your manual, probably toward the end.

If I consult this manual, the format is

TSTAMP: 3 adjacent registers, 2 bytes each. First (lowest-addressed) register high byte is year (0-99), low byte is month (1-12).

Middle register high byte is day(1-31), low byte is hour (0-23 plus DST bit). DST (daylight saving time) bit is bit 6 (0x40).

Third register high byte is minutes (0-59), low byte is seconds (0-59). For example, 9:35:07AM on October 12, 2049 would be 0x310A, 0x0C49, 0x2307, assuming DST is in effect

Related