To guard against buffer overrun issues it’s best to specify a maximum length in the protocol entry:
Or, if the input terminator is set to a single ‘\r’ or ‘\n’ and the device sends a "\r\n” you could use: read_raw { in “%39[^\r\n]"; }
I have the bar code scanner, so, the string input is the arbitrary ascii and numbers from bar codes, generated by myself, whenever I scan it.
For example,
case 1 : user,123456789,U002C007 case 2 : ABCDEFGHIZ0123456789 case 3 : office,248795493,M01B21 case 4 : ....
case N : SUBMIT
Note that case 1..N-1 can be done without order.
The scanner has a typical RS232 connection. I wrote the very simple IOC with asyn and Stream. It has only one record and one function in db and proto file as follows:
--- snip snip ---
record(stringin, "$(SYSDEV)RawScanData") { field(DESC, "RAW Scanned data") field(DTYP, "stream") field( INP, "@scanner.proto read_raw $(PORT)") field(SCAN, "I/O Intr") field(PINI, "YES") }
read_raw { in "%s"; } --- snip snip ----------
Is this enough?
Thanks, Han
|