D028868 CR1500 CR1100 CR2700 JavaScript Programming Guide User Manual Page 11 of 41
The Code Corporation
12393 South Gateway Park Place, Suite 600, Draper, UT 84020
+1 (801) 495-2200
FAX +1 (801) 495-0280
reader.onRawData(data, len)
The reader.onRawData property is called when the reader receives data in a non-packetized
stream, like a configuration command issued from the host console. The stream data comes
as individual characters and a count, and not necessarily as a complete string. Use the count
to assemble the string. You, as the user, must watch for the carriage return as it will be
passed as a normal character, as will all other control characters. Please note that the serial
comm channel is the command channel in serial mode. If you return true from your handler
you must not expect the system to handle normal serial commands, such as CFG. You may
watch for and replace commands (for example, replace 8x commands with the new 82x
commands) by sending the new command with a reader.configure(cmd) when you detect an
old command.
Example:
reader.onRawData = function(data, len)
{
if(len > 0)
comm.sendText(data);
else
return false;
return true;
}
reader.onConfigure(string config)
The onConfigure property of the Code reader calls the specified function when the reader:
Receives a configuration command from a communication port
Decodes a configuration command from a code read by the Code reader
The application uses this property as an event handler to:
Receive notification of command processing
Prevent execution of a command
The function will not be called in response to a reader.configure call.
Return 0 to instruct the reader to process the command, or return 1 to suppress the
command. When a command is suppressed, the firmware will not send any response to the
host, but the JavaScript application may provide its own response to the host.
The onConfigure property is a blocking call, which means other tasks, such as the
reader.tick1Hz or reader.periodic, aren’t guaranteed to work, if called within the
onConfigure property.
Example:
reader.onConfigure = function(confString)
{
if(confString.match(“JSJSG”) === null)
return false;
return true;
}