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-byte | unsigned int |
UINT2 | 2-byte | unsigned int |
UINT4 | 4-byte | unsigned int |
INT1 | 1-byte | signed int |
INT2 | 2-byte | signed int |
INT4 | 4-byte | signed int |
INT8 | 8-byte | signed int |
FP2 | 2-byte | non-standard floating point |
FP4 | 4-byte | non-standard floating point |
IEEE4 | 4-byte | IEEE floating point |
IEEE8 | 8-byte | IEEE floating point |
ASCII(n) | n-byte | fixed length null-terminated string |
SEC | 4-byte | unsigned int as seconds since 1990-01-01 |
USEC | 6-byte | unsigned int as 10s of microseconds since 1990-01-01 |
NSEC | 8-byte | 4-bytes for sec since 1990 + 4-bytes nanoseconds |
BOOL | 1-byte | boolean |
BOOL2 | 2-byte | boolean |
BOOL4 | 4-byte | boolean |
BOOL8 | 1-byte | bit 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
-
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. ↩
-
See available processing methods here: LoggerNet Product Manual - B.1.3.1 Field Name Suffixes ↩