Corrected bug in TDF script where TargetRegisterGroup objects were not being constructed correctly

This commit is contained in:
Nav
2024-03-22 20:09:04 +00:00
parent 07019fb358
commit 57f56e634e

View File

@@ -271,6 +271,8 @@ class TargetDescriptionFile
$registerGroup = $this->resolveRegisterGroupInstance($registerGroupInstance, $peripheral->moduleKey); $registerGroup = $this->resolveRegisterGroupInstance($registerGroupInstance, $peripheral->moduleKey);
if ($registerGroup instanceof RegisterGroup) { if ($registerGroup instanceof RegisterGroup) {
$output->registerGroups[] = $this->targetRegisterGroupFromRegisterGroup( $output->registerGroups[] = $this->targetRegisterGroupFromRegisterGroup(
$registerGroupInstance->key,
$registerGroupInstance->name,
$registerGroup, $registerGroup,
$registerGroupInstance->offset ?? 0, $registerGroupInstance->offset ?? 0,
$peripheral->moduleKey $peripheral->moduleKey
@@ -282,15 +284,23 @@ class TargetDescriptionFile
} }
private function targetRegisterGroupFromRegisterGroup( private function targetRegisterGroupFromRegisterGroup(
string $key,
string $name,
RegisterGroup $registerGroup, RegisterGroup $registerGroup,
int $addressOffset, int $addressOffset,
string $moduleKey string $moduleKey
): TargetRegisterGroup { ): TargetRegisterGroup {
$addressOffset += $registerGroup->offset ?? 0; $addressOffset += $registerGroup->offset ?? 0;
$output = new TargetRegisterGroup($registerGroup->key, $registerGroup->name, $addressOffset, [], []); $output = new TargetRegisterGroup($key, $name, $addressOffset, [], []);
foreach ($registerGroup->subgroups as $subgroup) { foreach ($registerGroup->subgroups as $subgroup) {
$output->subgroups[] = $this->targetRegisterGroupFromRegisterGroup($subgroup, $addressOffset, $moduleKey); $output->subgroups[] = $this->targetRegisterGroupFromRegisterGroup(
$subgroup->key,
$subgroup->name,
$subgroup,
$addressOffset,
$moduleKey
);
} }
foreach ($registerGroup->subgroupReferences as $subgroupReference) { foreach ($registerGroup->subgroupReferences as $subgroupReference) {
@@ -298,6 +308,8 @@ class TargetDescriptionFile
if ($subgroup instanceof RegisterGroup) { if ($subgroup instanceof RegisterGroup) {
$output->subgroups[] = $this->targetRegisterGroupFromRegisterGroup( $output->subgroups[] = $this->targetRegisterGroupFromRegisterGroup(
$subgroupReference->key,
$subgroupReference->name,
$subgroup, $subgroup,
$addressOffset, $addressOffset,
$moduleKey $moduleKey