Commit 94990bcb authored by Julio Tambara's avatar Julio Tambara
Browse files

Backup

parent f2042def
...@@ -44,6 +44,7 @@ const char* HISTO_FILENAME= "histo.dat"; ...@@ -44,6 +44,7 @@ const char* HISTO_FILENAME= "histo.dat";
// --------------------------------------------------------------------------- // ---------------------------------------------------------------------------
/************************************************** /**************************************************
**************************************************/ **************************************************/
...@@ -58,6 +59,7 @@ const char* HISTO_FILENAME= "histo.dat"; ...@@ -58,6 +59,7 @@ const char* HISTO_FILENAME= "histo.dat";
int main(int argc, char **argv) int main(int argc, char **argv)
{ {
int w; int w;
unsigned int histograma[8192]; unsigned int histograma[8192];
unsigned int temp = 0, lldt=10; unsigned int temp = 0, lldt=10;
...@@ -68,16 +70,16 @@ int main(int argc, char **argv) ...@@ -68,16 +70,16 @@ int main(int argc, char **argv)
short int fator = 1; short int fator = 1;
N957_UINT32 data32; N957_UINT32 data32;
int ret_val= 0; // procedure exit value int ret_val= 0; // procedure exit value
//N957ErrorCodes N957_error_code; // returned error code
user_setting_data user_setting; // user settings user_setting_data user_setting; // user settings
N957_UINT16 *data_buff= NULL; // read data buffer N957_UINT16 *data_buff= NULL; // read data buffer
unsigned long *histo_buff= NULL; // Histogram data buffer unsigned long *histo_buff= NULL; // Histogram data buffer
int32_t tot_data_read= 0; int32_t tot_data_read= 0;
int ii, i; int ii, i;
char aux_string[ 100]; char aux_string[ 100];
BOOL paused= FALSE; BOOL paused= FALSE; //organizar isso em forma de struct CONTROL
BOOL do_exit= FALSE; BOOL do_exit= FALSE;
BOOL start=FALSE; BOOL start=FALSE;
BOOL erro_9=FALSE;
for(w=0; w<8192; w++) for(w=0; w<8192; w++)
histograma[w] = 0; histograma[w] = 0;
...@@ -92,46 +94,24 @@ int main(int argc, char **argv) ...@@ -92,46 +94,24 @@ int main(int argc, char **argv)
// init user setting module // init user setting module
if( !user_settings_open( &user_setting)) if( !user_settings_open( &user_setting))
{ {
TRACE("erro_1"); TRACE("erro_1\n");
goto exit_point; goto exit_point;
} }
// //
// input parameter check
if( !user_settings_parse_input_param( &user_setting, argc, (char**)argv))
{
TRACE("erro_2");
goto exit_point;
}
/////////////////////////////////////////
// Library specific
/////////////////////////////////////////
//
// now board handle is valid and we can start calling boards API
{
// Get firmware revision
char fw_rev[10];
if( ( N957_GetFWRelease( user_setting.m_N957_handle, fw_rev, 10)))
{
TRACE("erro_3");
goto exit_point;
}
}
data_buff= malloc( user_setting.m_bldim* sizeof( N957_UINT16)); data_buff= malloc( user_setting.m_bldim* sizeof( N957_UINT16));
if( data_buff== NULL) if( data_buff== NULL)
{ {
TRACE("erro_8"); TRACE("erro_8\n");
goto exit_point; goto exit_point;
} }
histo_buff= malloc( N957_MAX_HISTO_SAMPLES* sizeof( *histo_buff)); histo_buff= malloc( N957_MAX_HISTO_SAMPLES* sizeof( *histo_buff));
if( histo_buff== NULL) if( histo_buff== NULL)
{ {
TRACE("erro_8"); TRACE("erro_8\n");
goto exit_point; goto exit_point;
} }
memset( histo_buff, 0, N957_MAX_HISTO_SAMPLES* sizeof( *histo_buff)); memset( histo_buff, 0, N957_MAX_HISTO_SAMPLES* sizeof( *histo_buff));
...@@ -143,42 +123,73 @@ int main(int argc, char **argv) ...@@ -143,42 +123,73 @@ int main(int argc, char **argv)
N957_UINT16 data_read; N957_UINT16 data_read;
if(start)
{
data_read= user_setting.m_bldim;
data_read= user_setting.m_bldim; if( user_setting.m_max_num_samples> 0){
if( tot_data_read>= user_setting.m_max_num_samples) {
if( user_setting.m_max_num_samples> 0){ ret_val= 0;
if( tot_data_read>= user_setting.m_max_num_samples) { //goto exit_point;
ret_val= 0; }
goto exit_point;
}
if( user_setting.m_max_num_samples- tot_data_read< user_setting.m_bldim) { if( user_setting.m_max_num_samples- tot_data_read< user_setting.m_bldim) {
data_read= ( N957_UINT16)(int32_t)(user_setting.m_max_num_samples - tot_data_read); data_read= ( N957_UINT16)(int32_t)(user_setting.m_max_num_samples - tot_data_read);
}
} }
}
// //
// ReadData // ReadData
if( N957_ReadData( user_setting.m_N957_handle, data_buff, &data_read)) {
TRACE("erro_9"); if( N957_ReadData( user_setting.m_N957_handle, data_buff, &data_read)) {
goto exit_point;
if(!erro_9)
{
erro_9=TRUE;
TRACE("erro_9\n");
}
//goto exit_point;
}
else
erro_9=FALSE;
tot_data_read+= data_read;
} }
tot_data_read+= data_read;
if( kbhit()) { if( kbhit()) {
switch( getch()) { switch( getch()) {
case 's': case 's':
case 'S': case 'S':
/// input parameter check
if( !user_settings_parse_input_param( &user_setting, argc, (char**)argv))
{
TRACE("erro_2\n");
break;
//goto exit_point;
}
/////////////////////////////////////////
// Library specific
/////////////////////////////////////////
//
// now board handle is valid and we can start calling boards API
{
// Get firmware revision
char fw_rev[10];
if( ( N957_GetFWRelease( user_setting.m_N957_handle, fw_rev, 10)))
{
TRACE("erro_3");
break;
//goto exit_point;
}
}
if( N957_GetScaler(user_setting.m_N957_handle, &data32)) if( N957_GetScaler(user_setting.m_N957_handle, &data32))
{ {
TRACE("erro_5"); TRACE("erro_5");
//goto exit_point; //goto exit_point;
} }
if(N957_StartAcquire( user_setting.m_N957_handle, user_setting.m_mode)) if(N957_StartAcquire( user_setting.m_N957_handle, user_setting.m_mode))
{ {
...@@ -194,6 +205,7 @@ int main(int argc, char **argv) ...@@ -194,6 +205,7 @@ int main(int argc, char **argv)
//goto exit_point; //goto exit_point;
} }
} }
start= TRUE;
TRACE("OK\n"); TRACE("OK\n");
break; break;
...@@ -220,7 +232,7 @@ int main(int argc, char **argv) ...@@ -220,7 +232,7 @@ int main(int argc, char **argv)
if((N957_StopAcquire( user_setting.m_N957_handle))) if((N957_StopAcquire( user_setting.m_N957_handle)))
{ {
TRACE("erro_24"); TRACE("erro_24\n");
goto exit_point; goto exit_point;
} }
...@@ -320,7 +332,7 @@ int main(int argc, char **argv) ...@@ -320,7 +332,7 @@ int main(int argc, char **argv)
break; break;
case 'l': case 'l':
goto exit_point;
//N957_SetLLD( user_setting.m_N957_handle, lldt); //N957_SetLLD( user_setting.m_N957_handle, lldt);
//lldt=0; //lldt=0;
break; break;
...@@ -379,14 +391,14 @@ exit_point: ...@@ -379,14 +391,14 @@ exit_point:
// Stop acquisition // Stop acquisition
if(N957_StopAcquire( user_setting.m_N957_handle)) if(N957_StopAcquire( user_setting.m_N957_handle))
{ {
TRACE("erro_24"); TRACE("erro_24\n");
goto exit_point; //goto exit_point;
} }
if(N957_SwClear(user_setting.m_N957_handle)) if(N957_SwClear(user_setting.m_N957_handle))
{ {
TRACE("erro_25"); TRACE("erro_25\n");
goto exit_point; //goto exit_point;
} }
// close modules // close modules
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment