Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
return Buffer.from(message.substr(idx+regMessage[1].length), 'hex');
}
return null;
}
if (this.options.debug === 2) this.options.logger('SML MESSAGE: ' + smlFile.toString());
var result = {};
var crcCheck = true; // we ignore whole-Message CRC (smlFile.valid;) only check detail CRCs
if (crcCheck) {
for (var msg in smlFile.messages) {
if (smlFile.messages[msg].getMessageTag() === OpenSml.Constants.GET_LIST_RESPONSE) {
crcCheck &= smlFile.messages[msg].isValid();
if (smlFile.messages[msg].isValid()) Object.assign(result, this.prepareResult(smlFile.messages[msg].getMessageBody().getValList()));
}
else if (smlFile.messages[msg].getMessageTag() === OpenSml.Constants.GET_PROFILE_LIST_RESPONSE) {
crcCheck &= smlFile.messages[msg].isValid();
if (smlFile.messages[msg].isValid()) Object.assign(result, this.prepareResult(smlFile.messages[msg].getMessageBody().getPeriodList()));
}
}
}
if (Object.keys(result).length === 0) {
if (!crcCheck) {
if (!this.options.protocolSmlIgnoreInvalidCRC) {
smlFile = null;
this.callUserCallback(new Error('Message CRC-Check invalid -> no data available'), null);
if (idx !== -1) {
return Buffer.from(message.substr(idx+regMessage[1].length), 'hex');
}
return null;
}
else {
catch (err) {
smlFile = null;
this.callUserCallback(new Error('Error while parsing SML message: ' + err + ': Message: ' + regMessage[1]), null);
if (idx !== -1) {
return Buffer.from(message.substr(idx+regMessage[1].length), 'hex');
}
return null;
}
if (this.options.debug === 2) this.options.logger('SML MESSAGE: ' + smlFile.toString());
var result = {};
var crcCheck = true; // we ignore whole-Message CRC (smlFile.valid;) only check detail CRCs
if (crcCheck) {
for (var msg in smlFile.messages) {
if (smlFile.messages[msg].getMessageTag() === OpenSml.Constants.GET_LIST_RESPONSE) {
crcCheck &= smlFile.messages[msg].isValid();
if (smlFile.messages[msg].isValid()) Object.assign(result, this.prepareResult(smlFile.messages[msg].getMessageBody().getValList()));
}
else if (smlFile.messages[msg].getMessageTag() === OpenSml.Constants.GET_PROFILE_LIST_RESPONSE) {
crcCheck &= smlFile.messages[msg].isValid();
if (smlFile.messages[msg].isValid()) Object.assign(result, this.prepareResult(smlFile.messages[msg].getMessageBody().getPeriodList()));
}
}
}
if (Object.keys(result).length === 0) {
if (!crcCheck) {
if (!this.options.protocolSmlIgnoreInvalidCRC) {
smlFile = null;
this.callUserCallback(new Error('Message CRC-Check invalid -> no data available'), null);
if (idx !== -1) {
return Buffer.from(message.substr(idx+regMessage[1].length), 'hex');