.checksum Method

Function:

Calculates and writes into the RAM buffer, or verifies the checksum for the data in the currently selected RAM buffer of the flash memory (selection is made through the fd.buffernum property).

Syntax:

fd.checksum(mode as pl_fd_csum_mode, byref csum as word) as ok_ng

Returns:

0 — OK: Completed successfully (always the case when mode = 1 — PL_FD_CSUM_MODE_CALCULATE).

1 — NG: The checksum was found to be invalid (can only be generated when mode = 0 — PL_FD_CSUM_MODE_VERIFY).

Also returns the calculation result indirectly, through the csum argument.

See Also:

Using Checksums, Direct Sector Access, fd.buffernum, fd.getbuffer, fd.setbuffer, fd.getsector, fd.setsector, fd.copyfirmware, fd.copyfirmwarelzo


Part

Description

mode

0 — PL_FD_CSUM_MODE_VERIFY: verify the checksum.

1 — PL_FD_CSUM_MODE_CALCULATE: calculate the checksum and store it into the selected RAM buffer.

csum

Indirectly returns calculated value. When mode = 0 — PL_FD_CSUM_MODE_VERIFY, this value returned will be 0 if the checksum was found to be correct, or some other value if the checksum was found to be wrong. When mode = 1 — PL_FD_CSUM_MODE_CALCULATE, the method will return a newly calculated checksum and store the same checksum into the RAM buffer.