Details
Resolution: Implementing Dynamic Match String Validation via Script
Issue
The built-in MatchString Data Validation feature may not be usable if the code content contains unprintable characters. In such cases, an alternative approach is required to achieve equivalent functionality.
Solution
Dynamic Match String validation can be implemented through a script, with the expected data provided by a PLC before each decode cycle.
Sending the expected string
The expected data string is transmitted to the reader using a DMCC command. This can be done via:
Configuring the Input String object
To enable the Input String mechanism, both a header and a footer must be defined, even if they are not functionally used (as in the data stream method). These parameters become part of the reader configuration and can only be removed with a Reset to Factory Defaults.Example commands:
||>SET INPUT-STRING.HEADER "...."[CRLF]
||>SET INPUT-STRING.FOOTER "...."[CRLF]- Use an unlikely combination of characters for “.....” (e.g., §%(/).
Transmitting the expected value
The PLC (or host system) then sends the expected string before each decode:
||>SET INPUT-STRING.VALUE "abcxyz"[CRLF]
Script for validation
On the reader, insert the following script under Script Based Formatting:
function onResult (decodeResults, readerProperties, output)
{
if (decodeResults[0].decoded)
{
var inStr = readerProperties.inputstr;
var readRes = decodeResults[0].content;if (inStr != readRes)
output.events.system = Event.system.validationFailure;output.content = decodeResults[0].content;
}
}
Result
If the decoded result does not match the input string provided by the PLC, the reader triggers the ValidationFailure event. This provides a reliable, script-based replacement for MatchString validation in environments where unprintable characters prevent the use of the built-in feature.