Skip to main content

GS1 EPC Tag Data Translation for Python and RAIN (UHF) RFID. Encode and decode SGTIN, SSCC, SGLN, GRAI, and all EPC schemes.

Project description

tag-data-translation

GS1 EPC Tag Data Translation for Python and RAIN (UHF) RFID. Encode and decode SGTIN, SSCC, SGLN, GRAI, and all EPC schemes defined in TDT 2.2 and TDS 2.3.

Requirements

  • Python 3.9+
  • .NET 8.0+ runtime (download)

Installation

pip install tag-data-translation

Usage

from tag_data_translation import TDTEngine

engine = TDTEngine()

# encode GTIN to EPC hex
binary = engine.translate(
    "gtin=00037000302414;serial=10419703",
    "filter=1;gs1companyprefixlength=7;tagLength=96",
    "BINARY"
)
hex_value = engine.binary_to_hex(binary)
print(hex_value)  # 30340242201d8840009efdf7

# decode EPC hex to all fields
binary = engine.hex_to_binary("30340242201d8840009efdf7")
result = engine.translate_details(binary, "tagLength=96", "TAG_ENCODING")
print(result.output)   # urn:epc:tag:sgtin-96:1.0037000.030241.10419703
print(result.fields)   # {'filter': '1', 'gs1companyprefix': '0037000', ...}

Error handling

translate() raises TranslationError on invalid input. Use try_translate() for a non-throwing alternative:

from tag_data_translation import TDTEngine, TranslationError

engine = TDTEngine()

# raises on error
try:
    result = engine.translate(epc, params, "BINARY")
except TranslationError as e:
    print(f"Translation failed: {e}")

# returns None on error
result = engine.try_translate(epc, params, "BINARY")
if result is not None:
    print(result)

Performance

The underlying .NET engine translates a typical SGTIN-96 in ~8 us. The pythonnet bridge adds minimal overhead on top of the native .NET performance.

Operation .NET native
SGTIN-96 encode 7.8 us
SGTIN-96 decode 7.7 us
HexToBinary (96-bit) 99 ns
BinaryToHex (96-bit) 54 ns

License

BSL 1.1 — see LICENSING.md

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

tag_data_translation-3.0.1.tar.gz (651.1 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

tag_data_translation-3.0.1-py3-none-any.whl (750.1 kB view details)

Uploaded Python 3

File details

Details for the file tag_data_translation-3.0.1.tar.gz.

File metadata

  • Download URL: tag_data_translation-3.0.1.tar.gz
  • Upload date:
  • Size: 651.1 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.13.7

File hashes

Hashes for tag_data_translation-3.0.1.tar.gz
Algorithm Hash digest
SHA256 c1f1c6f3f8640ef34be8e255afcf3a39d19ab1c04358d04e4a3f4cc9fb1d3c4c
MD5 e15c4fcd7a5f6101ef0c90d084a1f17a
BLAKE2b-256 37c93fe920ee1b00436e8c799ad546a241ce42ddc1afc977dee860f7eab32308

See more details on using hashes here.

File details

Details for the file tag_data_translation-3.0.1-py3-none-any.whl.

File metadata

File hashes

Hashes for tag_data_translation-3.0.1-py3-none-any.whl
Algorithm Hash digest
SHA256 5284eef3830d4256d3008989802ca560d711dd927d0a6f58cd5beac61784d425
MD5 f3c4d4c7c2da18b32ed6ce9befdcc6fc
BLAKE2b-256 81d0f82cab515e37b1118caa7e66248969986b35666965f95f03a88495be3629

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page