Skip to content
Merged
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
9 changes: 8 additions & 1 deletion GlueGenerator.py
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,14 @@ def __glue_logic(self, varName):
return f"lint_output_ptr[{pos1}] = (IEC_ULINT *){varName};"

elif kind == "M":
if sub == "W":
if sub == "X":
# %MX (bool memory) is only supported in OpenPLC v4
return (
f"#ifdef OPENPLC_V4\n"
f" bool_memory_ptr[{pos1}][{pos2}] = (IEC_BOOL *){varName};\n"
Copy link

Copilot AI Jan 6, 2026

Choose a reason for hiding this comment

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

The indentation in the generated code uses 4 spaces, but other cases in this function (lines 69-73) generate code without leading spaces. This inconsistency could lead to improperly formatted output. Consider removing the leading spaces from line 65 to match the pattern used by other memory types.

Suggested change
f" bool_memory_ptr[{pos1}][{pos2}] = (IEC_BOOL *){varName};\n"
f"bool_memory_ptr[{pos1}][{pos2}] = (IEC_BOOL *){varName};\n"

Copilot uses AI. Check for mistakes.
f"#endif"
)
elif sub == "W":
return f"int_memory_ptr[{pos1}] = (IEC_UINT *){varName};"
elif sub == "D":
return f"dint_memory_ptr[{pos1}] = (IEC_UDINT *){varName};"
Expand Down
21 changes: 21 additions & 0 deletions templates/glueVars.c.j2
Original file line number Diff line number Diff line change
Expand Up @@ -106,6 +106,9 @@ extern unsigned long long common_ticktime__;
static IEC_UINT *(*int_memory_ptr) = NULL;
static IEC_UDINT *(*dint_memory_ptr) = NULL;
static IEC_ULINT *(*lint_memory_ptr) = NULL;
#ifdef OPENPLC_V4
static IEC_BOOL *(*bool_memory_ptr)[8] = NULL;
#endif

void setBufferPointers(IEC_BOOL *input_bool[BUFFER_SIZE][8], IEC_BOOL *output_bool[BUFFER_SIZE][8],
IEC_BYTE *input_byte[BUFFER_SIZE], IEC_BYTE *output_byte[BUFFER_SIZE],
Expand All @@ -129,6 +132,24 @@ extern unsigned long long common_ticktime__;
dint_memory_ptr = dint_memory;
lint_memory_ptr = lint_memory;
}

#ifdef OPENPLC_V4
void setBufferPointers_v4(IEC_BOOL *input_bool[BUFFER_SIZE][8], IEC_BOOL *output_bool[BUFFER_SIZE][8],
IEC_BYTE *input_byte[BUFFER_SIZE], IEC_BYTE *output_byte[BUFFER_SIZE],
IEC_UINT *input_int[BUFFER_SIZE], IEC_UINT *output_int[BUFFER_SIZE],
IEC_UDINT *input_dint[BUFFER_SIZE], IEC_UDINT *output_dint[BUFFER_SIZE],
IEC_ULINT *input_lint[BUFFER_SIZE], IEC_ULINT *output_lint[BUFFER_SIZE],
IEC_UINT *int_memory[BUFFER_SIZE], IEC_UDINT *dint_memory[BUFFER_SIZE],
IEC_ULINT *lint_memory[BUFFER_SIZE], IEC_BOOL *memory_bool[BUFFER_SIZE][8])
{
// Call the base function to set all standard pointers
setBufferPointers(input_bool, output_bool, input_byte, output_byte,
input_int, output_int, input_dint, output_dint,
input_lint, output_lint, int_memory, dint_memory, lint_memory);
// Set the v4-specific bool_memory pointer
bool_memory_ptr = memory_bool;
}
#endif
#endif

void glueVars()
Expand Down
Loading