155 assert(res == 1); |
160 assert(res == 1); |
156 } |
161 } |
157 |
162 |
158 void parse_data(char *data) |
163 void parse_data(char *data) |
159 { |
164 { |
160 fprintf(outfile, "# Start: %hi-%hhi-%hhi %hhi:%hhi:%hhi\n", |
165 time_t now; |
161 *((short int *) (data + 16)), |
166 struct tm *tm_now; |
162 *((unsigned char *) (data + 28))+1, |
167 struct tm tm; |
163 *((unsigned char *) (data + 29)), |
168 |
164 *((unsigned char *) (data + 30)), |
169 now = time(0); |
165 *((unsigned char *) (data + 31)), |
170 |
166 *((unsigned char *) (data + 32))); |
171 tm_now = localtime(&now); |
|
172 memset(&tm, 0, sizeof(tm)); |
|
173 |
|
174 tm.tm_isdst = tm_now->tm_isdst; |
|
175 tm.tm_year = *((short int *) (data + 16)) - 1900; |
|
176 tm.tm_mon = *((unsigned char *) (data + 28)); |
|
177 tm.tm_mday = *((unsigned char *) (data + 29)); |
|
178 tm.tm_hour = *((unsigned char *) (data + 30)); |
|
179 tm.tm_min = *((unsigned char *) (data + 31)); |
|
180 tm.tm_sec = *((unsigned char *) (data + 32)); |
|
181 |
|
182 timestamp = mktime(&tm); |
|
183 |
|
184 fprintf(outfile, "# Start: %i-%i-%i %i:%i:%i @%llu\n", |
|
185 tm.tm_year + 1900, |
|
186 tm.tm_mon+1, |
|
187 tm.tm_mday, |
|
188 tm.tm_hour, |
|
189 tm.tm_min, |
|
190 tm.tm_sec, |
|
191 (unsigned long long) timestamp); |
|
192 |
167 fprintf(outfile, "# Num Samples: %hi\n", |
193 fprintf(outfile, "# Num Samples: %hi\n", |
168 *((short int *) (data + 8)) |
194 *((short int *) (data + 8)) |
169 ); |
195 ); |
170 fprintf(outfile, "# Time between samples: %hi s\n", |
196 |
171 *((short int *) (data + 12)) |
197 time_per_sample = *((short int *) (data + 12)); |
172 ); |
198 |
|
199 fprintf(outfile, "# Time between samples: %i s\n", |
|
200 time_per_sample); |
173 } |
201 } |
174 |
202 |
175 int |
203 int |
176 start_download() |
204 start_download() |
177 { |
205 { |
232 int j; |
260 int j; |
233 for(j=0; j<take; j+=4) |
261 for(j=0; j<take; j+=4) |
234 { |
262 { |
235 float temp = *((short int *) (data + j)) / 10.; |
263 float temp = *((short int *) (data + j)) / 10.; |
236 float hum = *((short int *) (data + j + 2)) / 10.; |
264 float hum = *((short int *) (data + j + 2)) / 10.; |
237 fprintf(outfile, "%i %g %g\n", sec, temp, hum); |
265 |
238 sec++; |
266 time_t sampletime = timestamp + time_per_sample * sample; |
|
267 |
|
268 fprintf(outfile, "%i %llu %g %g\n", sample, |
|
269 (unsigned long long) sampletime, |
|
270 temp, hum); |
|
271 sample++; |
239 } |
272 } |
240 num -= 64; |
273 num -= 64; |
241 num_frames -= 1; |
274 num_frames -= 1; |
242 } |
275 } |
243 ++block; |
276 ++block; |