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

Checking the Scanner Status


Detailed Description

The order of operations here is important.
  1. jsGetScannerStatusFromScanner()
  2. jsGetScannerStatusValue()

Here are the valid indexes:

  1. DSP Version Code
  2. Mode: 0-Init, 1-Idle, 2-Expose, 3-Scan
  3. Host Request: 0-None, 1-Scan Cam, 2-Laser Scan
  4. Current Camera Exposure Time
  5. Current Laser On Time
  6. Current Encoder Count
  7. Optically Isolated Inputs
  8. Results of Last Host Interface Communication
  9. Dark Pixel Value
  10. Current Bias (offset)
  11. End Code
  12. Scan Server Version
  13. Serial Number

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

using namespace joescan;

int main(int argc, char * argv[])
{
    JCONNECTION jc;

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

    switch(jsGetScannerStatusFromScanner(jc))
    {
        case INVALID_PARAMETER:
            printf("Invalid Parameter.\n");
            goto CLEANUP;
        case SCANNER_FAILURE:
            printf("Scanner Failure in jsGetScannerStatusFromScanner ().\n");
            goto CLEANUP;
        default:
            printf("Got status from scanner.\n");
            break;
    }

    size_t i = 0;
    int value;
    char statusDescription[128];

    bool finished = false;
    while(finished == false)
    {
        switch(jsGetStatusDescriptionFromScanner(jc, i, statusDescription, 128))
        {
            case INVALID_PARAMETER:
                printf("Invalid Parameter.\n");
                break;
            case SCANNER_FAILURE:
                printf("Scanner Failure in jsGetStatusDescriptionFromScanner().\n");
                goto CLEANUP;
            default:
                break;
        }

        switch(jsGetScannerStatusValue (jc, i, &value))
        {
            case INVALID_PARAMETER:
                printf("%2d Invalid parameter -- Out of bounds index.\n", i);
                finished = true;
                break;
            default:
                printf("%2d %s %d\n", i, statusDescription, value);
                break;
        }
        ++i;
    }

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


Functions

JCAM_DLL_API int STDCALL jsGetScannerStatusFromScanner (JCONNECTION const jc)
 Reads status from the scanner into a data structure inside the opaque JCONNECTION.
JCAM_DLL_API int STDCALL jsGetScannerStatusValue (JCONNECTION const jc, size_t i, int *value)
 Gets the specified status value from the data structure inside the JCONNECTION.
JCAM_DLL_API int STDCALL jsGetStatusDescriptionFromScanner (JCONNECTION const jc, UINT32 i, char *const description, UINT32 description_length)
 Reads a descriptive text string from the scanner for the particular status index.

Function Documentation

JCAM_DLL_API int STDCALL jsGetScannerStatusFromScanner ( JCONNECTION const   jc  ) 

Reads status from the scanner into a data structure inside the opaque JCONNECTION.

See also:
jsGetScannerStatusValue()

jsGetStatusDescriptionFromScanner()

Parameters:
jc The connection to the scanner.
Returns:
0 on success.

INVALID_PARAMETER if jc is NULL.

SCANNER_FAILURE if the connection closes.

JCAM_DLL_API int STDCALL jsGetScannerStatusValue ( JCONNECTION const   jc,
size_t  i,
int *  value 
)

Gets the specified status value from the data structure inside the JCONNECTION.

See also:
jsGetScannerStatusFromScanner()

jsGetStatusDescriptionFromScanner()

Parameters:
jc The connection to the scanner.
i The index of the status value to retrieve.
value Pointer to an int that will hold the value.
Returns:
0 on success.

INVALID_PARAMETER if jc or value is NULL, or if i is out of range.

JCAM_DLL_API int STDCALL jsGetStatusDescriptionFromScanner ( JCONNECTION const   jc,
UINT32  i,
char *const   description,
UINT32  description_length 
)

Reads a descriptive text string from the scanner for the particular status index.

The description length should be a minimum of 128 characters. After this call, description will be properly null-terminated. If description isn't long enough, the result will be truncated, but still properly null-terminated. The first valid index is 0, the last valid index is 12.

Invalid indexes will return the string "ERROR unsuported status type".

See also:
jsGetScannerStatusValue()

jsGetScannerStatusFromScanner()

Parameters:
jc The connection to the scanner.
i The index of the status name to retrieve.
description The character buffer that will contain the status name.
description_length The number of characters that description points to.
Returns:
0 on success.

INVALID_PARAMETER if jc or description is NULL, or if i is out of range.

SCANNER_FAILURE if the connection closes.