Skip to content

Commit 1d2e837

Browse files
TigerTag: read tag index and tag count
Read the tag index / tag count byte (offset +39, TigerTag spec v2.2): the high nibble is the index of the tag that was read, the low nibble is the number of tags on the item (0x12 = tag 1 of 2). 0 means unknown, which is what every tag written before v2.2 contains. - Add tag_index and tag_count to GenericFilament (default 0 = unknown), exposed in to_dict() and shown in pretty_text() when the count is known - Add twin-tag fixtures (tag 1 of 2, tag 2 of 2) built from the eSun TigerTag+ dump, and check that the existing dump reads as unknown
1 parent a13bc9e commit 1d2e837

8 files changed

Lines changed: 64 additions & 3 deletions

‎src/filament/generic.py‎

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,9 @@ def __init__(self,
2626
drying_temp_c: float,
2727
drying_time_hours: float,
2828
manufacturing_date: str, # ISO 8601 date string
29-
td: float = 0.0 # Transmission Distance in mm for HueForge/OrcaSlicer-FullSpectrum
29+
td: float = 0.0, # Transmission Distance in mm for HueForge/OrcaSlicer-FullSpectrum
30+
tag_index: int = 0, # Which tag of the item was read (1-based), 0 = unknown
31+
tag_count: int = 0, # Number of tags on the item (2 = twin tags), 0 = unknown
3032
):
3133
self.source_processor = source_processor
3234
self.unique_id = unique_id
@@ -43,6 +45,8 @@ def __init__(self,
4345
self.drying_time_hours = drying_time_hours
4446
self.manufacturing_date = manufacturing_date
4547
self.td = td
48+
self.tag_index = tag_index
49+
self.tag_count = tag_count
4650

4751
if "CF" in self.modifiers:
4852
self.type += "-CF"
@@ -71,7 +75,7 @@ def pretty_text(self) -> str:
7175
f"- Drying: {self.drying_temp_c:.1f}C for {self.drying_time_hours:.1f} hours",
7276
f"- Manufactured on: {self.manufacturing_date}",
7377
f"- TD: {self.td:.1f} mm"
74-
])
78+
] + ([f"- Tag: {self.tag_index or '?'} of {self.tag_count}"] if self.tag_count else []))
7579

7680
@property
7781
def rgba(self) -> int:
@@ -102,7 +106,9 @@ def to_dict(self) -> dict:
102106
"drying_temp_c": self.drying_temp_c,
103107
"drying_time_hours": self.drying_time_hours,
104108
"manufacturing_date": self.manufacturing_date,
105-
"td": self.td
109+
"td": self.td,
110+
"tag_index": self.tag_index,
111+
"tag_count": self.tag_count
106112
}
107113

108114
@staticmethod

‎src/tag/tigertag/constants.py‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@
2020
OFF_BED_TEMP_MIN = 30
2121
OFF_BED_TEMP_MAX = 31
2222
OFF_TIMESTAMP = 32
23+
OFF_TAG_INDEX_COUNT = 39 # high nibble = tag index, low nibble = tag count, 0 = unknown
2324
OFF_TD = 44
2425
OFF_METADATA = 48
2526
OFF_SIGNATURE = 80

‎src/tag/tigertag/processor.py‎

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -68,6 +68,17 @@ def __parse_tigertag(self, scan_result: ScanResult, user_data: bytes, tag_id: in
6868

6969
timestamp_raw = struct.unpack_from('>I', user_data, Constants.OFF_TIMESTAMP)[0]
7070

71+
# Tag index / count (spec v2.2): 0x12 = tag 1 of 2. Tags written
72+
# before v2.2 have 0x00 here, which means unknown.
73+
tag_index = 0
74+
tag_count = 0
75+
if len(user_data) > Constants.OFF_TAG_INDEX_COUNT:
76+
index_count = user_data[Constants.OFF_TAG_INDEX_COUNT]
77+
tag_index = index_count >> 4
78+
tag_count = index_count & 0x0F
79+
if tag_index > tag_count:
80+
tag_index = 0
81+
7182
material_label = self.registry.material_ids.get(material_id, f"Unknown({material_id})")
7283
material_type = self.registry.material_type_ids.get(material_id, material_label)
7384
filled_type = self.registry.filled_type_ids.get(material_id, "")
@@ -100,6 +111,7 @@ def __parse_tigertag(self, scan_result: ScanResult, user_data: bytes, tag_id: in
100111
self.logger.debug(" Bed Temp: %d-%d °C", bed_temp_min, bed_temp_max)
101112
self.logger.debug(" TD: raw=%d → %.1f mm", td_raw, td_mm)
102113
self.logger.debug(" Timestamp: %d (%s)", timestamp_raw, manufacturing_date)
114+
self.logger.debug(" Tag: %d of %d", tag_index, tag_count)
103115

104116
return GenericFilament(
105117
source_processor=self.name,
@@ -120,6 +132,8 @@ def __parse_tigertag(self, scan_result: ScanResult, user_data: bytes, tag_id: in
120132
drying_time_hours=float(dry_time),
121133
manufacturing_date=manufacturing_date,
122134
td=td_mm,
135+
tag_index=tag_index,
136+
tag_count=tag_count,
123137
)
124138

125139
except Exception as e:
Binary file not shown.
Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
bed_temp_c: 0.0
2+
colors:
3+
- 0xFFDDE5ED
4+
diameter_mm: 1.75
5+
drying_temp_c: 50.0
6+
drying_time_hours: 8.0
7+
hotend_max_temp_c: 230.0
8+
hotend_min_temp_c: 210.0
9+
manufacturer: eSun
10+
manufacturing_date: '2025-11-12'
11+
modifiers:
12+
- Basic
13+
source_processor: TigerTagProcessor
14+
td: 0.0
15+
type: PLA
16+
unique_id: c97d79c4ec83c89e5063834556625468b602e492996bfd674fbbeb238469d031
17+
weight_grams: 1000.0
18+
tag_index: 1
19+
tag_count: 2
Binary file not shown.
Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
bed_temp_c: 0.0
2+
colors:
3+
- 0xFFDDE5ED
4+
diameter_mm: 1.75
5+
drying_temp_c: 50.0
6+
drying_time_hours: 8.0
7+
hotend_max_temp_c: 230.0
8+
hotend_min_temp_c: 210.0
9+
manufacturer: eSun
10+
manufacturing_date: '2025-11-12'
11+
modifiers:
12+
- Basic
13+
source_processor: TigerTagProcessor
14+
td: 0.0
15+
type: PLA
16+
unique_id: c97d79c4ec83c89e5063834556625468b602e492996bfd674fbbeb238469d031
17+
weight_grams: 1000.0
18+
tag_index: 2
19+
tag_count: 2

‎test/tags/Tigertag/eSun PLA Basic Refill Cold White TigerTag+.yml‎

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,3 +15,5 @@ td: 0.0
1515
type: PLA
1616
unique_id: c97d79c4ec83c89e5063834556625468b602e492996bfd674fbbeb238469d031
1717
weight_grams: 1000.0
18+
tag_index: 0
19+
tag_count: 0

0 commit comments

Comments
 (0)