Serial Numbers in XJRunner

XJRunner can read and log unique board identifiers during testing, such as serial numbers and MAC addresses. To pass serial numbers between the XJEase test code and XJRunner, use the built-in global string variable SERIAL_NUMBER.

Serial Numbers from XJRunner

If the serial numbers are entered into XJRunner by the tester, XJRunner will set the value of SERIAL_NUMBER before running the tests for the board. The XJEase tests should then include a function in the XJRunner test list to program the serial number into the board, taking the value from the string SERIAL_NUMBER.

Example code:

ProgramSerialNumber()(INT result)
  INT serNo1, serNo2, serNo3, serNo4;
  INT serial WIDTH 32;

  // Convert serial number string to int
  serial := STRTOINT(SERIAL_NUMBER);

  // Write four data bytes to the EEPROM.
  I2C_Write(0x0, I2C_ADDRESS, serial[7..0]);
  I2C_Write(0x1, I2C_ADDRESS, serial[15..8]);
  I2C_Write(0x2, I2C_ADDRESS, serial[23..16]);
  I2C_Write(0x3, I2C_ADDRESS, serial[31..24]);

  // Read the bytes back.
  I2C_Read(0, I2C_ADDRESS)(serNo1);
  I2C_Read(1, I2C_ADDRESS)(serNo2);
  I2C_Read(2, I2C_ADDRESS)(serNo3);
  I2C_Read(3, I2C_ADDRESS)(serNo4);

  // Check the read-back data.
  IF serNo1 != serial[7..0] ||?
     serNo2 != serial[15..8] ||?
     serNo3 != serial[23..16] ||?
     serNo4 != serial[31..24]
  THEN
    result := RESULT_FAIL;
  ELSE
    result := RESULT_PASS;
  END;
END;

Complex Serial Numbers

If complex board identifiers are needed, such as MAC addresses, there are two options:

Tester inputs serial numbers
For example, the boards may have a barcode with their serial number. Using a barcode reader, the tester can input these into XJRunner. These should be handled by XJEase test code in the same way as above.
XJEase generates serial numbers
XJEase can generate serial numbers and pass them to XJRunner. This is explained in more detail below.

Serial Numbers from XJEase

If XJEase will be generating the serial numbers, it must let XJRunner know, so that XJRunner can read the serial numbers and put them in the log file(s). This notification is done by writing a test function called NEW_SERIAL_NUMBER, and including it in the XJRunner test list. This test function will be a normal XJEase test function, which will set the value of the global variable SERIAL_NUMBER to be the next serial number. This function must be defined in a circuit code file.

If XJRunner finds a function called NEW_SERIAL_NUMBER in the test list, it assumes that:

  • XJEase will generate serial numbers for this project.
  • The serial number for this board (stored in the global variable SERIAL_NUMBER) will be valid when the test named NEW_SERIAL_NUMBER has finished. XJRunner will put this value in the log file for the board.

See the documentation on FLOCK for a complete example of how to write a NEW_SERIAL_NUMBER function.

See Also