You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I haven't seen activity for the project for 4 years at this point so I decided to implement the LGX string type on my own. For anyone interested following is my solution:
In the cip data-types add the following data type to the array: LGXSTR: 0x2a0
Next go to parseReadMessageResponseValueForAtomic and add LGXSTR to the types: const { SINT, INT, DINT, REAL, BOOL, LGXSTR } = Types;
Then add the case for it in the switch statement:
case LGXSTR: // struct for string
var len = data.readUInt32LE(4);
this.controller_value = "";
for(var i = 0; i < len; i++)
{
// LGX string header = 8 bytes
this.controller_value += String.fromCharCode(data[8+i]);
}
break;
There may be a better way to convert the bytes to string so feel free to modify as needed. If you create custom string lengths then you will may need to modify this in order to accomodate the size.
find generateWriteMessageRequestForAtomic and add LGXSTRZ to the types: const { SINT, INT, DINT, REAL, BOOL, LGXSTR } = Types;
Finally add the following case to the switch statement:
case LGXSTR: // LGX string
// override size with struct handle in header
buf.writeUint16LE(0x0FCE,2);
// string struct is a total of 90 by default
var header = Buffer.alloc(6);
header.writeInt16LE(1); // writing only one string
header.writeInt32LE(tag.value.length,2); // length of string
valBuf = Buffer.alloc(84); // standard string length
valBuf.write(tag.value);
buf = Buffer.concat([buf,header,valBuf]);
break;
Again, if you use strings that are not the default size you may need to make changes in order to accommodate it. We never use anything but the default size at work and so I have no need to accommodate anything else.
Hi, how to read and write string values to AB Compact /Control Logix it seems types does not have a string datatype
The text was updated successfully, but these errors were encountered: