AdvancedHMI Software
General Category => Tips & Tricks => Topic started by: bachphi on March 16, 2025, 12:09:38 PM
-
Barcode scanners typically store scanned data in a SINT array.
In general, the data length can varies, a direct COPY without knowing its exact length is not feasible.
To transfer the barcode data from the SINT array to a STRING and set its length correctly:
After scanning, the FSC is used to locate the position of the last char in the SINT array.
If .FD is true, the position corresponds to STRING.LEN.
If it's not found & .DN is true [ie. Full string LEN], then Position + 1 determines STRING.LEN.
(https://i.postimg.cc/Dfc1HfVM/Copy-SINT-Array-to-STRING.png)
Next, Extract the content of BarcodeString to SerialNumber, PartNumber, ProductCode, PartCode using a delimiter such as 'Space'.
Noted that FIND can not find a NUL character.
(https://i.postimg.cc/FHDPSVWZ/Extract-String-using-Delimiter.png)
-
If you are using a PLC serial connection to communicate with the barcode reader,
First check the buffer for any available characters.
If data is present, read it into the BarcodeString.
Finally, clear the buffer to ensure it's ready for the next scan.
(https://i.postimg.cc/7ZKw0fQS/Serial-Port-Read.jpg)
-
If you're using an ASCII serial-to-Ethernet device like the RTA-435NBX to connect to the barcode reader, refer to this link for setup instructions.
https://www.advancedhmi.com/forum/index.php?topic=2695.0
If your RTA module is set up the Data Type as a SINT array instead of a STRING,
its length is stored in at index [[0] and the actual barcode data begins at index [2].
(https://i.postimg.cc/L473NTGs/RTA-Setup-As-SINTArray.jpg)