PC/SC: Remove version parsing algorithm (#486)

This commit is contained in:
Michał Leszczyński
2025-12-16 21:28:13 +01:00
committed by GitHub
parent e5216c2f8a
commit fbaeb733f7
2 changed files with 9 additions and 46 deletions

View File

@@ -156,48 +156,20 @@ function makeOptions(reader: Reader): ExecHaloCmdOptions {
async function execHaloCmdPCSC(command: HaloCommandObject, reader: Reader) {
await selectCore(reader);
const version = await getVersion(reader);
const [verMajor, verMinor, verSeqStr, verShortId] = version.split('.');
const verMajorNum = parseInt(verMajor, 10);
const verSeq = parseInt(verSeqStr, 10);
if (verMajorNum > 1) {
throw new HaloLogicError("This version of CLI doesn't support major release version " + verMajor + ". Please update.");
}
const options = makeOptions(reader);
command = {...command};
if (command.name === "version") {
// PCSC-specific version retrieval command
const version = await getVersion(reader);
const addonVersion = await getAddonVersion(reader);
let addonParts = null;
if (addonVersion) {
const [verAMajor, verAMinor, verASeqStr, verAShortId] = addonVersion.split('.');
const verASeq = parseInt(verASeqStr, 10);
addonParts = {
verAMajor,
verAMinor,
verASeq,
verAShortId
};
}
return {
"core": {
"ver": version,
"parts": {
verMajor,
verMinor,
verSeq,
verShortId
}
"ver": version
},
"addons": {
"ver": addonVersion,
"parts": addonParts
"ver": addonVersion
}
};
} else if (command.name === "read_ndef") {

View File

@@ -935,29 +935,20 @@ This command doesn't accept any arguments.
### Return value
* `version` (str) - full version string;
* `parts.verMajor` (int) - major version number;
* `parts.verMinor` (str) - minor version identifier;
* `parts.verSeq` (int) - minor version sequential number;
* `parts.verShortId` (str) - unique identifier;
**Note:** Comparing versions: All versions are sortable on `(verMajor, verSeq)` pair.
The version with higher `verMajor` is always more recent than the version with lower `verMajor` value.
If two versions have the same `verMajor` value, the version with the higher `verSeq` is always more recent.
* `core.ver` (str) - full version string;
* `addons.ver` (str) - reserved;
### Examples
Command:
```json
{
"name": "version"
}
```
halocli version
```
Response:
```json
{
"version": "01.C5.000083.633916E1",
"parts": { "verMajor": 1, "verMinor": "C5", "verSeq": 83, "verShortId": "633916E1" }
"core": { "ver": "HWV1.000026.0D97E811" },
"addons": { "ver": "HWV1.000026.0D97E811" }
}
```