Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Write is not working for SINT and USINT (1 byte) datatype for Omron NX/NJ PLC #457

Open
ahmad9918 opened this issue Apr 19, 2024 · 1 comment

Comments

@ahmad9918
Copy link

Hello Kyle,

I am using libplctag library in order to read and write for SINT and USINT datatype for Omron NX/NJ plc . I have observed read is working as expected but while writing value for SINT and USINT tag, an extra byte is written into the PLC which results into error being returned in the response. I found an extra byte is getting written while analyzing wireshark log. In order to verify if an extra byte is causing problem I tried to modify the packet structure by removing the extra byte also adjusting the length of the buffer and sent using socket sample application. It resulted into proper response from the PLC with value getting written into the PLC.

Can you please share your thoughts on this issue and provide the fix for these datatypes.
Thanks

@kyle-github
Copy link
Member

I think I may have an idea here. I found these statements in another manual:

  • Omron’s NJ structure types use the natural alignment of their members, up to 64-bit, then pad
    the structure to the largest alignment of it the members. Which then becomes the structure’s
    natural alignment when nesting in other structures. Named booleans in NJ structures occupy
    and align to a complete 16-bit word of their own.
  • Omron’s CJ structure types use only 16-bit alignment, even for bytes and strings. Consecutive
    named booleans are packed into 16-bit words together, and in this library, must be hosted in a
    16-bit word.

Right now the library does not distinguish between CJ and NJ PLC types. That seems to be a problem due to alignment.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants