#include #include "CEthCamera.h" int main( int argc, char* argv[] ) { CEthCamera* c; try { c = new CEthCamera( argv[1], 32100 ); } catch( char const* msg ) { printf( "%s\n", msg ); return 0; } // Log files setup must take place before Open(), otherwise // some of the refresh thread logs will be lost. if ( !c->SetLogFilename( "log.txt" ) ) printf( "Log file not created.\n\n" ); if ( !c->SetErrLogFilename( "log_err.txt" ) ) printf( "Error log file not created.\n\n" ); if ( !c->Open( argv[2] ) ) { printf( "Not opened.\n" ); return 0; } char cmd_char[4]; cmd_char[0] = 0x05; cmd_char[1] = 0x01; cmd_char[2] = 0x00; cmd_char[3] = 0x00; if ( c->SendCmd( cmd_char ) ) printf( "Binning: turn ON\n\n" ); // sleep( 3 ); unsigned int val, cmd_uint = 0x01; // if ( c->SendCmd( cmd_uint, NULL, 0, 5, &val ) ) // { // printf( "Get 16b reg #1: number field = %.8X\n\n", htonl(val) ); // } // sleep( 3 ); char* data_buf = new char[NUDP_DATA_PACKETS*NUDP_DATA_LENGTH]; c->SetRawDataBuffer( data_buf ); cmd_uint = 0x08; if ( c->SendCmd( cmd_uint ) ) printf( "Data taking started.\n\n" ); bool any_command_failed = false; /* for ( int i = 0; i < 2; i++ ) { sleep ( 1 ); // three times in a row to make it harder if ( c->SendCmd( 0x0205 ) ) printf( "Command during data taking sent (binning: turn OFF).\n\n" ); else any_command_failed = true; if ( c->SendCmd( 0x0105 ) ) printf( "Command during data taking sent (binning: turn ON).\n\n" ); else any_command_failed = true; if ( c->SendCmd( 0x0205 ) ) printf( "Command during data taking sent (binning: turn OFF).\n\n" ); else any_command_failed = true; //sleep( 1 ); } */ if ( c->WaitForRawData() ) printf( "RAW data transmision done, no missing packets.\n\n" ); else { if ( c->ReadMissing( data_buf ) ) printf( "Missing packets retransmitted.\n\n" ); else printf( "Still there are some missing packets....\n\n" ); } if ( !any_command_failed ) printf( "All commands during data taking with correct response.\n\n" ); // sleep( 1 ); size_t received_length; unsigned int packet_number = 251; if ( c->SendCmd( (packet_number*NUDP_DATA_LENGTH)>>1, NULL, 0, 6, // packet offset (16-bit mode), no data, no data length, top=6 NULL, // don't care about returning number - driver check if it is the same as sent number data_buf+(packet_number*NUDP_DATA_LENGTH), // correct place in the image buffer (8-bit mode) &received_length // might be NULL, but if you are interested in the received data length for any reason... ) ) printf( "RAW packet #%u (length=%d) retransmitted and stored in its right place in the image.\n\n", packet_number, received_length ); sleep( 1 ); if ( c->GetLastResponse( &packet_number ) ) printf( "Get the number field from the last camera respons again.\nIt is: %.8X and it should be the retransmitted data offset (16-bit words).\n\n", packet_number ); char id_buf[32]; // by the way - whenever data field is received, its length must be received too if ( c->SendCmd( 0xEF, NULL, 0, 0, NULL, id_buf, &received_length ) ) printf( "Camera ID received (length=%d). String is: %s\n\n", received_length, id_buf+10 ); c->Close(); delete c; delete data_buf; return 0; }