34 int main(
int argc,
char *argv[])
37 unsigned int sample = 0;
39 double ppSensorData[6];
40 unsigned short chksum16_ver;
43 printf(
"\r\nInitializing HCL layer...");
45 printf(
"\r\nError: could not initialize the Seiko Epson HCL layer. Exiting...\r\n");
48 printf(
"...done.\r\n");
51 printf(
"\r\nInitializing GPIO interface...");
53 printf(
"\r\nError: could not initialize the GPIO layer. Exiting...\r\n");
59 printf(
"\r\nInitializing UART interface...");
63 printf(
"\r\nError: could not initialize UART interface. Exiting...\r\n");
70 printf(
"\r\nChecking sensor NOT_READY status...");
73 printf(
"\r\nError: failed to power on Sensor. Exiting...\r\n");
80 printf(
"\r\nInitializing Sensor...");
83 printf(
"\r\nError: could not initialize Epson Sensor. Exiting...\r\n");
89 printf(
"...Epson IMU initialized.");
92 const time_t date = time(NULL);
93 struct tm tm = *localtime(&date);
94 char EpsonlogName[128];
95 char EpsonRawName[128];
98 sprintf(EpsonlogName,
"EpsonLog-%4d-%02d-%02d_T%d:%d:%d.csv", tm.tm_year+1900, tm.tm_mon+1, tm.tm_mday, tm.tm_hour, tm.tm_min, tm.tm_sec);
99 FILE *EpsonLog = fopen(EpsonlogName,
"w");
100 fprintf(EpsonLog,
"Date: ");
101 fprintf(EpsonLog,
"%s", ctime(&date));
102 fprintf(EpsonLog,
"\r\nEpson IMU\r\nSAMPLE,\tXGYRO,\tYGYRO,\tZGYRO,\tXACCL,\tYACCL,\tZACCL,\tCount");
109 #if defined G350 || defined V340 111 #else //G354/G364/G352/G362/G320 115 printf(
"\r\n...Epson IMU Logging.\r\n");
124 #if defined G350 || defined V340 // 16-bit Sensor Output 129 fprintf(EpsonLog,
"\r\n%u,\t%+08f,\t%+08f,\t%+08f,\t%+08f,\t%+08f,\t%+08f,\t%5d", sample, ppSensorData[0], ppSensorData[1], ppSensorData[2], ppSensorData[3], ppSensorData[4], ppSensorData[5], (
unsigned short)readData[9]);
132 #if defined G354 || defined G364 || defined G352 || defined G362 || defined G320 // 32-bit Sensor Output 137 fprintf(EpsonLog,
"\r\n%u,\t%+08f,\t%+08f,\t%+08f,\t%+08f,\t%+08f,\t%+08f,\t%5d,\t0x%04hX,\t0x%04hX", sample, ppSensorData[0], ppSensorData[1], ppSensorData[2], ppSensorData[3], ppSensorData[4], ppSensorData[5], (
unsigned short)readData[12],
138 (
unsigned short)readData[13], tmp16);
140 fprintf(EpsonLog,
", OK");
142 fprintf(EpsonLog,
", ERROR");
151 const time_t end = time(NULL);
152 tm = *localtime(&end);
153 fprintf(EpsonLog,
"\r\nEnd: ");
154 fprintf(EpsonLog,
"%s", ctime(&end));
165 printf(
"\r\nThe following arguments were passed to main(): ");
166 for(i=1; i<argc; i++) printf(
"%s ", argv[i]);
int sensorDataReady(void)
int uartInit(const char *comPortPath, int baudRate)
unsigned short calChecksum16(unsigned short sensorReadData[], unsigned int endOffset)
const unsigned int NUM_SAMPLES
int uartRelease(ComPortHandle comPort)
void ppSensorDataRead32N(double ppSensorReadData[], signed short sensorReadData[], unsigned char startIndex)
void sensorDataReadBurstN(signed short[], unsigned int)
int main(int argc, char *argv[])
void ppSensorDataRead16N(double ppSensorReadData[], signed short sensorReadData[], unsigned char startIndex)