Experiment Controller Data File Format
The ECL emulator firmware and the ECBasic firmware (in transparent mode) output data in a binary format. On IBM-PC platforms the ExpRun program writes this data into files in the same format as it is sent from the controller, except that an information header is written at the beginning of the data file.
The file header is 14 bytes long and has the following format:
Byte Number |
Byte Usage |
Description |
---|---|---|
|
|
|
|
| |
|
|
|
|
| |
|
| |
|
| |
|
|
|
|
| |
|
|
|
|
| |
|
|
|
|
| |
|
| |
|
|
The date and time is stored as the number of seconds since 00:00 January 1, 1970. This is the return value of the time() function found in most "C" compilers. The localtime() function is commonly used to convert this value to a more usable structure.
Data items follow the header and are 6 bytes long. They have the following format:
Byte Number |
Byte Usage |
Description |
---|---|---|
|
|
|
|
|
|
|
|
|
|
| |
|
| |
|
|
ECL and ECBasic encodes these data records as follows:
Type |
Value |
Data |
Description |
---|---|---|---|
1 |
1-48 |
Time |
Turn on Output |
2 |
1-48 |
Time |
Turn off Output |
3 |
1-8 |
Time |
Input seen |
4 |
1-255 |
Time |
Marker |
5 |
0 |
Time |
Program Ends |
6 |
1-5 |
Time |
Timer Expired |
7 |
0 |
Value |
Send 32-bit Data value |
8 |
0-255 |
Line Number |
Error Number |
Record type 5 marks the end of the data. There should not be any data records after the marker type 5, so you can use this as the "end of file" indicator.
Error Number |
Probable Cause |
---|---|
|
Syntax Error |
|
Illegal Variable Name |
|
Constant Redefined |
|
Variable redefined |
|
Symbol table full - too many variables |
|
Illegal Variable usage |
|
Expression Missing |
|
Variable not defined |
|
Illegal use of string |
|
Parentheses Balance Error |
|
Improper Parameter Count |
|
Internal Error - usually a bad instruction was encountered |
|
Illegal Array Usage |
|
Array not dimensioned |
|
Illegal Array Subscript |
|
Illegal Expression Type |
|
NEXT without FOR |
|
Improper Nesting of FOR/NEXT |
|
Missing Argument |
|
Subroutine Stack Overflow |
|
Line number not found |
|
Return without GoSub |
|
Array Redimensioned |
|
Illegal Expression Value |
|
Break seen (control program terminated) |
|
Stop command seen |
|
Division by zero |
|
Nesting too deep in FOR/NEXT |
|
Out of Data in read command |
|
Out of Memory |
|
Dimension Too Large - Exceeded available memory |
#include <stdio.h> #include <stdlib.h> #include <time.h> #include <string.h> char infile[40]; /* input file name */ FILE *ipnt; /* input file descriptor */ struct tm *localtime(); struct tm *time_ptr; void put8( unsigned char, FILE * ); void put16( unsigned short, FILE * ); void put32( unsigned long, FILE * ); unsigned char get8( FILE * ); unsigned short get16( FILE * ); unsigned long get32( FILE * ); int main( int argc, char *argv[] ) { int i; int ibird,itype,idata; long oldtim; long bird_time; int weight; int box; unsigned long prog_id; if (argc<2) { while(1) { printf( "File name? " ); fgets( infile, 20, stdin ); if ( strlen( infile ) == 0 ) continue; break; } } else { strcpy(infile,argv[1]); } i = strlen( infile ); if ( infile[i-1] == '\n' ) infile[i-1] = '\0'; ipnt = fopen(infile,"rb"); if(ipnt == NULL) { printf( "Cannot open %s\n", infile ); exit( 1 ); } oldtim = 0; ibird = get16( ipnt ); bird_time = get32( ipnt ); weight = get16( ipnt ); box = get16( ipnt ); prog_id = get32( ipnt ); putenv( "TZ=EST0" ); tzset(); time_ptr = localtime(&bird_time); printf( "Bird #%d, Date: %d/%d/%d %d:%d:%d\n", ibird, time_ptr->tm_mon+1, time_ptr->tm_mday, time_ptr->tm_year, time_ptr->tm_hour, time_ptr->tm_min, time_ptr->tm_sec ); printf( "Weight = %d, Box = %d, ID = %ld\n", weight, box, prog_id ); while( feof( ipnt ) == 0) { itype = get8( ipnt ); idata = get8( ipnt ); bird_time = get32( ipnt ); if( itype == 7 ) { if (idata == 0) { printf( "%3d %ld\n", itype, bird_time ); } else { printf( "%3d %3d %ld\n", itype, idata, bird_time ); } } else { printf( "%3d %3d %ld,%ld\n",itype,idata, bird_time,bird_time-oldtim); oldtim = bird_time; if ( itype == 5 ) break; } } fclose( ipnt ); return( 1 ); }
Bird #11, Date: 5/22/97 9:30:5 Weight = 11, Box = 9, ID = 1 1 4 20,20 4 100 22,2 4 1 22,0 1 28 22,0 4 2 6022,6000 1 21 6023,1 4 3 12022,5999 1 27 12023,1 4 4 18023,6000 1 26 18023,0 4 5 24023,6000 1 19 24023,0 4 6 30023,6000 1 23 30023,0 3 2 31211,1188 3 2 31418,207 3 2 31586,168 3 2 31725,139 3 2 31860,135 4 7 36022,4162 1 22 36023,1 4 8 42022,5999 1 25 42023,1 4 9 48023,6000 1 24 48023,0 4 10 54023,6000 1 20 54023,0 2 4 60023,6000 1 2 60023,0 2 2 63022,2999 1 4 63023,1 4 100 63024,1 4 1 63024,0 1 28 63025,1 5 0 65867,2842