3 sciLogger high sample data decoder
6 このプログラムが動作するマシンもLittle Endianである必要あり。
8 Copyright Naoya Takamura@NT systemd design, 2011
10 This program is free software; you can redistribute it and/or modify
11 it under the terms of the GNU General Public License as published by
12 the Free Software Foundation; either version 2 of the License, or
13 (at your option) any later version.
15 This program is distributed in the hope that it will be useful,
16 but WITHOUT ANY WARRANTY; without even the implied warranty of
17 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18 GNU General Public License for more details.
20 You should have received a copy of the GNU General Public License
21 along with this program; if not, write to the Free Software
22 Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
34 struct _recdata_head_t {
43 uint16_t freq; // 記録周波数 Hz
44 } __attribute__((__packed__));
47 typedef struct _recdata_head_t recdata_head;
49 #define REC_DATALEN_HEAD sizeof(recdata_head)
53 3byte -> signed long(4byte)
55 static long b3_to_long32(unsigned char *ptr)
73 static void read_high(FILE *fp)
77 uint8_t data[AD_CH * AD_SAMPLE * AD_BYTES];
81 if (fread(&d, 1, REC_DATALEN_HEAD, fp) < 1) break;
82 //fprintf(stderr, "%02d:%02d:%02d.%03d %d %d", d.hour, d.min, d.sec, (1000*j/AD_SAMPLE), d.tacc, d.valid);
83 if (d.freq > AD_SAMPLE || d.freq < 1) {
84 fprintf(stderr, "read_high() Error freq=%d\n", d.freq);
87 int data_size = AD_CH * d.freq * AD_BYTES;
89 if (fread(data, 1, data_size, fp) < 1) break;
90 for(j = 0; j < d.freq; j++) {
91 fprintf(stdout, "%02d:%02d:%02d.%03d", d.hour, d.min, d.sec, (1000*j/d.freq));
92 for(ch = 0; ch < AD_CH; ch++) {
93 fprintf(stdout, ",%+07ld", b3_to_long32((char*)(data + ch*d.freq*AD_BYTES + j*AD_BYTES)));
95 fprintf(stdout, "\n");
100 int main(int argc, char *argv[])
106 unsigned char buf[256];
108 //printf("len=%d\n", REC_DATALEN_HEAD);
112 printf("sciLogger high sample data converter Ver"VER"\n");
113 printf("Please set filename.\n");
117 fpin = fopen(argv[1], "rb");
120 fprintf(stderr, "Input file open error.\n");
124 strcpy(fname_out, argv[1]);
125 strcat(fname_out, ".txt");
127 fpout = freopen(fname_out, "w", stdout);
129 fprintf(stderr, "Output file open ERROR. %s\n", fname_out);