Debian Codegraph @

biosig4c++/src/flowmon2.c

raw symbols SCIP
1 /*
2 # Copyright (C) 2011,2012,2026 Alois Schloegl, ISTA
3 #
4 # This program is free software; you can redistribute it and/or modify
5 # it under the terms of the GNU General Public License as published by
6 # the Free Software Foundation; either version 3 of the License, or
7 # (at your option) any later version.
8 #
9 # This program is distributed in the hope that it will be useful,
10 # but WITHOUT ANY WARRANTY; without even the implied warranty of
11 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 # GNU General Public License for more details.
13 #
14 # You should have received a copy of the GNU General Public License
15 # along with this program; If not, see <http://www.gnu.org/licenses/>.
16 */
17
18 /*
19
20 Supported Device(s):
21 Flow Meter GSM-D3KA-BN00 from Vögtlin Instruments
22
23 DONE(+)/TODO(-):
24 - units of flow l/min oder m^3/h ??
25 + graceful handling of exit (close all handles even when stopped with <CTRL>-C
26 + one file per day, appending
27 + autostart
28 - file management, data compression, (/var/spool/... /etc/flowmon.conf
29 - init.d (flowmon start/stop)
30 - fix appending to *.log.gdf file after restart
31 - javascript interface
32
33 Requirements:
34 g++
35 libz 1.2.5 or higher
36 libbiosig.a (v1.2 or higher) available from http://biosig.sf.net
37
38 */
39
40
41 #include "../biosig.h"
42
43 #include <errno.h>
44 #include <math.h>
45 #include <inttypes.h>
46 #include <stdio.h>
47 #include <stdlib.h>
48 #include <string.h>
49 #include <time.h>
50 #include <sys/time.h>
51
52 #include <termios.h>
53 #include <unistd.h>
54 #include <fcntl.h>
55 #include <sys/signal.h>
56 #include <sys/types.h>
57
58
59 #define LENBUF 300
60 #define BAUDRATE B9600
61 #define MODEMDEVICE "/dev/ttyUSB0"
62 #define _POSIX_SOURCE 1 //POSIX compliant source
63 #define FALSE 0
64 #define TRUE 1
65
66
67 int wait_flag=TRUE; //TRUE while no signal received
68 //void signal_handler_IO (int status); //definition of signal handler
69 char buf[LENBUF+1] __attribute__ ((deprecated));
70 uint8_t idata[LENBUF];
71 uint8_t odata[LENBUF];
72 char manufacturer[1000];
73
74 int fd;
75 FILE *fid=NULL;
76 FILE *fid2=NULL;
77 // biosig
78 HDRTYPE *hdr = NULL;
79 struct termios oldtio, newtio; //place for old and new port settings for serial port
80
81 void stop() {
82 // reset terminal
83 if (fd>2) {
84 tcsetattr(fd, TCSANOW, &oldtio);
85 close(fd);
86 }
87
88 // close gdf file
89 if (hdr) destructHDR(hdr);
90
91 // close debug file
92 if (fid2) fclose(fid2);
93 }
94
95 const void *outPtr = odata+3;
96
97 /*
98 crc16_a001: computes crc of a modbus packet and writes it at the end;
99 (remark: its not CCITT's crc16 but uses 0xA001 polynomial)
100 input :
101 data : packet with its crc
102 n : length of data without the crc
103
104 ouput : crc16 value
105 */
106 #if defined(__LITTLE_ENDIAN)
107 uint16_t crc16_a001(uint8_t data[], size_t n)
108 {
109 uint8_t flag;
110 size_t i,j;
111 union {
112 uint16_t u16;
113 uint8_t u8[2];
114 } crc;
115
116 crc.u16 = 0xffff;
117 for (i=0; i<n; i++) {
118 crc.u8[0] = crc.u8[0]^data[i];
119 for (j=0; j<8; j++) {
120 flag = crc.u8[0] & 0x01;
121 crc.u16 = crc.u16 >> 1;
122 if (flag) crc.u16 = crc.u16^0xa001;
123 }
124 }
125
126 // write crc to end of data block
127 *(uint16_t*)(data+n) = crc.u16;
128 return (uint16_t)crc.u16;
129 }
130
131 int read_register(uint8_t slave, uint8_t cmd, uint16_t reg) {
132
133 idata[0] = slave; // address
134 idata[1] = 3; //cmd; // read -
135 *(uint16_t*)(idata+2) = bswap_16((uint16_t)reg); // register
136 *(uint16_t*)(idata+4) = bswap_16(0x0004); // length
137 crc16_a001(idata,6); // compute crc and add at and
138 tcflush(fd, TCIOFLUSH);
139 int c = write(fd,idata,8);
140 if (VERBOSE_LEVEL>8) fprintf(stdout,"\n======= SENT %i bytes\n",c);
141 usleep(100000);
142 c = read(fd,odata,16);
143 if (VERBOSE_LEVEL>8) fprintf(stdout,"\n======= RECEIVED %i bytes\n",c);
144 if (c<9 || odata[0] != slave) return (-1);
145
146 if (VERBOSE_LEVEL==6)
147 fprintf(stdout,"\n======= REG:0x%04x RECEIVED %2i bytes U16[2]: 0x%08x %08x %08x %08x F:%10g %10g<%s> ",\
148 reg,c,beu32p(odata),beu32p(odata+4),beu32p(odata+8),beu32p(odata+12), \
149 (double)bef32p(odata+3), (double)bef32p(odata+7), (char*)(odata+3));
150
151 uint16_t crc=bswap_16(crc16_a001(odata,c-2));
152 if (VERBOSE_LEVEL>8)
153 fprintf(stdout,"crc 0x%04x 0x%04x",bswap_16(crc),beu16p(odata+c-2));
154 usleep(10000);
155
156 if (crc!=beu16p(odata+c-2)) return -1;
157
158 return 0;
159 }
160 #else
161 #error CRC16 function not defined for big endian platform
162 #endif
163
164
165 int main(int argc, char *argv[]) {
166
167 char *devicename = "/dev/ttyUSB0";
168 const char *outFile = NULL;
169
170 // TODO: check whether debugFile and debugfile can be unified.
171 const char *debugFile = NULL;
172 char debugfile[40] = "flowmonDD.log.txt";
173
174 // 00 = NONE, 01 = Odd, 02 = Even, 03 = Mark, 04 = Space
175 struct timeval tv;
176 struct timezone tz;
177 struct tm T;
178 uint32_t oldDay=0, newDay;
179 gdf_time gdfTime;
180 char flag_GZIP = 0;
181
182 char logfile[48] = "flowmonYYYYMMDD.log.gdf";
183
184
185 /***************************************************************************
186 *
187 * input arguments
188 *
189 ***************************************************************************/
190
191 const char help[]=
192 "FLOWMON2 reads data of the flow sensor through the serial terminal and stores it into a data file for archiving.\n"
193 " The current measurement values are also written into the file /var/www/flowsensor.html.\n"
194 " This software supports the device 'Flow Meter GSM-D3KA-BN00 (BHT Rotary Gas Meter) from Vögtlin Instruments'.\n\n"
195 "Usage: flowmon -d devicename [-o outfile] [-D debugfile] [-V#]\n"
196 " devicename: default value is /dev/ttyS0\n"
197 " outfile: logs the recorded data\n"
198 " If no outfile is provided, the data will be logged into daily files named flowmon<$date>.log.gdf \n"
199 " debugfile: logs the data in ascii text\n"
200 " If no outfile is provided, the data will be logged into daily files named flowmon<$day-of-month>.log.txt \n"
201 " -V# verbose level #=0 is no messages, #=9 is highest level(debugging) messages\n"
202 " -h, --help: display this help text\n"
203 " -z save outfile in gzipped format\n"
204 " \n\n"
205 ;
206 if (argc<2) {
207 fprintf(stdout,"%s",help);
208 return(0);
209 }
210
211 gettimeofday(&tv, &tz);
212 gdfTime = t_time2gdf_time(tv.tv_sec + ldexp(tv.tv_usec*1e-6/(24*3600.0),32) );
213 gdf_time2tm_time_r(gdfTime, &T);
214 newDay = T.tm_mday;
215 sprintf(debugfile,"flowmon%02d.log.txt",T.tm_mday);
216
217 /* Sanity checks of input arguments */
218 int k = 0;
219 while (k<argc) {
220
221 if (VERBOSE_LEVEL>3) fprintf(stdout,"%i/%i\t%s\n",k,argc,argv[k]);
222
223 if (0) {
224 }
225 else if (!strcmp(argv[k],"-d")) {
226 devicename = argv[++k];
227 }
228 else if (!strcmp(argv[k],"-h") || !strcmp(argv[k],"--help") ) {
229 fprintf(stdout,"%s",help);
230 return 0;
231 }
232 else if (!strcmp(argv[k],"-o")) {
233 k++;
234 outFile = argv[k];
235 }
236 else if (!strcmp(argv[k],"-D")) {
237 k++;
238 debugFile = argv[k];
239 }
240 else if (!strncmp(argv[k],"-V",2)) {
241 char c = argv[k][2];
242 #ifndef VERBOSE_LEVEL
243 if ('0'<=c && c<='9')
244 VERBOSE_LEVEL = c-'0';
245 #endif
246 }
247 else if (!strcmp(argv[k],"-z")) {
248 flag_GZIP = 1;
249 }
250 k++;
251 }
252
253 /***************************************************************************
254 *
255 * initialization
256 *
257 ***************************************************************************/
258
259 // clean up at exit
260 atexit(&stop);
261
262 if (VERBOSE_LEVEL>7) fprintf(stdout,"%s (line %d): err %d\n",__FILE__,__LINE__,errno);
263
264 //open the device(com port) to be non-blocking (read will return immediately)
265 fd = open(devicename, O_RDWR | O_NOCTTY | O_NONBLOCK);
266 if (fd < 0) {
267 perror(devicename);
268 exit(EXIT_FAILURE);
269 }
270 tcgetattr(fd,&oldtio); // save current port settings
271
272 if (VERBOSE_LEVEL>7) fprintf(stdout,"%s (line %d): fd=%d\n",__FILE__,__LINE__,fd);
273
274 // set new port settings for canonical input processing
275 // newtio.c_cflag = BAUD | CRTSCTS | DATABITS | STOPBITS | PARITYON | PARITY | CLOCAL | CREAD;
276 newtio.c_cflag = BAUDRATE | CS8 | CLOCAL | CREAD | CSTOPB;
277 newtio.c_iflag = IGNPAR;
278 newtio.c_oflag = 0;
279 newtio.c_lflag = 0; //ICANON;
280 newtio.c_cc[VMIN] = 1;
281 newtio.c_cc[VTIME]= 0;
282 tcflush(fd, TCIOFLUSH);
283 tcsetattr(fd,TCSANOW,&newtio);
284
285 if (VERBOSE_LEVEL>7) fprintf(stdout,"%s (line %d): err %d\n",__FILE__,__LINE__,errno);
286 if (errno) {
287 fprintf(stderr,"%s (line %d) %d %s\n", __FILE__, __LINE__, errno, strerror(errno));
288 stop();
289 return(errno);
290 }
291
292 #if 1
293 fid2 = fopen(debugFile,"a");
294
295 {
296 hdr = constructHDR(4 ,0);
297 hdr->SampleRate = 1;
298 hdr->SPR = 1;
299 hdr->NRec = -1;
300 hdr->EVENT.N = 0;
301 hdr->FILE.COMPRESSION = 0;
302
303 {
304 // channel 1: time stamp
305 CHANNEL_TYPE *hc = hdr->CHANNEL + 0;
306 hc->LeadIdCode = 0;
307 strcpy(hc->Label,"time ");
308 hc->GDFTYP = 8; // uint64
309 hc->SPR = hdr->SPR;
310
311 hc->PhysMax = ldexp(1,32);
312 hc->PhysMin = 0;
313 hc->DigMax = ldexp(1,64);
314 hc->DigMin = 0;
315 hc->PhysDimCode = PhysDimCode("d"); // days
316 hdr->AS.bpb += GDFTYP_BITS[hc->GDFTYP]>>3;
317 }
318
319 {
320 // channel 2: volume
321 CHANNEL_TYPE *hc = hdr->CHANNEL + 1;
322 hc->LeadIdCode = 0;
323 strcpy(hc->Label,"total volume ");
324 hc->GDFTYP = 6; // uint32
325 hc->GDFTYP = 16; // float32
326 hc->SPR = hdr->SPR;
327 hc->PhysMax = ldexp(1,32);
328 hc->PhysMin = -hc->PhysMax;
329 hc->DigMax = hc->PhysMax;
330 hc->DigMin = hc->PhysMin;
331 hdr->AS.bpb += GDFTYP_BITS[hc->GDFTYP]>>3;
332
333 read_register(247, 3, 0x6384) ; // f32: Skalierung Totalisator, and s8: Einheit des Totalisatorwertes mit 4 Byte offset.
334 //read_register(247, 3, 0x6386) ; // s8: Einheit des Totalisatorwertes
335 if (!strcmp((char*)(outPtr+4),"ln"))
336 hc->PhysDimCode = PhysDimCode("l");
337 else
338 hc->PhysDimCode = 0; // "unknown"
339 }
340
341 {
342 // channel 3: flow
343 CHANNEL_TYPE *hc = hdr->CHANNEL + 2;
344 hc->LeadIdCode = 0;
345 strcpy(hc->Label,"flow ");
346 hc->GDFTYP = 3; // int16
347 hc->GDFTYP = 16; // float32
348 hc->SPR = hdr->SPR;
349 hdr->AS.bpb += GDFTYP_BITS[hc->GDFTYP]>>3;
350
351 read_register(247, 3, 0x6020) ; // f32: Endwert Messbereich
352 hc->PhysMax = bef32p(outPtr);
353 hc->PhysMin = -hc->PhysMax;
354 hc->DigMax = hc->PhysMax;
355 hc->DigMin = hc->PhysMin;
356 read_register(247, 3, 0x6022) ; // s50: Bezeichnung Medium Lang
357 strncpy(hc->Transducer,(char*)(outPtr+1),MAX_LENGTH_TRANSDUCER);
358 read_register(247, 3, 0x6042) ; // s8: Bezeichnung Medium kurz
359 strncpy(hc->Transducer,(char*)(outPtr),MAX_LENGTH_LABEL);
360
361 read_register(247, 3, 0x6046) ; // s8: Einheit Messwert
362 if (!strcmp((char*)outPtr,"ln/h")) {
363 //hc->PhysDimCode = 3072; // "l min-1"
364 hc->PhysDimCode = 3104; // "l h-1"
365 }
366 else
367 hc->PhysDimCode = 0; // "unknown"
368
369 // read_register(247, 3, 0x6046) ; // s8: Einheit Messwert
370
371 read_register(247, 3, 0x6120) ; // u16: Verstärkung, Amplification; und u16 Heizleistung (2 byte offset), und u16: Dynamik (4 Byte offset)
372 //read_register(247, 3, 0x6121) ; // u16: Heizleistung
373 //read_register(247, 3, 0x6122) ; // u16: Dynamik
374 }
375
376 {
377 // channel 4: temparature
378 CHANNEL_TYPE *hc = hdr->CHANNEL + 3;
379 hc->LeadIdCode = 0;
380 strcpy(hc->Label,"Temperature");
381 hc->GDFTYP = 16; // float32
382 hc->SPR = hdr->SPR;
383 hc->PhysMax = 500;
384 hc->PhysMin = -500;
385 hc->DigMax = 500;
386 hc->DigMin = -500;
387 hc->PhysDimCode = 6048; // degree Celsius
388 hdr->AS.bpb += GDFTYP_BITS[hc->GDFTYP]>>3;
389 }
390
391 if (hdr->NS > 4) {
392 // channel 5: type of gas
393 CHANNEL_TYPE *hc = hdr->CHANNEL + 4;
394 hc->LeadIdCode = 0;
395 strcpy(hc->Label,"typ of gas");
396 hc->GDFTYP = 2; // uint8
397 hc->SPR = hdr->SPR;
398 hc->PhysMax = 255;
399 hc->PhysMin = 0;
400 hc->DigMax = 255;
401 hc->DigMin = 0;
402 hc->PhysDimCode = 0;
403 hdr->AS.bpb += GDFTYP_BITS[hc->GDFTYP]>>3;
404 }
405 for (k=0; k<hdr->NS; k++) {
406 CHANNEL_TYPE *hc = hdr->CHANNEL + k;
407 hc->LeadIdCode = 0;
408 hc->SPR = 1;
409 }
410
411 hdr->AS.rawdata = (uint8_t*)realloc(hdr->AS.rawdata,hdr->AS.bpb);
412
413 hdr->ID.Manufacturer.Name = "Voegtlin";
414 /*
415 hdr->ID.Manufacturer.Model = "Flow Meter";
416 hdr->ID.Manufacturer.Version = "GSM-D3KA-BN00";
417 hdr->ID.Manufacturer.SerialNumber = "150427";
418 */
419 read_register(247, 3, 0x0023) ; // Typencode 1: Gerätebezeichnung Teil 1
420 hdr->ID.Manufacturer.Model = (char*)manufacturer;
421 strcpy(manufacturer,"FlowMeter ");
422 strcat(manufacturer, outPtr);
423 read_register(247, 3, 0x1004) ; // Typencode 2: Gerätebezeichnung Teil 2
424 strcat(manufacturer, outPtr);
425
426 read_register(247, 3, 0x0020); // u16: Hardware Version number,
427 uint16_t HardWareVersion = beu16p(outPtr);
428 // read_register(247, 3, 0x0021); // u16: Software Version number: is available also from previous request with 2 byte offset
429 uint16_t SoftWareVersion = beu16p(outPtr+2); // u16: Software Version number
430 hdr->ID.Manufacturer.Version = manufacturer+strlen(manufacturer)+1;
431 sprintf((char*)(hdr->ID.Manufacturer.Version),"Hardware: %d.%d.%d Software: %d.%d.%d", \
432 HardWareVersion>>8, \
433 (HardWareVersion & 0xF0)>>4, \
434 HardWareVersion & 0x0F, \
435 SoftWareVersion>>8, \
436 (SoftWareVersion & 0xF0)>>4, \
437 SoftWareVersion & 0x0F \
438 );
439
440 read_register(247, 3, 0x001e) ; // u32: serial number
441 hdr->ID.Manufacturer.SerialNumber = hdr->ID.Manufacturer.Version+strlen(hdr->ID.Manufacturer.Version)+1;
442 sprintf((char*)(hdr->ID.Manufacturer.SerialNumber),"%d",beu32p(outPtr));
443
444 hdr->FLAG.UCAL = 1;
445 hdr->TYPE = GDF;
446 hdr->VERSION = 2.0;
447 if (outFile) hdr->FileName = strdup(outFile);
448 }
449 #endif
450
451 read_register(247, 3, 0x0000) ; // float32: Messwert Gasdurchfluss
452 read_register(247, 3, 0x0002) ; // float32: Temperatur
453 // read_register(247, 3, 0x0006) ; // float32: Sollwert Gasdurchfluss
454 // read_register(247, 3, 0x0008) ; // float32: Messwert Analogeingang
455
456 read_register(247, 3, 0x000c) ; // u16: Alarmmeldungen
457 read_register(247, 3, 0x000d) ; // u16: Hardwarefehler
458 //read_register(247, 3, 0x000e) ; // u16: Regelmode
459 //read_register(247, 3, 0x000f) ; // u16: Ramp
460
461 read_register(247, 3, 0x0013) ; // device address: default 247 (0xf7)
462 //read_register(247, 3, 0x0020) ;
463 //read_register(247, 3, 0x0021) ;
464
465 // read_register(247, 3, 0x5200) ; // u16: baud rate
466
467
468 read_register(247, 3, 0x0004) ; // f32: Totalisator 1
469 read_register(247, 3, 0x6380) ; // f32: Totalisator 1, and f32 Totalisator 2 with 4 Byte offset.
470 //read_register(247, 3, 0x6382) ; // f32: Totalisator 2 - nicht rückstellbar
471 read_register(247, 3, 0x6384) ; // f32: Skalierung Totalisator, and s8: Einheit des Totalisatorwertes mit 4 Byte offset.
472 //read_register(247, 3, 0x6386) ; // s8: Einheit des Totalisatorwertes
473
474 if (outFile) {
475 // open once write all data into single log file
476 hdr->FILE.COMPRESSION = flag_GZIP;
477 hdr = sopen(outFile, "a", hdr);
478 if (VERBOSE_LEVEL>7) hdr2ascii(hdr,stdout,4);
479
480 if (serror2(hdr)) {
481 destructHDR(hdr);
482 return(EXIT_FAILURE);
483 }
484
485 if (hdr->FILE.OPEN < 2) {
486 destructHDR(hdr);
487 hdr = NULL;
488 fprintf(stderr,"Could not open output file %s\n", outFile);
489 exit(-1);
490 }
491
492 hdr->AS.rawdata = (uint8_t*)realloc(hdr->AS.rawdata,hdr->AS.bpb);
493 if (hdr->NRec < 0) hdr->NRec = 0;
494 }
495
496 /***************************************************************************
497 *
498 * processing: data is continuosly read from serial interface and written to log and debug file
499 *
500 ***************************************************************************/
501
502 fid = fdopen(fd, "r+");
503
504 while (1) {
505 /***
506 get data
507 ***/
508
509 if (read_register(247, 3, 0x0004)) continue; // f32: Totalisator 1
510 float TotalVolume = bef32p(outPtr);
511
512 if (read_register(247, 3, 0x0000)) continue; // float32: Messwert Gasdurchfluss, and f32: Temperatur with 4 byte offset
513 //read_register(247, 3, 0x0002) ; // float32: Temperatur
514 float Flow = bef32p(outPtr);
515 float Temperature = bef32p(outPtr+4);
516
517 /*
518 if (read_register(247, 3, 0x6380)) continue; // f32: Totalisator 2
519 float TotalVolume2 = bef32p(outPtr);
520 float TotalVolume3 = bef32p(outPtr+4);
521 */
522
523 gettimeofday(&tv, &tz);
524 gdfTime = t_time2gdf_time(tv.tv_sec) + ldexp(tv.tv_usec*1e-6/(24*3600.0),32);
525 gdf_time2tm_time_r(gdfTime, &T);
526 newDay = T.tm_mday;
527 if ( (newDay != oldDay) && !outFile) {
528 // open/close daily log file
529
530 sclose(hdr);
531 hdr->NRec = -1;
532 sprintf(logfile,"flowmon%04d%02d%02d.log.gdf",T.tm_year+1900,T.tm_mon+1,T.tm_mday);
533 hdr->FILE.COMPRESSION = flag_GZIP;
534 hdr = sopen(logfile, "a", hdr);
535
536 if (serror2(hdr)) {
537 destructHDR(hdr);
538 return(EXIT_FAILURE);
539 }
540
541 if (!hdr->FILE.OPEN) {
542 destructHDR(hdr);
543 hdr = NULL;
544 fprintf(stderr,"Could not open output file %s\n", logfile);
545 }
546
547 hdr->AS.rawdata = (uint8_t*)realloc(hdr->AS.rawdata,hdr->AS.bpb);
548 if (hdr->NRec<0) hdr->NRec = 0;
549 }
550
551 if ( (newDay != oldDay) && !debugFile) {
552 // open/close daily debug file
553 if (fid2) fclose(fid2);
554 sprintf(debugfile,"flowmon%02d.log.txt",T.tm_mday);
555 fid2 = fopen(debugfile,"a");
556 }
557
558 if (newDay != oldDay) {
559 oldDay = newDay;
560 };
561
562
563 /***
564 parse data
565 ***/
566
567 memcpy(hdr->AS.rawdata+hdr->CHANNEL[0].bi,&gdfTime,8);
568 *(float*)(hdr->AS.rawdata+hdr->CHANNEL[1].bi)=TotalVolume;
569 *(float*)(hdr->AS.rawdata+hdr->CHANNEL[2].bi)=Flow;
570 *(float*)(hdr->AS.rawdata+hdr->CHANNEL[3].bi)=Temperature;
571
572 if (hdr) {
573
574 if (VERBOSE_LEVEL>7) fprintf(stdout,"FLOWMON 230 %i, %i, %i\n", (int)hdr->NRec, hdr->AS.bpb, hdr->FILE.OPEN);
575 if (VERBOSE_LEVEL>8) fprintf(stdout,"FLOWMON 240 %g, %g, %g\n", TotalVolume,Flow,Temperature);
576
577 hdr->NRec += ifwrite(hdr->AS.rawdata, hdr->AS.bpb, 1, hdr);
578 ifflush(hdr);
579
580 /*******************************************************************
581 * Write HTML file
582 *******************************************************************/
583 char buf[100];
584 strfgdftime(buf,100,"%Y-%m-%d %H:%M:%S UTC",gdfTime);
585 FILE *fid3 = fopen("/var/www/flowsensor.html","w");
586 if (fid3 != NULL) {
587 fprintf(fid3,"<html><body><h1>Carbogen FlowSensor</h1><br><pre>Time:\t\t%s\n",buf);
588 fprintf(fid3,"Manufacturer:\t%s \nModel:\t\t%s\nSerialNo:\t%s\nVersion:\t%s\n",hdr->ID.Manufacturer.Name, hdr->ID.Manufacturer.Model,hdr->ID.Manufacturer.SerialNumber,hdr->ID.Manufacturer.Version);
589 fprintf(fid3,"Total Volume:\t%10.3f l_n\n",TotalVolume);
590 //fprintf(fid3,"Total Volume 2:\t%10.3f l_n (nicht ruecksetzbar)\n",TotalVolume2);
591 //fprintf(fid3,"Total Volume -:\t%10.3f l_n (nicht ruecksetzbar)\n",TotalVolume3);
592 fprintf(fid3,"Flow:\t\t %10.4f l_n/h\n",Flow);
593 fprintf(fid3,"Temperature:\t%6.3f C\n</pre><META HTTP-EQUIV=\"refresh\" CONTENT=\"1\"></body></html>",Temperature);
594 fclose(fid3);
595 }
596 }
597
598 }
599 stop();
600
601 return(0);
602 }
603
604
605