▼Output Serial File Serial.Dat
TaskLink accomplishes serialization by running an External Serialization Program (ESP) to generate a serial number for each device. The ESP is run once at the beginning of the programming session and again each time a device is successfully programmed. The goal of the ESP is to increment the serial number and to create the data that represents the serial number inside the device. This information is also written to a disk file that TaskLink reads when the ESP is finished.
To write an ESP, you need to know the following:
How to write a program that runs on a PC. Any language will do provided the resulting program can accept command line arguments and output an ASCII file.
Description of the command line arguments that TaskLink supplies to the ESP and the format of the disk file that the ESP creates for TaskLink.
The following is a detailed description of the information needed for the second item:
Using TaskLink's two-way communication with an ESP:
the ESP receives data via arguments on the command line used to invoke the ESP.
the ESP returns data to TaskLink in the file SERIAL.DAT that the ESP creates in the current directory. This file is a line-oriented ASCII file containing the information needed to change the data in programmer RAM.
TaskLink uses the following arguments to pass information to the ESP. These are always passed and do not need to be specified in the Program field in TaskLink's Setup/Serialization dialog box. Other command line arguments defined by the writer of the ESP may be entered in the Program field following the name of the ESP executable file.
-N serial_number: The ASCII representation of the current serial number (the number that the ESP is expected to format for programmer RAM). The format of serial_number is determined by the requirements of the ESP. In fact, if the ESP is given the responsibility of keeping track of the next serial number to use, serial_number may not be present at all.
-E ending_serial_number: The ASCII representation of the last serial number that should be used during the programming session. This argument will not be present unless the Operator has entered an ending serial number at the beginning of the session. The format of ending_serial_number is determined by the requirements of the ESP.
-D device_size: Hexadecimal size (in bytes) of the currently selected device. The ESP can use this information to generate a block of serial numbers for serializing devices in a gang/set programmer. The serial numbers must be placed in programmer RAM after the device data, so the ESP must know the size of the device.
-Q quantity of serial numbers needed: The number of serial numbers requested. When serialization is done on a gang/set programmer with multiple sockets, TaskLink will pass the ESP the number of sockets currently available on the programmer. The ESP can then generate multiple serial numbers, which are placed in a block of programmer RAM immediately following the device data (the size of the device is passed in via the -D parameter).
-S checksum: The checksum of programmer RAM at the beginning of the programming session (before any serial number information has been placed in programmer RAM). This is a hexadecimal value with as many digits as the programmer supports (up to eight). The ESP can use this checksum value to calculate a new RAM checksum when new serial number information is generated. Note that the checksum calculation can be accurate only if the RAM locations are set to zeros (or some value known to the ESP) before serialization begins. The ESP can return the new checksum to TaskLink, which will display it on the screen as devices are programmed. Use of this feature is optional and does not affect the serialization of the device.
-F: Flag that indicates this is the first call to the ESP at the beginning of the programming session. Use of this flag is determined by the ESP. An ESP might, upon seeing this flag, "check out" a beginning serial number from an external database.
-L: Flag that indicates this is the last call to the ESP after the programming session has been terminated. The last serial number that was produced by the ESP has NOT BEEN USED YET and is once again the value supplied to the ESP in serial_number. If the ESP is responsible for keeping the next serial number to be used, it can store the value in serial_number for use as the starting serial number in the next session.
For example, assuming a starting serial number of 12345, a 256-byte device and initial RAM that happens to have a zero checksum, the first call to Serializ.exe looks like this:
serializ.exe -F -D100 -S00000000 -N12345
The next call looks like this:
serializ.exe -D100 -S00000000 -N12346
Assuming the last serial number successfully programmed into a device is 12500, the last call looks like this:
serializ.exe -L -D100 -S00000000 -N12501
The file SERIAL.DAT must be generated each time the ESP is called (except for the last time, indicated to the ESP by an -L on the command line). The file is a standard line-oriented ASCII file, each line being terminated by a carriage-return/line-feed sequence. Each line begins with a tag of the form Tnn, where nn is a decimal number. The tag identifies the type of data, if any, that the line contains. If the line contains additional data, the tag is followed by a colon (:) and then the data. The lines may appear in the file in any order, except for the T04 line, which marks the beginning of the serial number data and is by definition the last T-record in the file. A description of each type of T-record follows.
This line contains one or more ASCII representations of serial numbers that have been generated. If more than one serial number is generated, the numbers should be separated by commas.
T01:12345,12346,12347,12348,12349,1234A,1234B,1234C
This line contains the ASCII representation of the NEXT serial number to be used (after the number(s) that have just been formatted). This number will be the number that is passed to the ESP by TaskLink in the -N field of the command line the next time the ESP is called (unless you did not fill all the sockets on a multisocket programmer, in which case TaskLink will pass back the next number that was not used). If the serialization is being done as part of a Task, TaskLink can store this number for you when the session is terminated for use as the starting serial number the next time the Task is run.
T02:1234D
T03: Translation format number
This line contains an ASCII representation of the Data I/O translation format number (1-99) for the serial number data in the file (which follows the T04 record). An ASCII translation format must be used, the records being terminated with a carriage-return/line-feed sequence. See your programmer manual for a description of supported formats.
Note: The C-language source for Serializ.exe, included with TaskLink, contains a routine for formatting a buffer of binary data into lines of Motorola format 95. This routine can be used for development of your own ESP.
T03:95
T04: "Beginning of serial number data" marker
A line containing just the tag T04 marks the beginning of the serial number data. The contents of the SERIAL.DAT file from the line following the T04 record up to the end-of-file will be sent to the programmer verbatim. The data must be in one of the ASCII formats supported by the programmer being used. The format being used is specified in the T03 record. Use a Translation Format with address fields if you want the data to start anywhere except address 0 in the device.
Here is an example file produced by an ESP. The ESP was called with the current serial number of 12345. The program formats the number as a long integer (four bytes) at address 0 in the device. The beginning- and end-of-file markers and comments are not part of the file.
<beginning-of-file>
T01:12345 ' Current serial number
T02:12346 ' Next serial number
T03:87' Format number for Motorola format 87
T04 ' Beginning of data marker
S2080000000803E98281 ' The formatted data in an S2 record
S9030000FC ' The format 87 end record
<end-of-file>
These T-records may be included in the file if needed.
T05: Fatal-error message
If this record is included, TaskLink stops processing and displays the text string preceded by the message "Error message from external serialization program."
T05: Unable to generate serial number
T06: Limit-reached flag
This record is included when the ESP has detected that the current serial number is greater than some limit (the last device programmed had the last allowable serial number). When this record is detected, TaskLink stops processing and displays "Ending serial number reached."
T06
T09: RAM checksum
This record contains the current RAM checksum. TaskLink displays this checksum in the System Status box while processing devices. This allows the external program to calculate the RAM checksum from the initial checksum value passed to the program on the command line. If this record is not included, TaskLink displays the initial checksum and does not change it during the programming session.
T11: Warning message
If this record is included, TaskLink stops processing and displays the text string. The Operator will be given the choice to end the programming session or to continue.
T11: Serial Number Warning Limit Reached
• • •