JoeScan
  home
our story
news  and events
contact us
    our products
how it works
applications support service

Sending Parameter Files to the Scanner


Detailed Description

These functions are for sending, reading, and checking correctness of parameter files sent to the scanner.

This sample code opens a connection and sends parameters to the scanner.

Please, please check your error codes from the function. If there is a syntax error in the parameters, the parameters will not be saved to the scanner. You should tell users what the errors are so they can fix them. There are line numbers and everything.

Yes, I realize there are goto statments in this code. It makes things cleaner in this case.

#define JCAM_STATIC_LIB
#include "jcam_dll.h"
#include <stdio.h>

using namespace joescan;

int main(int argc, char * argv[])
{
    if(jsInitialize() == FALSE)
        exit(0);

    size_t i = 0;
    JCONNECTION jc;

    if((jc = jsOpenConnection("192.168.1.105")) == NULL)
    {
        printf("Couldn't open connection.\n");
        goto CLEANUP;
    }

    switch(jsSendParameterFileToScanner(jc, "param.dat"))
    {
        case SCANNER_FAILURE:
            printf("Lost connection.\n");
            goto CLEANUP;
        case OPERATION_FAILURE:
            for(i = 0; i < jsGetNumberOfErrorMessages(jc); i++)
                printf("%s\n", jsGetErrorMessage(jc, i));
            break;
        default:
            printf("Sent parameters successfully.\n");
    }

CLEANUP:
    jsCloseConnection(jc);
    jc = NULL;
    return 0;
}


Functions

JCAM_DLL_API int STDCALL jsSendParameterFileToScanner (JCONNECTION const jc, char const *const filename)
 Sends a parameter file to the scanhead.
JCAM_DLL_API int STDCALL jsSendParametersToScanner (JCONNECTION const jc, char const *const parameters)
 Sends parameters to the scanhead.
JCAM_DLL_API int STDCALL jsGetParameterFileFromScanner (JCONNECTION const jc, char const *const filename)
 Reads the current parameter file from the scanhead and writes them to the specified file.
JCAM_DLL_API size_t STDCALL jsGetNumberOfErrorMessages (JCONNECTION const jc)
 Returns the number of error messages after a jsSendParameterFileToScanner() call returned OPERATION_FAILURE.
JCAM_DLL_API char const *const
STDCALL 
jsGetErrorMessage (JCONNECTION const jc, size_t i)
 Returns the specified error message.

Function Documentation

JCAM_DLL_API int STDCALL jsSendParameterFileToScanner ( JCONNECTION const   jc,
char const *const   filename 
)

Sends a parameter file to the scanhead.

If OPERATION_FAILURE is returned, the error messages should be checked using jsGetNumberOfErrorMessages() and jsGetErrorMessage(). The error messages are stored inside the opaque JCONNECTION.

See also:
jsGetErrorMessage()

jsSendParametersToScanner()

jsGetNumberOfErrorMessages()

jsGetParameterFileFromScanner()

Parameters:
jc The connection to the scanner.
filename The name of the file to send to the scanner.
Returns:
0 on success.

SCANNER_FAILURE on all connection failures.

OPERATION_FAILURE on all other failures, including parse and file I/O errors.

JCAM_DLL_API int STDCALL jsSendParametersToScanner ( JCONNECTION const   jc,
char const *const   parameters 
)

Sends parameters to the scanhead.

If OPERATION_FAILURE is returned, the error messages should be checked using jsGetNumberOfErrorMessages() and jsGetErrorMessage(). The error messages are stored inside the opaque JCONNECTION.

See also:
jsGetErrorMessage()

jsGetNumberOfErrorMessages()

jsSendParameterFileToScanner()

jsGetParameterFileFromScanner()

Parameters:
jc The connection to the scanner.
parameters A NULL-terminated string with the parameters to send to the scanner.
Returns:
0 on success.

SCANNER_FAILURE on all connection failures.

OPERATION_FAILURE on all other failures, including parse and file I/O errors.

JCAM_DLL_API int STDCALL jsGetParameterFileFromScanner ( JCONNECTION const   jc,
char const *const   filename 
)

Reads the current parameter file from the scanhead and writes them to the specified file.

See also:
jsSendParametersToScanner()

jsSendParameterFileToScanner()

Parameters:
jc the connection to the scanner.
filename The name of the file to save the parameters in. The file will be created if it doesn't exist.
Returns:
0 on success.

SCANNER_FAILURE on all connection failures.

OPERATION_FAILURE on all other failures.

JCAM_DLL_API size_t STDCALL jsGetNumberOfErrorMessages ( JCONNECTION const   jc  ) 

Returns the number of error messages after a jsSendParameterFileToScanner() call returned OPERATION_FAILURE.

See also:
jsGetErrorMessage()

jsSendParametersToScanner()

jsSendParameterFileToScanner()

Parameters:
jc The connection to the scanner.
Returns:
The number of error messages.

0 if jc is NULL.

JCAM_DLL_API char const* const STDCALL jsGetErrorMessage ( JCONNECTION const   jc,
size_t  i 
)

Returns the specified error message.

Do not modify the returned string.

See also:
jsSendParametersToScanner()

jsGetNumberOfErrorMessages()

jsSendParameterFileToScanner()

Parameters:
jc The connection to the scanner.
i The index of the error message to retrieve.
Returns:
A C string of the error message.

NULL if i is out of range or jc is NULL.