
HWg-PWR 3 / 12 / 25 MANUAL
HW group
September 2013
page 41
/* Special pragma for Borland C++ Builder
–
other compilers probably use a different way
* how to say to compiler an information about structures packing
*/
#pragma pack(push)
#pragma pack(1)
typedef struct {
unsigned __int16 val_id; /* Value ID */
unsigned __int32 time; /* Unix time format time_t */
__int32 value; /* Value = value * 10^EXP, where EXP is exponent */
} HWG_PWR_LOG_ENTRY;
#pragma pack(pop)
int main(int argc, char* argv[])
{
FILE *InFile;
HWG_PWR_LOG_ENTRY Entry;
time_t t;
InFile = fopen("datalog.bin", "rb");
if (!InFile) {
fprintf(stderr, "File 'datalog.bin' could not open!");
return 1;
}
printf("----------------------------------------------\n");
printf(" ID | VALUE | TIME\n");
printf("----------------------------------------------\n");
while (fread(&Entry, sizeof(HWG_PWR_LOG_ENTRY), 1, InFile)) {
t = _HTONL_(Entry.time);
printf(" %5d | %10d | %s",
_HTONS_(Entry.val_id),
_HTONL_(Entry.value),
asctime(gmtime(&t))
);
}
printf("----------------------------------------------\n");
printf(" ID | VALUE | TIME\n");
printf("----------------------------------------------\n");
fclose(InFile);
return 0;
}
Содержание HWg-PWR 12
Страница 1: ...HWg PWR 3 12 25 MANUAL...
Страница 42: ...HWg PWR 3 12 25 MANUAL HW group September 2013 page 42 Mechanical...
Страница 43: ...HWg PWR 3 12 25 MANUAL HW group September 2013 page 43...