Oc_writesram -92 – Rockwell Automation 1747-PCINT API Software for 1746 I/O User Manual
Page 146

6–92
Library of Routines
OC_WriteSRAM
Publication 1747-6.5.3 June 1998
OC_WriteSRAM
OC_WriteSRAM wires data to the battery-backed user memory
Syntax:
int OC_WriteSRAM(HANDLE Handle, BYTE*bufptr, DWORD offset, DWORD length);
Description:
The battery-backed memory may be used to store important data that needs to be preserved in the event of
a power failure. The size of the available memory in bytes may be obtained using OC_GetDeviceInfo.
Important:
It is recommended that the integrity of data stored in the user memory
be verified by some means. The OC_CalculateCRC function may be
used to generate a 16-bit CRC that may be used for this purpose.
handle
must be a valid handle returned from OC_OpenScanner.
bufptr
points to the data to be written.
offset
specifies the offset within the memroy to begin writing.
length
specifiies the number of bytes
to be written.
If
offset
+
length
points past the end of the memory, no bytes will be written and ERR_OCPRAM
will be returned.
Return Value:
Considerations:
Supported in the Windows NT API library only.
Example:
Byte
buf[100];
/*buffer of important data*/
Word crc;
HANDLE handle;
/* Save 100 bytes of data to offset 0 in SRAM */
OC_WriteSRAM(handle, buf, 0, 100);
/* Calculate CRC */
OC_CalculateCRC(buf, 100, &crc);
/* Write data CRC to offset 100 in SRAM */
OC_WriteSRAM(handle, &crc, 100, 2);
Name:
Description:
SUCCESS
data was written successfully
ERR_OCACCESS
handle
does not have access to scanner
ERR_OCPARAM
offset+length
points past the end of the memory