TOB1

Recommended Format


TOB1 is a binary format with a CSV-style header.1

If you will only be reading this file with LoggerNet and Toxx, and have no need to read the file in plaintext, this is by far the fastest and most efficient format.

LoggerNet Configuration

Output File Options

  • Include Timestamp
  • Include Record Number

Structure

TOB1 Format
"TOB1" Station Name Datalogger Model Serial Number OS Version DLD Name DLD Sig Table Name
Field Names
Units
Processing Method 2
Field Type 3
[Binary Record Data]

Binary Field Formats

Name Size Description
UINT1 1-byteunsigned int
UINT2 2-byteunsigned int
UINT4 4-byteunsigned int
INT1 1-bytesigned int
INT2 2-bytesigned int
INT4 4-bytesigned int
INT8 8-bytesigned int
FP2 2-bytenon-standard floating point
FP4 4-bytenon-standard floating point
IEEE4 4-byteIEEE floating point
IEEE8 8-byteIEEE floating point
ASCII(n) n-bytefixed length null-terminated string
SEC 4-byteunsigned int as seconds since 1990-01-01
USEC 6-byteunsigned int as 10s of microseconds since 1990-01-01
NSEC 8-byte4-bytes for sec since 1990 + 4-bytes nanoseconds
BOOL 1-byteboolean
BOOL2 2-byteboolean
BOOL4 4-byteboolean
BOOL8 1-bytebit field

FP2

FP2 is widely used as a storage format in Campbell Scientific dataloggers, it is a non-standard two-byte floating point number with a single sign bit, a two-bit negative decimal exponent, and a 13-bit mantissa.

Decoding FP2
sign     = ( 0x8000 & FP2 ) >> 15
exponent = ( 0x6000 & FP2 ) >> 13
mantissa = ( 0x1FFF & FP2 )

value = mantissa * pow( 10, -exponent ) * ( sign == 0 ? 1 : -1 )

FP4

Untested

FP4 is a storage format used in Campbell Scientific dataloggers. It is a non-standard four-byte floating point number with a single sign bit,
a seven-bit base-two exponent, and a 24-bit mantissa.

Decoding FP4
sign     = ( 0x80000000 & FP4 ) >> 31;
exponent = ( 0x7F000000 & FP4 ) >> 24;
mantissa = ( 0x00FFFFFF & FP4 );

value = mantissa * pow( 2, exponent ) * ( sign == 0 ? 1 : -1 );

Example File

"TOB1","Ridge Station","CR1000X","12345","CR1000X.Std.03.02","CPU:ridge_station.CR1X","12345","Ridge_Table"
"SECONDS","NANOSECONDS","RECORD","panel_temp","battery_voltage","battery_voltage_Min"
"SECONDS","NANOSECONDS","RN","°C","volts","volts"
"","","","Smp","Smp","Min"
"ULONG","ULONG","ULONG","FP2","FP2","FP2"
[binary record data...]

Usage

<?php

use Hyyppa\Toxx\Toxx;

$dat = Toxx::load('toa5_file.dat');

$json = $dat->first()->json();

$json =

{
    "TIMESTAMP": "2020-03-08 19:35:00",
    "RECORD": 0,
    "panel_temp": 26.86,
    "battery_voltage": 12.94,
    "battery_voltage_Min": 12.94,
    "SECONDS": 952544100
}

References


  1. Though comma separated, the file is not valid rfc4180 compliant csv as the first line of header does not contain the same number of columns as the rest of the csv file. 

  2. See available processing methods here: LoggerNet Product Manual - B.1.3.1 Field Name Suffixes 

  3. See Binary Field Formats Table 


Last update: January 6, 2021