BayEOS-PHP
 All Data Structures Namespaces Files Functions Variables Pages
dumpCat.php
Go to the documentation of this file.
1 #!/usr/bin/php
2 <?php
3 require_once 'BayEOSGatewayClient.php';
4 if($argc<2)
5  die("Usage: dumpCat.php BAYEOS.DB.File\n");
6 
7 if(! is_readable($argv[1]))
8  die("File $argv[1] not readable\n");
9 
10 $ref_date= DateTime::createFromFormat('Y-m-d H:i:s P','2000-01-01 00:00:00 +00:00');
11 $fp=fopen($argv[1],"r");
12 $pos=0;
13 
14 while(! feof($fp)){
15  //read timestamp, length and bayeosframe
16  $ts_bin=fread($fp,4);
17  $ts=BayEOSType::unpackUINT32($ts_bin);
18  $length_bin=fread($fp,1);
19  $length=BayEOSType::unpackUINT8($length_bin);
20  if($length) $bayeosframe=fread($fp,$length);
21  else $bayeosframe='';
22  $res=BayEOS::parseFrame($bayeosframe);
23  fwrite(STDOUT,"found frame: ".date('Y-m-d h:i:s',$ts+$ref_date->format('U'))." - ".($ts/3600)."\n");
24  print_r($res);
25 
26 }
$fp
Definition: dumpCat.php:11
$pos
Definition: dumpCat.php:12
static parseFrame($frame, $ts=FALSE, $origin='', $rssi=FALSE)
static unpackUINT32($value, $endianness=0)
$ref_date
Definition: dumpCat.php:10
static unpackUINT8($value)