When we check the length of a binary field, we compare the binary length directly with the length of the incoming value, which is in hex.
if (this_format.ContentType === 'b') {
if (this_format.MaxLen === this.Msg[field].length) { // this.Msg[field] is in hex format and this_format.MaxLen is in bytes
const size = this_format.MaxLen / 2;
const thisBuff = Buffer.alloc(size, this.Msg[field], 'hex');
buff = Buffer.concat([buff, thisBuff]);
...
This should be
if (this_format.ContentType === 'b') {
if (this_format.MaxLen * 2 === this.Msg[field].length) { // multiplied with 2 to make a byte with couple of hex characters
const size = this_format.MaxLen / 2;
const thisBuff = Buffer.alloc(size, this.Msg[field], 'hex');
buff = Buffer.concat([buff, thisBuff]);
...
Let me know if any further details necessary
When we check the length of a binary field, we compare the binary length directly with the length of the incoming value, which is in hex.
This should be
Let me know if any further details necessary