Repository navigation
Conversation
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
|
Thanks for this. I tested it on 20 projects: it stops the crash, but on the two public files that hit it, the tasks come out with blank settings. I've opened a small PR into your branch that recovers them: colinlove#1. Happy to adjust anything. |
This branch has not been deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
One Task record's whole binary layout doesn't match the known offsets (newer Studio/firmware version?)
Note: this patch touches the same file as 0004/0006/0008 and adds the
same
from loguru import logger as logimport each does. If applying morethan one of these to
acd/l5x/elements.pyat once, keep a single copy ofthat import line — see the top-level README's "Applying more than one
patch to the same file" note.
Symptom
aborting the entire export, on a file dated 2025 (i.e. likely a newer
Studio 5000 / firmware version than this comment in the source references:
"These offsets were reverse-engineered from CIPDemo_RevEng.ACD").
Root cause
TaskBuilder.build()reads a Task's scheduled-program list as au16count followed by N
u32comment_ids, at a fixed offset(
program_offset = 0x5A) within the record. On the file in question, thecount read back was 46563 (and, for a second task in the same file,
22458) against a sane maximum of ~1028 — clearly not a real count.
Investigating further: every other field read from this record's fixed
offsets is also wrong —
rate_us,type_val,priority, andwatchdog_us(at0x106C/0x10F6/0x10F8/0x110A) all read back as0, which is not a plausible task configuration. This isn't one corruptfield; the whole record's layout has shifted, most likely because this is
a genuinely different Task binary layout from a Studio/firmware version
newer than the one this code was reverse-engineered against.
Fix
This isn't a quick fix — recovering the real offsets for whatever layout
version this is requires the same kind of from-scratch reverse-engineering
as the rest of this file's fixed-offset table, which is out of scope for a
drop-in patch (no other example of this layout was available to
reverse-engineer against; if you can point at a second file with the same
shape, or the vendor documentation for the newer Task record format, this
could be finished properly). Instead, this degrades gracefully: when the
scheduled-program count exceeds the theoretical maximum for the field's
size, log a warning identifying the task and export it anyway with an
empty scheduled-program list, rather than failing the whole project's
export over one field of one task.
Suggested validation
If you have access to a project saved by a newer Studio 5000 / firmware
version than
CIPDemo_RevEng.ACDwas built with, dumping itsMainTask(or any Task) comps record and comparing byte-for-byte against a known-good
older one at the documented offsets would be the fastest way to find the
real offsets and turn this into a proper fix rather than a graceful
degradation. Happy to help gather more sample data if that would help —
see the top-level README for how to reach the author of this patch set.
🤖 Generated with Claude Code