 |
OMAPI
1.8
Open Movement Public API
|
Go to the documentation of this file.
43 #define _CRT_SECURE_NO_WARNINGS
64 printf(
"ERROR: Problem opening file: %s\n", infile);
85 for (i = 0; i < numSamples; i++)
88 unsigned short fractional;
90 static char timeString[25];
94 sprintf(timeString,
"%04d-%02d-%02d %02d:%02d:%02d.%03d",
97 (
int)fractional * 1000 / 0xffff);
100 x = buffer[3 * i + 0];
101 y = buffer[3 * i + 1];
102 z = buffer[3 * i + 2];
105 fprintf(ofp,
"%s,%d,%d,%d\n", timeString, x, y, z);
108 if (
tee) { fprintf(stderr,
"%s,%d,%d,%d\n", timeString, x, y, z); }
114 if (ofp != NULL && ofp != stdout) { fclose(ofp); }
122 printf(
"CONVERT: convert a specified binary data file to a CSV text file.\n");
126 const char *infile = argv[1];
129 if (argc > 2) {
outfile = argv[2]; }
130 if (argc > 3 && !strcmp(argv[3],
"-tee")) {
tee = 1; }
135 printf(
"Usage: convert <binary-input-file> [text-output-file [-tee]]\n");
137 printf(
"Where: binary-input-file: the name of the binary file to convert.\n");
138 printf(
" text-output-file: the name of the comma-separated-value text file to create, stdout if none.\n");
140 printf(
"Example: convert data.cwa data.csv\n");
unsigned long OM_DATETIME
int convert(const char *infile, const char *outfile, char tee)
#define OM_DATETIME_MONTH(dateTime)
Extract the month (1-12) from a packed date/time value.
#define OM_DATETIME_YEAR(dateTime)
Extract the year from a packed date/time value.
int OmReaderNextBlock(OmReaderHandle reader)
Reads the next block of data from the binary file.
void OmReaderClose(OmReaderHandle reader)
Closes the specified reader handle.
#define OM_DATETIME_DAY(dateTime)
Extract the day (1-31) from a packed date/time value.
#define OM_DATETIME_HOURS(dateTime)
Extract the hours (0-23) from a packed date/time value.
int convert_main(int argc, char *argv[])
#define OM_DATETIME_SECONDS(dateTime)
Extract the seconds (0-59) from a packed date/time value.
OM_DATETIME OmReaderTimestamp(OmReaderHandle reader, int index, unsigned short *fractional)
Determines the timestamp of the specified sample in the buffer read by OmReaderNextBlock().
OmReaderHandle OmReaderOpen(const char *binaryFilename)
Opens a binary data file for reading.
#define OM_DATETIME_MINUTES(dateTime)
Extract the minutes (0-59) from a packed date/time value.
void * OmReaderHandle
Handle to a reader object.
short * OmReaderBuffer(OmReaderHandle reader)
Obtains a pointer to the buffer of samples read, and unpacked, by OmReaderNextBlock().