GIAI

class epc.schemes.GIAI(*args, **kwargs)

The Global Individual Asset Identifier EPC scheme is used to assign a unique identity to a specific asset, such as a forklift or a computer.

The scheme supports two sizes: 96 bit and 202 bit tags. Alphanumeric character are supported on the larger size tag for the asset reference.

General syntax: urn:epc:id:giai:CompanyPrefix.IndividualAssetReference

Example: urn:epc:id:giai:0614141.1234540

Parameters
  • epc (str, optional) – Hexadecimal EPC tag data

  • barcode (str, optional) – GIAI barcode data

  • company_prefix_length (int, optional) – Number of digits in the company prefix. Required when specifying a barcode.

filter(tag_filter)

The filter value is additional control information that may be included in the EPC memory bank of a Gen 2 tag. The intended use of the filter value is to allow an RFID reader to select or deselect the tags corresponding to certain physical objects, to make it easier to read the desired tags in an environment where there may be other tags present in the environment. For example, if the goal is to read the single tag on a pallet, and it is expected that there may be hundreds or thousands of item-level tags present, the performance of the capturing application may be improved by using the Gen 2 air interface to select the pallet tag and deselect the item-level tags.

Allowed values for GIAI tags:

Value

Constant

Description

0

FILTER_ALL

All Others

1

FILTER_RAIL

Rail Vehicle

2-7

FILTER_RESERVED_*

Reserved

Parameters

tag_filter (int) – The filter value, defaults to FILTER_ALL.

Raises

AttributeError – Filter must be between 0 and 7.

Returns

The GIAI tag object.

Return type

epc.schemes.GIAI

company_prefix(company_prefix, company_prefix_length=None)

The GS1 Company Prefix, assigned by GS1 to a managing entity. The Company Prefix is the same as the GS1 Company Prefix digits within a GS1 GIAI key.

Length corresponds to the number of digits in the company prefix.

Parameters
  • company_prefix (str, int) – GS1 company prefix.

  • company_prefix_length (int, optional) – Number of digits in the company prefix. Required when company_prefix is an int.

Returns

The GIAI tag object.

Return type

epc.schemes.GIAI

asset_reference(asset_reference)

The Individual Asset Reference, assigned uniquely by the managing entity to a specific asset.

Parameters

asset_reference (str, int) – The asset reference.

Raises
  • AttributeError – Reference length must be less than 24 characters.

  • ValueError – Reference string character not encodeable.

Returns

The GIAI tag object.

Return type

epc.schemes.GIAI

tag_size()

Set the size for the tag. Options are SIZE_96 or SIZE_202.

Parameters

tag_size (int) – Tag size in bits. Defaults to SIZE_96.

Raises

AttributeError – Invalid tag size specified.

Returns

The GIAI tag object.

Return type

epc.schemes.GIAI

property tag_uri
Returns

The tag’s URI.

Return type

str

property pure_identity_uri
Returns

The tag’s pure identity URI.

Return type

str

property barcode
Returns

The barcode representation of the tag.

Return type

str

property barcode_humanized
Returns

A human readable barcode representation of the tag.

Return type

str

property values
Returns

Dictionary containing:

  • size (int): the tag’s size in bits

  • filter (int)

  • company_prefix (str)

  • asset_reference (int or str)

decode_epc(hex_string)

Decode an encoded tag and populate this object’s values from it.

Parameters

hex_string (str) – Tag data encoded as a hexadecimal string.

Raises
  • ValueError – EPC scheme header does not match input.

  • ValueError – Filter does not match allowed values.

  • ValueError – Supplied hex_string bit length invalid.

decode_barcode(barcode, company_prefix_length)

Decode a barcode and populate this object’s values from it.

Parameters
  • hex_string (str) – Barcode

  • company_prefix_length (int) – Number of digits of the company prefix length

Raises
  • ValueError – Expected barcode header does not match input.

  • AttributeError – Invalid barcode length, or wrong company prefix.

check_fields()

Checks to make sure all components of the tag are present, including size, filter, company_prefix and asset_reference.

Raises

AttributeError – If any components of the tag are missing.

Hint

To get the encoded tag data, use python’s built in conversion methods:

>>> tag = GIAI()
>>> tag.company_prefix('000200').asset_reference(50)

# Hexadecimal
>>> hex(tag)
'0x341800320000000000000032'

# Binary
>>> bin(tag)
'0b1101000001100000000000001100100000000000000000000000000000000000000000000000000000000000110010'

Constants

Filters

GIAI.FILTER_ALL
GIAI.FILTER_RAIL
GIAI.FILTER_RESERVED_*

Replace asterisk with 2-7.

Sizes

GIAI.SIZE_96

96 bit tag size.

GIAI.SIZE_202

202 bit tag size. Supports alphanumeric characters for the asset reference.

Headers

GIAI.HEADER_BARCODE

GS1 specified barcode header: 8004.

GIAI.HEADER_96

GS1 specified hexadecimal header for 96 bit GIAI tags: 0x34.

GIAI.HEADER_202

GS1 specified hexadecimal header for 202 bit GIAI tags: 0x38.

GIAI.GIAI_96

Human readable GS1 specified header for 96 bit GIAI tags: giai-96.

GIAI.GIAI_202

Human readable GS1 specified header for 202 bit GIAI tags: giai-202.