Cognex DataMan 370 Series Programming Manual

Cognex DataMan 370 Series Programming Manual

Hide thumbs Also See for DataMan 370 Series:

Advertisement

Quick Links

DataMan
and Programming Guide
2022 December 22
Revision: 6.1.14.3
®
Communications

Advertisement

Table of Contents
loading
Need help?

Need help?

Do you have a question about the DataMan 370 Series and is the answer not in the manual?

Questions and answers

Subscribe to Our Youtube Channel

Summary of Contents for Cognex DataMan 370 Series

  • Page 1 ® DataMan Communications and Programming Guide 2022 December 22 Revision: 6.1.14.3...
  • Page 2: Legal Notices

    Copyright © 2022. Cognex Corporation. All Rights Reserved. Portions of the hardware and software provided by Cognex may be covered by one or more U.S. and foreign patents, as well as pending U.S. and foreign patents listed on the Cognex web site at: cognex.com/patents.
  • Page 3: Table Of Contents

    Table of Contents Table of Contents Legal Notices Table of Contents Symbols About This Manual Networking Connecting Your DataMan to the Network Connecting Your Fixed-Mount DataMan Reader to the Network Connecting Your Handheld DataMan Reader to the Network Connecting Your DataMan Intelligent Base Station to the Network Direct Connection to Your Computer Connecting Your Reader Across Subnets Troubleshooting a Network Connection...
  • Page 4: Symbols

    Symbols Symbols The following symbols indicate safety precautions and supplemental information: WARNING: This symbol indicates a hazard that could cause death, serious personal injury or electrical shock. CAUTION: This symbol indicates a hazard that could result in property damage. Note: This symbol indicates additional information about a subject. Tip: This symbol indicates suggestions and shortcuts that might not otherwise be apparent.
  • Page 5: About This Manual

    About This Manual About This Manual The DataMan Communications and Programming Guide provides information on how to integrate DataMan readers into your particular environment, including: Network configuration DataMan Control Commands (DMCC) API The DataMan reader connected to a network can be triggered to acquire images by several methods: using the DataMan Setup Tool ...
  • Page 6: Networking

    Supply power to the reader using either a Power over Ethernet (PoE) injector (DataMan 260 series readers) or the Power and I/O breakout cable (CCB-PWRIO-xx). Cognex recommends the following connection sequence in case of using a PoE injector: 1. Connect the PoE injector to the Ethernet network (both ends of the patch cable).
  • Page 7 Networking If you are using a serial slide-in with your handheld DataMan reader, connect the serial cable to your PC, power your reader through an external power supply and connect your PC to the network. Connecting Your DataMan to the Network Wirelessly You can connect to your DataMan reader via the wireless network as well.
  • Page 8 Networking 1. Make sure that the DataMan device is (re)set to factory settings. 2. Search for the DataMan device among the available wi-fi connections and connect to it. 3. Open the DataMan Setup Tool. 4. Search for the device and connect to it. 5.
  • Page 9 Networking 3. Select from the following authentication modes: Authentication mode Encryption mode Requirements Open System WEP-40, WEP-104 passphrase WPA-PSK, WPA2-PSK TKIP, AES, TKIP/AES passphrase EAP-TLS (see the section below) TKIP, AES, TKIP/AES Client’s certificate CA’s certificate Client’s private key Client’s username PEAP-MSCHAPV2 (see the section TKIP, AES, TKIP/AES CA’s certificate...
  • Page 10: Connecting Your Dataman Intelligent Base Station To The Network

    Networking Removing a Certificate File from DataMan Click the red X button beside the corresponding field to delete an existing certificate from your device. The certificates are saved into device backups, and may be completely restored. PEAP-MSCHAPV2 Authentication Mode Encryption methods: TKIP, AES, TKIP/AES are supported. All these methods require a PEM file containing the CA’s certificate, the client’s user name, and a password.
  • Page 11: Direct Connection To Your Computer

    Networking If you want to use a Power over Ethernet (POE) adapter, that will power up your base station. If you use the DMA-IBASE-BT-01 base station, use direct connection with a 24V power supply. DMA-IBASE-BT-01 offers a 3-pin terminal block: Pin # Signal +24V...
  • Page 12 Networking configure your reader and your PC. Link Local Addressing automatically requests and assigns an IP address. In the DataMan Setup Tool, this corresponds to the DHCP Server communication option. This is the default, you do not have to make any changes. You can also manually configure your DataMan device to reside on the same subnet as the PC.
  • Page 13 Networking Your DataMan device is now configured to the specified network settings, and it reboots automatically. After the address has been resolved, your DataMan device appears under the Network node. This can take up to 60 seconds. If the device does not appear after 1 or 2 minutes, press the Refresh button in the DataMan Setup Tool’s Connect page. This will force the DataMan Setup Tool to scan for DataMan devices connected to the PC or connected to the same network.
  • Page 14 Networking Once the IP Address and Subnet Mask of the DataMan device are known, the PC’s network settings can be changed. Perform the following steps to configure your PC (examples here are of Windows XP): 1. In the Start Menu, start typing Control Panel and open it. 2.
  • Page 15 Networking 4. In the Ethernet Status window that pops up, click Properties. 5. In the Ethernet Properties window that pops up, select Internet Protocol Version 4 (TCP/IPv4) and click Properties. 6. Under the General tab, select the Use the following IP address option and enter an IP address and Subnet mask that are on the same subnet as your DataMan.
  • Page 16: Connecting Your Reader Across Subnets

    Networking 7. Click Close. The network settings of your PC will change to the new specified values. 8. Reboot the DataMan device. It appears under the Discovered Devices node on the Connect page after the network address has been resolved. 9.
  • Page 17: Troubleshooting A Network Connection

    Networking 3. Click OK. The reader appears under the Network node. Double click the new node or select it and click the Connect button. If the device is available, the reader will be connected. Troubleshooting a Network Connection Based on your network configuration, the DataMan Setup Tool may not be able to communicate with the reader and it will not appear in the list of Network devices.
  • Page 18: Dataman Application Development

    Ethernet connection, either directly or programmatically through a custom application. Note: For a complete list of DMCC commands, click the Windows Start menu and browse to Cognex -> DataMan Setup Tool v x.x -> Documentation -> Command Reference. Alternatively, you can open the Command Reference through the Setup Tool Help menu.
  • Page 19 DataMan Application Development Commands Short names specifying an action. A commonly used command is GET or SET followed by a Parameter and Value. Parameters Short names specifying a device setting. Parameter names are organized with a group of similar commands with one level of structural organization separated by a period ('.').
  • Page 20: Dataman Sdk Development

    Framework (CF). The name of each file corresponds to the platform it belongs to (PC/CF). There are two components for each platform, one is the DataMan SDK core itself (Cognex.DataMan.SDK), the other is for discovering available devices to be used with the SDK (Cognex.DataMan.Discovery).
  • Page 21 DataMan Application Development 3. In the pop-up window, click the Browse tab and look for the Cognex.DataMan.SDK.*.dll file (where * refers to the platform you are working on, either PC or CF) in the directory where you installed or copied the binary files.
  • Page 22 DataMan Application Development c. Create event handler of type EthSystemDiscoverer.SystemDiscoveredHandler. d. The event handler argument is an EthSystemDiscoverer.SystemInfo. These SystemInfo objects contain information required for connecting to a reader. You can store these SystemInfo objects in your own collection. e. To start device discovery, call the ethSystemDiscoverer.Discover() method. 5.
  • Page 23 DataMan Application Development 4. Call the Connect() method of your DataManSystem instance: mySystem.Connect(); 5. (Optional) Verify if you are connected: if (mySystem.IsConnected) 6. To disconnect, call mySystem.Disconnect(); Note: Currently all devices use the user name admin. If no password is required, an empty string can be used. Your Serial device Connect to your serial device by performing the following steps: 1.
  • Page 24 DataMan Application Development Some functions like SendCommand() or GetLiveImage() also have asynchronous implementations. If you wish to use these, look for the desired function name with Begin/End prefix. These functions go in pairs; the function with the Begin prefix returns an IAsyncResult which can be used by the one with the End prefix. Displaying Static and Live Images from a DataMan Device To have static images displayed, use DataManSystem.GetLastReadImage () or subscribe for the event ImageArrived to get images.
  • Page 25: Scripting

    DataMan Application Development Using the Helper Utilities The helper utilities are contained in two projects. Both projects refer to the same source codes, but one is created for Microsoft .Net Compact Framework (DataManUtilsCF) and the other of for the PC’s Microsoft .Net Framework (DataManUtilsPC).
  • Page 26 DataMan Application Development Note: The data formatting script function is executed after the output delay time or distance elapsed. All scripting functions run in a separate thread and the execution is mutual exclusive. It is not possible that a script function is interrupted by another. Use [0,1] or [true,false] instead of [ON|OFF] when scripting.
  • Page 27 DataMan Application Development Example To get the device name using the dmccGet function the correct string argument is required: var res = dmccGet(”DEVICE.NAME”); The dmccSend function can be used in a similar way, but without splitting the command and type correct arguments: var res = dmccSend(”GET DEVICE.NAME”);...
  • Page 28 DataMan Application Development F1 to F12 ALT-F1 to ALT-F12 PageUp, PageDown, Home, End, Arrow (up, down, left, right), , Insert, Delete, Backspace, Tab, Esc, Print Screen, GUI (left, right) keys. The escape sequences for these are the following: PageUp -> \KPup; PageDown ->...
  • Page 29: Error Management

    DataMan Application Development Function encode_base64 This global function is used to encode a string argument into base64 encoding. The encoded result is returned as a string object. Parameter Type Description string Input string to encode into base64. inputString Error Management Scripting errors may occur when the script is loaded or the code parser function is called.
  • Page 30 DataMan Application Development Output Output, the object which needs to be updated to modify the output output string or raise events. Function onGenerateFTPFilename The name of the file to be sent to the FTP server can be generated with this function. Property Type Description...
  • Page 31 DataMan Application Development SymbologyProperties The values of this property are listed in the Symbology Properties table symbology below. image ImageProperties The values of this property, also known as capture attributes, are listed in the Image Properties table below. ValidationResult The values of this property are listed in the Validation Result table validation below.
  • Page 32 DataMan Application Development Property Type Description array of Point This specifies the coordinates of the four corners. The details of the Point corners property type are listed in the Point table below. The corner coordinates are returned in the following order: For non-mirrored symbols, corner 0: upper left corner of the symbol, corner 1: upper right corner of the symbol,...
  • Page 33 DataMan Application Development Property Type Description integer The camera gain. gain autoExposure boolean True if automatic exposure is used. boolean True if internal illumination is enabled. illEnabled integer The internal illumination intensity. illIntensity boolean True if external illumination is enabled. extillEnabled extillIntensity integer...
  • Page 34 DataMan Application Development Property Type Description string The data title for each section of the parsed data. grade data string The raw parsed data. string A Pass/Fail assessment determined by the specific application standard selected. check TruCheckCodeword Property Type Description integer Outputs the codewords associated with the parsed data.
  • Page 35 DataMan Application Development Property Type Description float The overall numeric grade (0.0-4.0). gradeValue gradingStandard string The grading standard used to verify the symbol. string The lighting option selected for verification. lighting integer The wavelength used for verification in nm. wavelength TruCheckResult Outputs the TruCheck values used for verification.
  • Page 36 DataMan Application Development Property Type Description string The jpeg image of the symbol encoded as a base64 jpegImage string. TruCheckMetricGradeOnly The grade for the left L-side of the symbol. LeftLSide TruCheckMetricGradeOnly The grade for the left quiet zone of the symbol. leftQuietZone linearDecodability TruCheckMetric...
  • Page 37 DataMan Application Development Validation Result Describes all details of the validation. Property Type Description state integer These are the validation states: notTried fail pass The format of this property is “validation.state.notTried”. integer These are the validation methods: method none dod_uid pattern matchString The format of this property is “validation.method.none”.
  • Page 38 DataMan Application Development string Due date for amount on payment slip AI12 string Packaging date AI13 AI15 string Best before date string Sell by date AI16 string Expiration date AI17 string Product variant AI20 AI21 string Serial number string Additional product identification assigned by the manufacturer AI240 string Customer part number...
  • Page 39 DataMan Application Development string Purchased from Global Location Number AI412 string Ship for - Deliver for - Forward to Global Location Number AI413 AI414 string Identification of a physical location - Global Location Number string Global Location Number of the invoicing party AI415 string Ship to - Deliver to postal code within a single postal authority...
  • Page 40 DataMan Application Development AI8017 string Global Service Relation Number (GSRN) AI8018 string Service Relation Instance Number (SRIN) AI8019 string Payment slip reference number AI8020 AI8110 string Coupon code identification for use in North America string Loyalty points of a coupon AI8111 string Extended packaging URL...
  • Page 41 DataMan Application Development Property Type 1D Standards 2D Standards Description Metric 1D Readability The single-scan singleScanInt integrity, raw member is set to -1. Single- scan integrity is a general measure of the ease of decoding a barcode using only a single scan across it.
  • Page 42 DataMan Application Development Property Type 1D Standards 2D Standards Description Metric 1D Readability, ISO/IEC ISO/IEC 15415 The contrast of the symbolContrast 15416 (DataMatrix, QR, symbol in ISO15415. DotCode), SEMI T10 Symbol contrast is a measure of the difference in grayscale value between the light and dark cells.
  • Page 43 DataMan Application Development Property Type 1D Standards 2D Standards Description Metric ISO/IEC 15415 The axial non- axialNonUniformity (DataMatrix, QR, uniformity. Axial non- DotCode), AIM/DPM uniformity is a ISO/IEC TR-29158 measure of the (DataMatrix, QR) difference in spacing of grid cells along each axis. In the best case, this value will be zero, indicating that centers of the grid...
  • Page 44 DataMan Application Development Property Type 1D Standards 2D Standards Description Metric 1D Readability ISO/IEC 15415 The print growth. Print printGrowth (DataMatrix, QR, growth is a measure DotCode), AIM/DPM of how completely a ISO/IEC TR-29158 light or dark patch fills (DataMatrix, QR) the cell allocated to it. High print growth means that a cell exceeds the...
  • Page 45 DataMan Application Development Property Type 1D Standards 2D Standards Description Metric ISO/IEC 15415 The unused error (DataMatrix, QR, correction. Unused DotCode), AIM/DPM Error Correction ISO/IEC TR-29158 measures the amount (DataMatrix, QR), of Error Checking and SEMI T10 Correction data that was printed into the code, but was unused.
  • Page 46 DataMan Application Development Property Type 1D Standards 2D Standards Description Metric ISO/IEC 15415 The fixed pattern fixedPatternDamage (DataMatrix, QR), damage. Fixed AIM/DPM ISO/IEC TR- pattern damage is a 29158 (DataMatrix, QR) measure of how much of the fixed patterns around the outside of the code (the solid finder patterns and the alternating...
  • Page 47 DataMan Application Development Property Type 1D Standards 2D Standards Description Metric ISO/IEC 15415 The grid non- gridNonUniformity (DataMatrix, QR, uniformity. Grid non- DotCode), AIM/DPM uniformity measures ISO/IEC TR-29158 the difference (DataMatrix, QR) between the optimal placement of cells based on the overall grid and their actual placements.
  • Page 48 DataMan Application Development Property Type 1D Standards 2D Standards Description Metric ISO/IEC 15415 The extreme extremeReflectance (DataMatrix, QR) reflectance. This metric measures the brightness of the background on which the code is printed. A too high value might indicate lighting or imaging trouble that could lead to a code being washed out and difficult to read.
  • Page 49 DataMan Application Development Property Type 1D Standards 2D Standards Description Metric 1D Readability, ISO/IEC The reflectance reflectMin 15416 minimum. This metric measures how dark the dark part of a barcode is. A low value indicates that the dark parts of the code are dark, and a high value indicates that they are not.
  • Page 50 DataMan Application Development Property Type 1D Standards 2D Standards Description Metric 1D Readability The multi-scan multiScanInt integrity. Multi-scan integrity is a general measure of the ease of decoding a symbol by using multiple scans across the barcode. This metric is a way of measuring how advanced decoders might perform in decoding a...
  • Page 51 DataMan Application Development Property Type 1D Standards 2D Standards Description Metric SEMI T10 (DataMatrix) Vertical Mark Growth verticalMarkGrowth is the tracking of the tendency to over or under mark the symbol, that is, a vertical size comparison between the actual marked cells vs. their nominal size.
  • Page 52 DataMan Application Development Property Type 1D Standards 2D Standards Description Metric ISO/IEC 15416 Edge Determination is edgeDetermination the number of edges detected in the Scan Reflectance Profile. If the number of detected edges is greater than or equal to the expected number of edges, the grade is 4.
  • Page 53 DataMan Application Development Property Type 1D Standards 2D Standards Description Metric ISO/IEC 15416 Decodability is the decodability measure of bar code printing accuracy in relation to the symbology-specific reference decode algorithm. Decodability indicates the scale of error in the width of the most deviant element in the symbol.
  • Page 54 DataMan Application Development Property Type Description float The raw metric. grade string The grade of quality in a range from grade A to F, where A is the highest. Barcode Assignment Property Type Description integer Result for Barcode Assignment on the code. The following are the possible results:  result Disabled Not on Box...
  • Page 55 DataMan Application Development integer These are the available trigger types: type single presentation manual burst self continuous The format of this property is “trigger.type.single”. index integer The unique trigger identifier. integer The number of images in case of burst trigger. burstLength integer The trigger interval in microseconds.
  • Page 56: Output

    DataMan Application Development Property Type Description integer The number of no reads when buffered no read images are allowed. itemCount passedValidations integer The number of reads that passed the data validation. failedValidations integer The number of reads that failed the data validation. Status3D Property Type...
  • Page 57 DataMan Application Development function onResult (decodeResults, readerProperties, output) if (decodeResults[0].decoded) var mymsg = decodeResults[0].content; // output[’Serial’] is identical to output.Serial output[’Serial’] = ”serial: ”+mymsg; output.Telnet = ”telnet: ”+mymsg; output.content = mymsg; else output.content = ”bad read”; Note: For every channel that is not addressed in special, the output is the normal content text. For example: function onResult (decodeResults, readerProperties, output) if (decodeResults[0].decoded) /* save decoded result to variable */...
  • Page 58: Code Completion And Snippets

    DataMan Application Development Property Type Description integer These are the system generated events: system 0 = none 1 = good read 2 = no read 3 = validation failure* user1 boolean True if user event 1 is raised. boolean True if user event 2 is raised. user2 * Only changing between good read and validation failure is supported.
  • Page 59 DataMan Application Development The toolbar at the top of the editor collects the following actions available within the editor: Cut (Ctrl-x) Copy (Ctrl-c) Paste (Ctrl-v) Complete Word (Ctrl-k and then press w) Insert Snippet (Ctrl-k and then press x) Snippets The editor provides a selection of preset code fragments as examples.
  • Page 60: Custom Communication Protocol Api

    DataMan Application Development Custom Communication Protocol API Custom communication scripting can be activated by a boolean VT entry that can be accessed in the DataMan Setup Tool. The methods are encapsulated in a communication object. Each communication channel creates an instance of the communication object.
  • Page 61 DataMan Application Development “COM1” or “COM USB”. The local name for the HID connection is “keybrd”. onConnect – Initialize state upon connection (a network connection established or protocol stack starts on serial connection). If the method is not implemented an error occurs. The method has one argument and a return value: peerName –...
  • Page 62 DataMan Application Development expectFramed – Tells the communication listener which data to pass on to the onExpectedData and onUnexpectedData methods. It is possible to change the match parameter at runtime. The following three arguments are required: header of type string, can be empty (””) terminator of type string, can be empty (””) max length of type integer, specifies the maximum length of an input message to check for a match [required]...
  • Page 63 DataMan Application Development function CommHandler() // private properties and methods: var num_trigger = 0; var num_send; // public properties and methods: function onTimeout() num_send = this.send(my_name + ': timer callback\r\n'); this.setTimer(1.0); function onTimeout2() today = new Date(); var msg = today.getSeconds() * 1000 + today.getMilliseconds(); num_send = this.send(my_name + ': time is: ' + msg + '\r\n');...
  • Page 64 DataMan Application Development this.send(my_name + ': issue a trigger...\r\n'); dmccCommand("TRIGGER", true); msg = 'done'; else if (inputString == "close") this.close(); else if (inputString == "stop") this.setTimer(0.0); else if (inputString == "start") this.setTimer(10.0); else if (inputString == "switch") this.onTimer = onTimeout2; else if (inputString == "time") today = new Date();...
  • Page 65 DataMan Application Development Generic use case: Heartbeat Send out a periodic heartbeat message if reader is idle.
  • Page 66 DataMan Application Development // Data Formatting: var comm_handler = new Array(0); // Converts read data to all upper case. Single code only. function onResult (decodeResults, readerProperties, output) { if (decodeResults[0].decoded) { output.content = decodeResults[0].content+'\r\n'; for (var i = 0; i < comm_handler.length; i++) comm_handler[i].resetHeartBeat();...
  • Page 67 DataMan Application Development onTimer: function () { today = new Date(); var msg = today.getSeconds() * 1000 + today.getMilliseconds(); num_send = this.send(peer_name + ': time is: ' + msg + '\r\n'); this.resetHeartBeat(); // schedule next timer event [sec] resetHeartBeat: function () { this.setTimer(beat_timer);...
  • Page 68 DataMan Application Development // communication script var time_offset=0; function CommHandler() var peer_name; return { onConnect: function (peerName) peer_name = peerName; this.expectFramed("||;1>SET TIME.NOW ", "\r\n", 128); // some pattern unlikely to happen // enable the handler for this connection: return true; onDisconnect: function () onError: function (errorMsg) onExpectedData: function (inputString) {...
  • Page 69 DataMan Application Development onUnexpectedData: function (inputString) { return false; onTimer: function () { // data formatting script function onResult (decodeResults, readerProperties, output) var d = new Date(); var real = new Date(time_offset+d.getTime()); output.content = real.toString() + " " + decodeResults[0].content + "\r\n"; Customer Protocols implemented in various CR releases Communication with cmf400 Profibus gateway...
  • Page 70 DataMan Application Development var CMF400_PROTOCOL_STATUS = RUNNING: {value: 0, name: "Running"}, SYNCRONIZING: {value: 1, name: "Sync"}, CONFIGURING: {value: 2, name: "Config"}, STOPPED: {value: 3, name: "Stop"} // make the enum non-modifyable Object.freeze(CMF400_PROTOCOL_STATUS); var cmf400_protocol_stx = '\x02'; // header var cmf400_protocol_etx = '\x03'; // termination // VT Parameter to be converted into script configuration constant values: // "/Communication/Interfaces/COM1/Protocol") var vt_param_comif_com1_protocol = 1;...
  • Page 71 DataMan Application Development // Formatting helper function function zero_prefix(num, size) var s = "000000000" + num; return s.substr(s.length - size); function CommHandler() // The current protocol state var cmf400_status = CMF400_PROTOCOL_STATUS.STOPPED; function _configTimedOut() if (cmf400_status == CMF400_PROTOCOL_STATUS_CONFIGURING) cmf400_status = CMF400_PROTOCOL_STATUS_STOPPED; this.setTimer(30.0);...
  • Page 72 DataMan Application Development onDisconnect: function () onExpectedData: function (inputData) data = inputData.slice(1,inputData.length-1); if (cmf400_status == CMF400_PROTOCOL_STATUS.SYNCRONIZING) if (data == cmf400_gateway_ident_ok || data == cmf400_gateway_ident_no) cmf400_status = CMF400_PROTOCOL_ STATUS.CONFIGURING; var msg = cmf400_protocol_stx; msg += "+GW S000 H000"; msg += " X" + zero_prefix(vt_param_ comif_com1_protocol, 3);...
  • Page 73 DataMan Application Development function onResult (decodeResults, readerProperties, output) //assuming single code var content = cmf400_protocol_stx+decodeResults[0].content+cmf400_protocol_etx; output.content = content; Pass weight string input along with decode string...
  • Page 74 DataMan Application Development // the constructor: var input_string = ""; function CommHandler() // private properties and methods: var num_trigger = 0; var my_name; var num_send = 99; function privFunc () // public properties and methods: return { onConnect: function (peerName) my_name = peerName;...
  • Page 75 DataMan Application Development //Empty data formatting entry point function function onResult (decodeResults, readerProperties, output) if (decodeResults[0].decoded) output.content = input_string + decodeResults[0].content + "\r\n" input_string = ""; FMPCS protocol...
  • Page 76 (peerName) if(peerName == "COM1" || bConnected) return false; this.expectFramed("", "\r", 128); this.send(dmccGet('DEVICE.FIRMWARE-VER').response + ',"Cognex ' + dmccGet('DEVICE.TYPE').response + '"\r\n'); this.send('Ha,"DataMan READY"\r\n'); bConnected = true; return true; // activate this connection onError: function (msg) // TODO: this is new!
  • Page 77 DataMan Application Development var errno = ErrorToId[msg]; if (!errno) errno = 100; this.send('E' + errno + ',"' + msg + '"\r\n'); // We delay sending the result until trigger off to be sure that the package id is received. setResult: function (decodeResults) { storedDecodeResults = decodeResults;...
  • Page 78 DataMan Application Development case 'C': var match = config_msg_expr.exec(input); if (match.length == 4) speed = parseInt(match[1], 10); mode = match[2]; lengthLimit = parseInt(match[3], 10); break; case 'P': this.send('Q\r\n'); break; case 'Q': // pong response, not used break; return true; onUnexpectedData: function (input) { return true;...
  • Page 79 DataMan Application Development var packageID = "000000000"; // reset the package id var mode = 'a'; var lengthLimit = 9999; function getFixedPsocId(id_) var id = id_; switch (id.charAt(1)) case 'd': id = "[D0"; break; case 'X': switch (id.charAt(2))
  • Page 80 DataMan Application Development case '0': case '1': id = "[P0"; break; case '2': case '3': id = "[L0"; break; case '5': case '6': case '7': case '8': case '9': case 'A': id = "[O0"; break; break; return id; function onResult (decodeResults, readerProperties, output) var my_decode_results = new Array();...
  • Page 81 DataMan Application Development var msg = 'D' + packageID + ',S,W,V'; if (my_decode_results.length == 0) msg += ',?'; output.content = "no result"; else for(var i = 0; i < my_decode_results.length; i++) msg += ',' + getFixedPsocId(decodeResults [i].symbology.id); switch (my_decode_results[i].symbology.name) case 'Data Matrix': case 'PDF417': msg += encode_base64(my_decode_results [i].content);...
  • Page 82 DataMan Application Development function CommHandler() return { onConnect: function (peerName) this.expectFramed('\x02', '\x03', 256); return true; onDisconnect: function () onExpectedData: function (inputString) { if (inputString.length >= 11) var new_match_string = inputString.substr(11, inputString.length); for (var i = 1; i <= 3; i++) { dmccSet("DVALID.PROG-TARG", i);...
  • Page 83 DataMan Application Development var comm_handler = new Array(0); // Converts read data to all upper case. Single code only. function onResult (decodeResults, readerProperties, output) output.content = ''; output.SetupTool = decodeResults[0].content; if (decodeResults[0].decoded) { for (var i = 0; i < comm_handler.length; i++) comm_handler[i].sendResultTelegram(decodeResults);...
  • Page 84 DataMan Application Development // Parameter: var system_id = '\x43'; // the system ID var heartbeat_time_s = 5.0; // heartbeat timer in sec [0-50] (0 is disabled) var append_crlf = true; // wether to function CommHandler() function getChecksum(data) var sum = 0; for(var i = 0;...
  • Page 85 DataMan Application Development if (!index) this.sendErrorTelegram(errorCodes.undef_index); index = '9999'; data += index; for (var i = 0; i < decodeResults.length; i++) { length = decodeResults[i].content.length; data += String.fromCharCode(length / 256, length % 256); data += separator + filler; length = 0; for (var i = 0;...
  • Page 86 DataMan Application Development this.sendTelegram(telegram_types.init_resp); this.setTimer(0.0); // disable the heartbeat timer all_index = new Array(0); break; case 'S': if (index) { this.sendErrorTelegram(errorCodes.multi_index); break; index = data.substr(1, 4); if (all_index.indexOf(index) >= 0) this.sendErrorTelegram(errorCodes.index_in_use); else all_index.push(index); break; default: break; onConnect: function (peerName) status = TelegramState.WAIT4CONTENT; this.expectFramed('\x02', '\x03', 203);...
  • Page 87 DataMan Application Development default: throw("unknown state"); return true; onUnexpectedData: function (inputString) { this.expectFramed('\x02', '\x03', 203); // enable framing for the next telegram status = TelegramState.WAIT4CONTENT; return true; onTimer: function (inputString) { this.sendTelegram(telegram_types.heartbeat); this.setTimer(heartbeat_time_s); Event Callback The callback mechanism allows to register handler for trigger and input events. Handler for these events can be registered by the registerHandler method: callback_handle registerHandler(eventid, callback, ...) The registerHandler function requires the following arguments:...
  • Page 88 DataMan Application Development Input3: Input4: Input5: Input6: InputAll BnTrig BnTune The input mask can be combined. The input values are sampled with an accuracy of 1 ms. The callback function for the onInput event has one argument for the new state of the input. onTrigger event: It executes the callback function on trigger start and trigger end events.
  • Page 89 DataMan Application Development function CommHandler() return { onConnect: function (peerName) this.peer = peerName; this.input1 = registerHandler(Callback.onInput, this.onInput0.bind(this), ConstInput.Input0|ConstInput.BnTrig); this.input2 = registerHandler(Callback.onInput, this.onInput1.bind(this), ConstInput.Input1); this.ontrigger = registerHandler(Callback.onTrigger, this.onTrigger.bind(this)); return true; onDisconnect: function () deregisterHandler(this.input1); deregisterHandler(this.input2); deregisterHandler(this.ontrigger); onTrigger: function (trigger, state) { if (state) this.send("call onTrigger: started trigger with index "...
  • Page 90 DataMan Application Development onInput0: function (inputs) { this.send("call onInput0 for '" + this.peer + ", inputs=" + inputs + "\r\n"); onInput1: function (inputs) { this.send("call onInput1 for '" + this.peer + ", inputs=" + inputs + "\r\n"); With the following event sequence: input1 on, input0 on, input0 off, input1 off, software trigger, switch on, switch off, we get the following output on the terminal: call onInput1 for 'COM1, inputs=2 call onTrigger: start trigger with index 9...
  • Page 91 DataMan Application Development var ginputs = false; registerHandler(Callback.onInput, onInput, ConstInput.Input1); // Default script for data formatting function onResult (decodeResults, readerProperties, output) output.content = "Input: "+ginputs+" \r\n"; function onInput(inputs) ginputs = (inputs & ConstInput.Input1) ? true : false;...
  • Page 92 Copyright © 2022 Cognex Corporation. All Rights Reserved.

Table of Contents