:tocdepth: 4

.. _serialization-schemes:

Serialization Schemes
---------------------

Overview
++++++++
While the primary purpose of an ItemEncode device is encoding EPCs, ItemEncode
supports encoding other areas of tag memory as well. For complete details on
tag memory, please see the :ref:`UHF Gen2 Spec<uhf-gen2>`.

ItemEncode also supports encoding EPCs using automated serialization schemes: 
:ref:`Monza Self-Serialization<mss-mode>` and 
:ref:`Serial Number Range<sn-range-mode>`.

.. _mss-mode:

Monza Self-Serialization
++++++++++++++++++++++++
Monza Self-Serialization is a chip-based serialization scheme that generates 
EPCs with unique SGTIN serial numbers directly from the Monza TID. ItemEncode 
can generate these EPCs when encoding Monza tags. To configure an ItemEncode 
device to use Monza Self-Serialization, the application must add a 
:ref:`MonzaSelfSerialization<monza-self-serialization>` object to the 
:ref:`Serialization<serialization>` configuration object. They may optionally 
include a serialization prefix as well. This prefix may be up to four bits.

.. note:: For more information on Monza Self-Serialization, please see the `Monza Self-Serialization Product page <http://www.impinj.com/products/tag-chips/monza-self-serialization/>`_.


.. _sn-range-mode:

Serial Number Range
+++++++++++++++++++
ItemEncode also supports writing EPCs in an auto-incrementing Serial Number 
Range format. Users may specify the starting and ending EPC values. The 
ItemEncode device will increment the serial number by one with every tag it 
encounters. Upon reaching the end of the Serial Number Range, the ItemEncode 
device will begin reporting a :ref:`TagOperationResult<tag-operation-result>` of
TAG_OPERATION_RESULT_FAIL_SERIAL_NUMBER_RANGE_EMPTY. To configure an ItemEncode
device to use Serial Number Range, the application must add a 
:ref:`SerialNumberRange<serial-number-range>` object to the 
:ref:`Serialization<serialization>` configuration object. 

The Serial Number range supports two incrementing formats: Hexadecimal and 
Decimal. This is configured by setting the 
:ref:`SerialNumberRangeFormat<serial-number-range-format>` field in the 
:ref:`SerialNumberRange<serial-number-range>` object. The default is 
Hexadecimal.

===============  ===============
  Hexadecimal        Decimal
===============  ===============
 0000             0000 
 0001             0001 
 \.\.\.           \.\.\.
 0009             0009 
 000A             0010
 \.\.\.           \.\.\.
 00FF             0099
 0100             0100
===============  ===============


.. _user-configured-mode:

User Configured
+++++++++++++++
An Impinj ItemEncode device is capable of encoding the following regions of tag 
memory.

EPC Memory
^^^^^^^^^^
An Impinj ItemEncode device can encode up to 496 bits of EPC data, depending on
tag chip support and user requirements. It is also capable of encoding the PC 
Word. The EPC encoding options are controlled by the 
:ref:`EPCMemory<epc-memory>` object. Autonomous EPC serialization schemes, such
as :ref:`Monza Self-Serialization<mss-mode>` and 
:ref:`Serial Number Range<sn-range-mode>` are specified in this object as well.

.. code-block:: python

    epc_memory
    {
        # Data to be written to EPC memory
        data: [010102020303040405050000]
        pc_word
        {
            # Data to be written to PC Word. This will set the PC Length to 96 bits
            data: [3000]
        }
        serialization
        {
            # Serialize 16 bits
            serialization_bits: 16
            serial_number_range
            {
                serial_number_range_start: 0x0000
                serial_number_range_end: 0xFFFF
                # Start serial number at bit 80 in EPC
                bit_offset: 80
                serial_number_range_format: SERIAL_NUMBER_RANGE_FORMAT_HEX
            }
        }
    }

User Memory
^^^^^^^^^^^
An Impinj ItemEncode device can encode up to 512 bits of User memory, depending
on tag chip support and user requirements. The User memory encoding options are
controlled by the :ref:`UserMemory<user-memory>` object.

.. code-block:: python

    user_memory
    {
        # Data to be written to User memory
        data: [01234567]
        # Word offset for where to start writing data. This value is zero based.
        word_offset: 2
    }

Access Password
^^^^^^^^^^^^^^^
An Impinj ItemEncode device can encode the tag's access password. This can be 
configured in the access_password field in the 
:ref:`SerializationJob<serialization-job>`, 
:ref:`TIDTableEntry<tid-table-entry>`, or 
:ref:`OrderedListEntry<ordered-list-entry>`. This field is an instance of the 
:ref:`Password<password>` object.

.. code-block:: python

    access_password
    {
        data: [accec0de]
    }

Kill Password
^^^^^^^^^^^^^
An Impinj ItemEncode device can encode the tag's kill password. This can be 
configured in the kill_password field in the 
:ref:`SerializationJob<serialization-job>`, 
:ref:`TIDTableEntry<tid-table-entry>`, or 
:ref:`OrderedListEntry<ordered-list-entry>`. This field is an instance of the 
:ref:`Password<password>` object.

.. code-block:: python

    kill_password
    {
        data: [deadc0de]
    }

Lock Config
^^^^^^^^^^^
An Impinj ItemEncode device can also send a Lock command to the tag. This is 
used to permalock memory regions or require the tag be in the secured state to 
access memory sections. This is configured by the :ref:`LockConfig<lock-config>`
object. The lock_config_payload should be 20 bits.

.. note:: Please see the :ref:`UHF Gen2 Spec<uhf-gen2>` for the Lock payload bit definitions.

.. code-block:: python

    lock_config:
    {
        lock_config_payload: [0fffff]
    }

Tag Specific Feature Config
^^^^^^^^^^^^^^^^^^^^^^^^^^^
An Impinj ItemEncode device can configure tag specific features on certain 
Monza tags. This can be configured by the tag specific fields in the 
:ref:`SerializationJob<serialization-job>`, 
:ref:`TIDTableEntry<tid-table-entry>`, or
:ref:`OrderedListEntry<ordered-list-entry>`. This configuration will be ignored
if the device encounters a tag type that does not match the specified config.
For example, if only a monza_r6p_feature_config is provided and the device 
encounters a Monza S6-C tag, the device will not configure any of the tag 
specific features. If all other encoding operations also succeed, the tag will
be reported as encoded successfully. This behavior allows for multiple tag 
specific feature configurations to be specified and letting the device choose 
the appropriate one. This is useful when encoding a mixture of different tag 
types.
      
.. note:: These features are configured by writing to a single word in Reserved memory, so all options are required to be specified. 

.. note:: For more information on the tag specific features of each tag, please see their individual datasheets on the `Monza Tag Chip Products page <https://support.impinj.com/hc/en-us/categories/200156298-Monza-Chip-Products>`_.

.. code-block:: python

    monza_r6_feature_config:
    {
        enable_auto_tune: true
    }

    monza_r6p_feature_config:
    {
        enable_auto_tune: true
        enable_short_range_mode: false
        memory_map_config: MONZA_R6P_MEMORY_MAP_CONFIG_128_BIT_EPC_32_BIT_USER
    }

    monza_s6c_feature_config:
    {
        enable_auto_tune: true
        enable_short_range_mode: false
    }

