Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).

[unreleased]
### Changed
- **Javadoc**: clarified write contract for `prepareWriteBlocks` and `prepareSt25WriteSystemBlock`.
Comment on lines +8 to +9
Copy link

Copilot AI Apr 8, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The changelog entry says the Javadoc clarification is limited to prepareWriteBlocks and prepareSt25WriteSystemBlock, but this PR also changes the higher-level processCommands() write contract (memory image update semantics) and removes text from the deprecated prepareWriteSystemBlock docs. Please adjust this entry to reflect the full scope of the documentation changes (or narrow the code changes to match the entry).

Copilot uses AI. Check for mistakes.

## [1.2.0] - 2026-03-18
### Added
Expand Down
2 changes: 1 addition & 1 deletion gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
group = org.eclipse.keypop
title = Keypop Storage Card Java API
description = API defining the needed interfaces to manage storage cards
version = 1.2.0-SNAPSHOT
version = 1.2.1-SNAPSHOT

# Java Configuration
javaSourceLevel = 1.8
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,10 +39,10 @@
* <p><strong>For read commands:</strong> The {@link StorageCard} memory image is updated with the
* data retrieved from the card.
*
* <p><strong>For write commands:</strong> The {@link StorageCard} memory image is <strong>not
* updated</strong> even when the command appears successful, as some storage card technologies do
* not provide reliable confirmation of write completion. Applications should perform explicit read
* operations after writes to verify the actual card content and update the memory image.
* <p><strong>For write commands:</strong> The {@link StorageCard} memory image is updated with the
* written data once the write is confirmed successful. For card technologies that do not provide
* reliable status codes (e.g. ST25/SRT512), confirmation is obtained via an automatic verification
* read; the memory image is updated only if this verification passes.
Comment on lines +42 to +45
Copy link

Copilot AI Apr 8, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The class-level Javadoc now states that the StorageCard memory image is updated for write commands once the write is confirmed, but the deprecated prepareWriteSystemBlock(byte[]) Javadoc below still says the memory image is not automatically updated (lines 81-85). Please reconcile these contracts (e.g., clarify that only certain write operations update the memory image, or update the deprecated method’s documentation accordingly) to avoid conflicting guidance for API consumers.

Copilot uses AI. Check for mistakes.
*
* <p>The process is interrupted at the first failed command.
*
Expand Down Expand Up @@ -78,12 +78,6 @@ public interface StorageCardTransactionManager
*
* <p>The data length must match the block size defined by the card's {@link ProductType}.
*
* <p><strong>Important:</strong> After execution of this write command, the {@link StorageCard}
* memory image is <strong>not automatically updated</strong>. Some storage card technologies do
* not provide reliable status codes to confirm successful write operations. To ensure data
* consistency, an explicit read operation must be performed after the write to refresh the memory
* image and verify the actual content stored on the card.
*
* @param data The data to be written to the system block. The length must match the card's block
* size.
* @return The current instance.
Expand Down Expand Up @@ -122,14 +116,17 @@ public interface StorageCardTransactionManager
*
* <p>The data length must match the block size defined by the card's {@link ProductType}.
*
* <p><strong>Important:</strong> After execution of this write command, the {@link StorageCard}
* memory image is <strong>not automatically updated</strong>. ST25/SRT512 cards do not provide
* reliable status codes to confirm successful write operations. To ensure data consistency, an
* explicit read operation must be performed after the write to refresh the memory image and
* verify the actual content stored on the card.
* <p><strong>Important:</strong> It is the user's responsibility to ensure that the write
* operations are coherent with the target card's technology (e.g., OTP bits). The data provided
* must represent the <b>expected final state</b> of the system block after the write operation.
*
* @param data The data to be written to the system block. The length must match the card's block
* size.
* <p>ST25/SRT512 cards do not provide reliable status codes to confirm successful write
* operations. Consequently, the library performs an automatic verification read. This check will
* fail if the physical state of the system block after the write does not exactly match the
* provided data.
Comment on lines +123 to +126
Copy link

