EasyManua.ls Logo

Scanlab RTC 5 PC Interface Board - 6.8.3 Example Code

Scanlab RTC 5 PC Interface Board
622 pages
Print Icon
To Next Page IconTo Next Page
To Next Page IconTo Next Page
To Previous Page IconTo Previous Page
To Previous Page IconTo Previous Page
Loading...
RTC
®
5 PC Interface Board
Rev. 1.9 e
6 Developing User Applications
90
innovators for industry
6.8.3 Example Code
The following example C source code shows how to
catch an error during initialization. It ensures the
program will terminate with an error message
if an error occurs during initialization with
init_rtc5_dll (e.g. if no RTC
®
5 board was
detected),
if the desired RTC
®
5 board (here: the board with
serial number 12345) is not detected,
if access is denied to the desired RTC
®
5 board,
if an error occurs during load_program_file (e.g.
a version mismatch, file or system error).
The code must be included in a user program (see
page 67).
UINT ErrorCode;
ErrorCode = init_rtc5_dll();
if ( ErrorCode )
{
// Reading the number of RTC
®
5 boards detected during initialization with init_rtc5_dll
const UINT RTC5CountCards = rtc5_count_cards();
if ( RTC5CountCards )
{
// Detailed error analysis for all detected boards
UINT AccError( 0 );
for ( UINT i = 1; i <= RTC5CountCards; i++ )
{
// Errors which occurred during execution of init_rtc5_dll
const UINT Error = n_get_last_error( i );
if ( Error != 0 )
{
AccError |= Error;
const UINT SerialNumber = n_get_serial_number ( i );
printf( "RTC5 board number %d (serial number %d): Error %d detected\n",
i, SerialNumber, Error );
n_reset_error( i, Error );
}
}
if ( AccError )
{
free_rtc5_dll();
return;
}
}
else
{
printf( "Initializing the DLL: Error %d detected\n", ErrorCode );
free_rtc5_dll();
return;
}
}
else
{
// Reading the internal board number for the desired RTC
®
5 board
const UINT SerialNumberOfDesiredBoard ( 12345 );
const UINT RTC5CountCards = rtc5_count_cards();
UINT InternalNumberOfDesiredBoard ( 0 );
for ( UINT i = 1; i <= RTC5CountCards; i++ )
{
if ( n_get_serial_number( i ) == SerialNumberOfDesiredBoard )
{
InternalNumberOfDesiredBoard = i;
}
}
if ( InternalNumberOfDesiredBoard == 0 )
{
printf( "RTC5 board with serial number %d not detected.\n", SerialNumberOfDesiredBoard);
free_rtc5_dll();
return;
}

Table of Contents

Related product manuals