[ Pobierz całość w formacie PDF ]

{
printf("\nERROR: OC_DownloadIOConfiguration failed: %d\n", rc);
Configure
Ioexit(1);
the scanner
}
See page
6-11.
Publication 1747-6.5.3 June 1998
Developing Applications 3 17
/* Set output update mode to always */
if (SUCCESS != (rc = OC_SetOutputUpdateMode(OChandle, OUTUPD_ALWAYS)))
{
printf("\nERROR: OC_SetOutputUpdateMode failed: %d\n", rc);
Ioexit(1);
}
/* Set scan time to 5ms, periodic scan mode */
Control scanner
if (SUCCESS != (rc = OC_SetScanTime(OChandle, SCAN_PERIODIC, 20)))
operation
{
See pages 6-70
printf("\nERROR: OC_SetScanTime failed: %d\n", rc);
and 6-73.
Ioexit(1);
}
/* Goto Scan Mode */
if (SUCCESS != (rc = OC_SetScanMode(OChandle, SCAN_RUN)))
{
printf("\nERROR: OC_SetScanMode failed: %d\n", rc);
Ioexit(1);
}
/* Turn on User LED 1 */
if (SUCCESS != (rc = OC_SetUserLEDState(OChandle, 1, LED_GREEN_SOLID)))
{
printf("\nERROR: OC_SetUserLEDState failed: %d\n", rc);
Ioexit(1);
}
/* Read word 0 of IB32 module */
if ( IB32slot != 0 )
{ if (SUCCESS != (rc = OC_ReadInputImage(OChandle, NULL, IB32slot, 0, 1, &wData)))
{
printf("\nERROR: OC_ReadInputImage failed: %d\n", rc);
Ioexit(1);
} }
Scan I/O
See pages
/* Write the data read to word 2 of BAS module M0 file */
6-54 and
wLen = 1; if ( BASslot != 0 )
6-88.
{
if (SUCCESS != (rc = OC_WriteModuleFile(OChandle, FILTYP_M0, &wData, BASslot,
2, wLen)))
{
printf("\nERROR: OC_WriteModuleFile failed: %d\n", rc);
Ioexit(1);
}
}
/* Close the scanner before exiting */
OC_CloseScanner(OChandle);
return(0);
} /* end main()*/
Publication 1747-6.5.3 Junel 1998
3 18 Developing Applications
Handling Interrupt Modules that communicate via discrete input interrupts or module interrupts require
special attention. The API buffers these interrupts internally until they are extracted
Messages
via OC_PollScanner. The internal message buffer can hold as many as 5 messages.
If the message buffer is full, the oldest message in the buffer is overwritten by the
next message. Interrupts will be missed if OC_PollScanner is not called by the
application more often than interrupts are received.
For Windows NT, use the OC_WaitForxxx functions.
Handling Errors Every function call returns a status code for the function. Check this status code
before using the data returned by the function. The scanner reports faults and other
errors via messages. The API library buffers these errors internally and reports their
existence as an Extended Error. The application must periodically call
OC_GetExtendedError to determine if an extended error message exists.
The library buffers extended errors in a queue. The queue can hold as many as 5
extended errors at one time. If the queue is full when a new extended error is received
from the scanner, the oldest extended error is lost and ERR_OCOVERRUN is
returned. The host application must call OC_GetExtendedError periodically to
remove existing extended errors from the buffer.
Extended Errors cause the scanner to fault. Once the scanner is faulted, it is forced
to Idle mode and cannot go to Scan mode until the Extended Errors are extracted
via OC_GetExtendedError and the fault is cleared via OC_ClearFault. For Windows
NT, use the OC_WaitForExtError function.
Determining The host application initializes the scanner by providing partitioning information,
which contains the size of memory to be reserved in the shared memory for the
Partition Sizes for
input and output images. The size of memory to be reserved for each of the images
Shared Memory
must be greater than or equal to the number of input and output words required by
each module. The host application can t communicate with the scanner until it has
been initialized.
The partitioning information is passed to OC_InitScanner in the OCINIT structure,
which is defined as:
typedef struct tagOCINIT {
WORD OutputImageSize; /* size in bytes */
WORD InputImageSize; /* size in bytes */
WORD HostRetentiveDataSize; /* size in bytes */
} OCINIT;
Publication 1747-6.5.3 June 1998
Developing Applications 3 19
To determine the input and output image sizes, call OC_CreateIOConfiguration
with a configuration that contains the I/O modules to be installed.
OC_CreateIOConfiguration returns the number of bytes of I/O required by each
module. Or you can use OC_GetIOConfig to use the current configuration, if one
exists. The input and output sizes are based on the number of words of I/O required
by each module. As an estimate, take the total number of input and output words
for all the modules in the system and multiply by two to get the number of required
bytes. The following code fragment calculates the number of bytes required by the
input and output images:
OCINIT initinfo;
OCIOCFG iocfg;
int i,numslots;
/* assuming application has filled iocfg with I/O configuration */
OC_CreateIOConfiguration(&iocfg);
numslots = iocfg.Rack1Size + iocfg.Rack2Size + iocfg.Rack3Size;
if ( numslots > 31 ) numslots = 31;
initinfo.OutputImageSize = initinfo.InputImageSize = 0;
for ( i=1 ; i
initinfo.OutputImageSize += ((iocfg.SlotCfg[i].OutputSize+1) / 2) * 2;
initinfo.InputImageSize += ((iocfg.SlotCfg[i].InputSize+1) / 2) * 2;
}
Any remaining shared memory can be allocated for host retentive data, which is the
portion of the dual port RAM that you can use to store data in case power fails. If
the application doesn t need host retentive data, set its size to 0. If the application
needs host retentive data, the application can determine the amount of memory
available by using the OCSEGMENTSIZELIMIT constant.
This constant specifies the total number of bytes available for the three segment
sizes. To calculate the maximum memory available for the host retentive data, use
this formula:
initinfo.HostRetentiveDataSize =
OCSEGMENTSIZELIMIt - initinfo.OutputImageSize - initinfo.InputImageSize;
If the I/O configuration changes and causes the image sizes to change, the maximum
memory available for Host Retentive Data will change accordingly, and information
stored in the Host Retentive Data memory may be overwritten. [ Pobierz całość w formacie PDF ]
  • zanotowane.pl
  • doc.pisz.pl
  • pdf.pisz.pl
  • rafalstec.xlx.pl