Copilot AI Apr 7, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The updated contract says the library performs an automatic verification read after some writes, but the interface-level note above still states that for write commands the StorageCard memory image is not updated and that applications should perform explicit reads after writes. Please reconcile these docs by clarifying whether the verification read (a) updates the StorageCard memory image or (b) is only an internal comparison. Also consider stating what the caller should expect during processCommands() when verification fails (e.g., whether it throws SCCardCommunicationException, per that exception’s Javadoc), so users know how to handle the failure.

Copilot uses AI. Check for mistakes.
*
* @param data The data to be written to the system block (expected final state). The length must
* match the card's block size.
* @return The current instance.
* @throws IllegalArgumentException If data is null or its length does not match the block size.
* @throws UnsupportedOperationException If the current card type is not ST25/SRT512.
Expand Down Expand Up @@ -180,15 +177,18 @@ public interface StorageCardTransactionManager
* array divided by the block size of the storage card. The block size is provided by {@link
* ProductType#getBlockSize()}.
*
* <p><strong>Important:</strong> Some storage card technologies do not provide reliable status
* codes to confirm successful write operations. For such cards (e.g., SRT512/ST25), the library
* automatically performs a verification read after each write to ensure that the data has been
* correctly stored. For cards that provide a reliable write acknowledgment, no additional read is
* performed. In all cases, the library guarantees the integrity of the written data, and the
* application does not need to explicitly perform verification reads.
* <p><strong>Important:</strong> It is the user's responsibility to ensure that the write
* operations are coherent with the target card's technology (e.g., OTP bits, counters). The data
* provided must represent the <b>expected final state</b> of the blocks after the write
* operation.
*
* <p>For cards that do not provide reliable status codes (e.g., SRT512/ST25), the library
Copy link

Copilot AI Apr 8, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Card family naming is inconsistent in this Javadoc (ST25/SRT512 vs SRT512/ST25). Please standardize the order across the file to keep the public API documentation searchable and unambiguous (ideally match ProductType.ST25_SRT512).

Suggested change
* <p>For cards that do not provide reliable status codes (e.g., SRT512/ST25), the library
* <p>For cards that do not provide reliable status codes (e.g., ST25/SRT512), the library

Copilot uses AI. Check for mistakes.
* performs an automatic verification read. This check will fail if the physical state of the card
* after the write does not exactly match the provided data. For cards providing reliable
* acknowledgment, no additional read is performed.
Comment on lines +186 to +188
Copy link

Copilot AI Apr 7, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This Javadoc describes an automatic verification read for cards without reliable write status codes, which conflicts with the interface-level note stating that applications should perform explicit reads after writes and that the StorageCard memory image is not updated for write commands. Please align these two pieces of documentation and clarify whether the verification read updates the StorageCard memory image or is only used for internal comparison during processCommands().

Suggested change
* performs an automatic verification read. This check will fail if the physical state of the card
* after the write does not exactly match the provided data. For cards providing reliable
* acknowledgment, no additional read is performed.
* performs an automatic verification read during {@link #processCommands(ChannelControl)} for
* internal comparison with the provided data. This check will fail if the physical state of the
* card after the write does not exactly match the expected final state. This verification read
* does <strong>not</strong> update the {@link StorageCard} memory image; applications must
* prepare an explicit read command after the write if they need to refresh the memory image. For
* cards providing reliable acknowledgment, no additional verification read is performed.

Copilot uses AI. Check for mistakes.
*
* @param fromBlockAddress The offset from which the blocks will be written.
* @param data The data to be written to the storage card.
* @param data The data to be written to the storage card (expected final state).
* @return The current instance of the {@link StorageCardTransactionManager}.
* @throws IllegalArgumentException If data is null or its length is not a multiple of the block
* size.
Expand Down
Loading