diff --git a/README.md b/README.md
index 668d769..382549a 100644
--- a/README.md
+++ b/README.md
@@ -113,6 +113,14 @@ simtrace2-pysniff-server --capture direct
simtrace2-pysniff-server --capture disabled
```
+The GSMTAP listener also accepts the **sigrok-iso7816-stream** decoder
+(https://github.com/anttro/sigrok_iso7816_stream) — an FX2-logic-analyzer
+passive SIM sniffer that emits the same GSMTAP-SIM format on UDP 4729. Its
+custom sub-types for RST/VCC line events (`0x10`/`0x11`, added for
+compatibility with that project) are decoded as `RESET ASSERTED/DE-ASSERTED`
+and `VCC ON/OFF` timeline markers, and a reset-assert or power-removal
+correctly invalidates the file-selection tracking.
+
Server options:
```
diff --git a/frontend/index.html b/frontend/index.html
index 61a6480..c3aeac3 100644
--- a/frontend/index.html
+++ b/frontend/index.html
@@ -124,6 +124,8 @@ body { font: 14px/1.5 system-ui, sans-serif; background: var(--bg); color: var(-
.apdu-type { color: var(--text); font-weight: 600; min-width: 150px; }
.apdu-type.atr { color: var(--green); }
.apdu-type.pps { color: var(--yellow); }
+.apdu-type.rst { color: var(--warn); }
+.apdu-type.vcc { color: var(--accent); }
.apdu-type.cat-proactive { font-weight: 700; color: var(--proactive); }
.apdu-type.cat-tr { font-weight: 700; color: var(--tr); }
.apdu-type.cat-envelope { color: var(--envelope); }
@@ -412,6 +414,13 @@ const INS_NAMES = {
};
// ──────────────────── UI Helpers ────────────────────
+function line_event_label(msg) {
+ const d = msg.decoded;
+ if (msg.type === 'rst') return d && d.event ? 'RESET ' + (d.event === 'reset asserted' ? 'ASSERTED' : 'DE-ASSERTED') : 'RESET';
+ if (msg.type === 'vcc') return d && d.event ? 'VCC ' + (d.event === 'power applied' ? 'ON' : 'OFF') : 'VCC';
+ return null;
+}
+
function ins_label(msg) {
if (msg.decoded && msg.decoded.cat_command) return msg.decoded.cat_command;
if (msg.decoded && msg.decoded.ins_name) return msg.decoded.ins_name;
@@ -420,6 +429,8 @@ function ins_label(msg) {
if (msg.type === 'change') return 'STATE CHANGE';
if (msg.type === 'fidi') return 'FIDI';
if (msg.type === 'gap') return 'CAPTURE GAP';
+ const le = line_event_label(msg);
+ if (le) return le;
const d = msg.data;
if (d && d.length >= 2) {
const ins = d.slice(2, 4);
@@ -434,6 +445,8 @@ function _fallback_label(msg) {
if (msg.type === 'change') return 'STATE CHANGE';
if (msg.type === 'fidi') return 'FIDI';
if (msg.type === 'gap') return 'CAPTURE GAP';
+ const le = line_event_label(msg);
+ if (le) return le;
const data = msg.data;
if (data && data.length >= 2) {
const ins = data.slice(2, 4);
@@ -1504,6 +1517,19 @@ function showDetail(msg, entry) {
return;
}
+ if (decoded.type === 'rst' || decoded.type === 'vcc') {
+ const evName = decoded.event || (decoded.type === 'rst' ? 'reset event' : 'power event');
+ d.innerHTML = `
+
+
+ | Event | ${evName} |
+ | Level | ${decoded.level || '?'} |
+ ${decoded.raw ? `| Raw | ${decoded.raw} |
` : ''}
+
+
`;
+ return;
+ }
+
if (decoded.type === 'fidi') {
d.innerHTML = `
@@ -1951,7 +1977,8 @@ function renderMessages(skipScroll) {
}
const label = ins_label(m);
const cat = command_cat(_ins_hex(m));
- const typeCls = (m.type === 'atr' ? 'atr' : m.type === 'pps' ? 'pps' : '') +
+ const typeCls = (m.type === 'atr' ? 'atr' : m.type === 'pps' ? 'pps'
+ : m.type === 'rst' ? 'rst' : m.type === 'vcc' ? 'vcc' : '') +
(cat ? ' cat-' + cat : '');
const errs = error_names(m);
const errBadge = errs ? `⚠` : '';
@@ -2484,7 +2511,7 @@ function onFilterChange() {
}
// ──────────────────── Versioning ────────────────────
-const PWA_VERSION = '1.20.2';
+const PWA_VERSION = '1.21.0';
const MIN_SERVER_VERSION = '1.0.0';
function parseVersion(v) {
diff --git a/frontend/sw.js b/frontend/sw.js
index d8ce4b6..5115efa 100644
--- a/frontend/sw.js
+++ b/frontend/sw.js
@@ -1,4 +1,4 @@
-const CACHE = 'simtrace-analyser-v30';
+const CACHE = 'simtrace-analyser-v31';
const PRECACHE = [
'index.html',
diff --git a/pyproject.toml b/pyproject.toml
index 61bf353..93fede2 100644
--- a/pyproject.toml
+++ b/pyproject.toml
@@ -4,7 +4,7 @@ build-backend = "setuptools.backends._legacy:_Backend"
[project]
name = "simtrace2-pysniff"
-version = "1.20.2"
+version = "1.21.0"
description = "Python-based sniffing tool for SIMtrace2 hardware (SIM card communication sniffer)"
readme = {file = "README.md", content-type = "text/markdown"}
license = {text = "GPL-2.0-or-later"}
diff --git a/simtrace2_pysniff/__init__.py b/simtrace2_pysniff/__init__.py
index bbcf1ce..0e98014 100644
--- a/simtrace2_pysniff/__init__.py
+++ b/simtrace2_pysniff/__init__.py
@@ -6,7 +6,7 @@ from .gsmtap import GsmtapSender, GsmtapReceiver
from .pcap import PcapWriter
from .dump import FileDumper, format_message
-__version__ = '1.20.2'
+__version__ = '1.21.0'
__all__ = [
'SniffSession',
'DeviceDisconnected',
diff --git a/simtrace2_pysniff/gsmtap.py b/simtrace2_pysniff/gsmtap.py
index e3a7faa..df1ca4e 100644
--- a/simtrace2_pysniff/gsmtap.py
+++ b/simtrace2_pysniff/gsmtap.py
@@ -14,6 +14,10 @@ GSMTAP_SIM_APDU = 0x00
GSMTAP_SIM_ATR = 0x01
GSMTAP_SIM_PPS_REQ = 0x02
GSMTAP_SIM_PPS_RSP = 0x03
+# Custom sub-types from the sigrok-iso7816-stream decoder
+# (github.com/anttro/sigrok_iso7816_stream): line-level events.
+GSMTAP_SIM_RST_EVENT = 0x10
+GSMTAP_SIM_VCC_EVENT = 0x11
GSMTAP_UDP_PORT = 4729
diff --git a/simtrace2_pysniff/pcap.py b/simtrace2_pysniff/pcap.py
index 25ee06a..950d319 100644
--- a/simtrace2_pysniff/pcap.py
+++ b/simtrace2_pysniff/pcap.py
@@ -32,6 +32,8 @@ GSMTAP_SIM_APDU = 0x00
GSMTAP_SIM_ATR = 0x01
GSMTAP_SIM_PPS_REQ = 0x02
GSMTAP_SIM_PPS_RSP = 0x03
+GSMTAP_SIM_RST_EVENT = 0x10 # sigrok-iso7816-stream custom sub-type
+GSMTAP_SIM_VCC_EVENT = 0x11 # sigrok-iso7816-stream custom sub-type
_GSMTAP_HDR_FMT = '!BBBBHBBIBBBB'
_GSMTAP_HDR_SIZE = struct.calcsize(_GSMTAP_HDR_FMT) # 16 bytes
@@ -48,6 +50,8 @@ _SUB_TYPE_NAMES = {
GSMTAP_SIM_ATR: 'atr',
GSMTAP_SIM_PPS_REQ: 'pps',
GSMTAP_SIM_PPS_RSP: 'pps',
+ GSMTAP_SIM_RST_EVENT: 'rst',
+ GSMTAP_SIM_VCC_EVENT: 'vcc',
}
# pcapng block types
diff --git a/simtrace2_pysniff/server/capture.py b/simtrace2_pysniff/server/capture.py
index 909381f..605ec90 100644
--- a/simtrace2_pysniff/server/capture.py
+++ b/simtrace2_pysniff/server/capture.py
@@ -3,7 +3,21 @@
import time
import threading
-from ..gsmtap import GsmtapReceiver, GSMTAP_SIM_ATR, GSMTAP_SIM_APDU
+from ..gsmtap import (GsmtapReceiver, GSMTAP_SIM_ATR,
+ GSMTAP_SIM_RST_EVENT, GSMTAP_SIM_VCC_EVENT)
+
+
+def gsmtap_msg_type(sub_type):
+ """Map a GSMTAP-SIM sub_type to a stored message type.
+
+ Custom sigrok-iso7816-stream line events (0x10/0x11) become 'rst'/'vcc';
+ everything except ATR defaults to 'tpdu'.
+ """
+ return {
+ GSMTAP_SIM_ATR: 'atr',
+ GSMTAP_SIM_RST_EVENT: 'rst',
+ GSMTAP_SIM_VCC_EVENT: 'vcc',
+ }.get(sub_type, 'tpdu')
class GsmtapListener:
@@ -23,8 +37,7 @@ class GsmtapListener:
sub_type, data = self._receiver.read_packet()
if sub_type is None:
continue
- msg_type = 'atr' if sub_type == GSMTAP_SIM_ATR else 'tpdu'
- yield msg_type, data, 0
+ yield gsmtap_msg_type(sub_type), data, 0
class DirectSniffer:
diff --git a/simtrace2_pysniff/server/database.py b/simtrace2_pysniff/server/database.py
index beefac5..30373c9 100644
--- a/simtrace2_pysniff/server/database.py
+++ b/simtrace2_pysniff/server/database.py
@@ -377,5 +377,16 @@ class Database:
if msg['flags'] & (CHANGE_FLAG_CARD_INSERT | CHANGE_FLAG_CARD_EJECT |
CHANGE_FLAG_RESET_ASSERT | CHANGE_FLAG_RESET_DEASSERT):
states = {}
+ elif msg['type'] in ('rst', 'vcc'):
+ # sigrok-iso7816-stream line events: a reset assert or power
+ # removal destroys the card's selection state. De-assert /
+ # power-on are markers only (the following ATR resets state).
+ data = row[4] if len(row) > 4 and row[4] else b''
+ if msg['type'] == 'rst':
+ if data and data[0] == 1: # asserted
+ states = {}
+ else: # vcc
+ if data and data[0] == 0: # power removed
+ states = {}
msgs.append(msg)
return msgs
diff --git a/simtrace2_pysniff/server/decode.py b/simtrace2_pysniff/server/decode.py
index d535cf5..7ff3e27 100644
--- a/simtrace2_pysniff/server/decode.py
+++ b/simtrace2_pysniff/server/decode.py
@@ -4002,6 +4002,26 @@ def decode_change(flags):
}
+def decode_line_event(raw_data, kind):
+ """Decode a sigrok-iso7816-stream RST/VCC line event (GSMTAP sub_type
+ 0x10/0x11): payload [direction, level, reserved].
+
+ direction — RST: 1 = asserted (high→low), 0 = de-asserted (low→high);
+ VCC: 1 = power applied (low→high), 0 = removed (high→low).
+ level — resulting line level: 0 = low, 1 = high.
+ """
+ result = {'type': kind}
+ if raw_data and len(raw_data) >= 2:
+ direction, level = raw_data[0], raw_data[1]
+ if kind == 'rst':
+ result['event'] = 'reset asserted' if direction else 'reset de-asserted'
+ else:
+ result['event'] = 'power applied' if direction else 'power removed'
+ result['level'] = 'high' if level else 'low'
+ result['raw'] = raw_data.hex().upper()
+ return result
+
+
def decode_data_flags(flags):
"""Decode SIMtrace2 sniff_data error flags into a list of names (or None)."""
if not flags:
@@ -4260,6 +4280,8 @@ def decode_sniff_msg(raw_data, msg_type, flags=0, prev=None):
return result
if msg_type == 'change':
return decode_change(flags)
+ if msg_type in ('rst', 'vcc'):
+ return decode_line_event(raw_data, msg_type)
if msg_type == 'fidi' and raw_data:
return decode_fidi(raw_data)
if msg_type == 'atr':
diff --git a/tests/test_capture.py b/tests/test_capture.py
index 4133d54..aeccae0 100644
--- a/tests/test_capture.py
+++ b/tests/test_capture.py
@@ -4,10 +4,21 @@ import os
import tempfile
import unittest
-from simtrace2_pysniff.server.capture import CaptureManager
+from simtrace2_pysniff.server.capture import CaptureManager, gsmtap_msg_type
from simtrace2_pysniff.server.database import Database
+class TestGsmtapSubtypeMapping(unittest.TestCase):
+ def test_custom_line_event_subtypes(self):
+ self.assertEqual(gsmtap_msg_type(0x10), 'rst')
+ self.assertEqual(gsmtap_msg_type(0x11), 'vcc')
+
+ def test_standard_subtypes(self):
+ self.assertEqual(gsmtap_msg_type(0x00), 'tpdu')
+ self.assertEqual(gsmtap_msg_type(0x01), 'atr')
+ self.assertEqual(gsmtap_msg_type(0x02), 'tpdu') # PPS combined
+
+
class _FakeBackend:
def __init__(self, messages=()):
self._messages = list(messages)
diff --git a/tests/test_decode.py b/tests/test_decode.py
index 085c135..cfdd1fb 100644
--- a/tests/test_decode.py
+++ b/tests/test_decode.py
@@ -2307,5 +2307,44 @@ class TestClaDecode(unittest.TestCase):
self.assertEqual(r['interclass'], 'ETSI-defined (SIM/GSM)')
+class TestLineEvents(unittest.TestCase):
+ """sigrok-iso7816-stream RST/VCC line events (GSMTAP 0x10/0x11)."""
+
+ def _dec(self, kind, payload):
+ from simtrace2_pysniff.server.decode import decode_line_event
+ return decode_line_event(bytes.fromhex(payload), kind)
+
+ def test_rst_asserted(self):
+ r = self._dec('rst', '010000')
+ self.assertEqual(r['type'], 'rst')
+ self.assertEqual(r['event'], 'reset asserted')
+ self.assertEqual(r['level'], 'low')
+
+ def test_rst_deasserted(self):
+ r = self._dec('rst', '000100')
+ self.assertEqual(r['event'], 'reset de-asserted')
+ self.assertEqual(r['level'], 'high')
+
+ def test_vcc_on(self):
+ r = self._dec('vcc', '010100')
+ self.assertEqual(r['event'], 'power applied')
+ self.assertEqual(r['level'], 'high')
+
+ def test_vcc_off(self):
+ r = self._dec('vcc', '000000')
+ self.assertEqual(r['event'], 'power removed')
+ self.assertEqual(r['level'], 'low')
+
+ def test_sniff_routing(self):
+ from simtrace2_pysniff.server.decode import decode_sniff_msg
+ self.assertEqual(decode_sniff_msg(b'\x01\x00\x00', 'rst')['type'], 'rst')
+ self.assertEqual(decode_sniff_msg(b'\x00\x01\x00', 'vcc')['type'], 'vcc')
+
+ def test_short_payload(self):
+ r = self._dec('rst', '01')
+ self.assertEqual(r['type'], 'rst')
+ self.assertNotIn('event', r)
+
+
if __name__ == '__main__':
unittest.main()
diff --git a/tests/test_pcap_import.py b/tests/test_pcap_import.py
index db050f4..e54d300 100644
--- a/tests/test_pcap_import.py
+++ b/tests/test_pcap_import.py
@@ -9,7 +9,9 @@ from simtrace2_pysniff.pcap import (
build_pcap, parse_pcap, parse_pcapng, wrap_gsmtap, extract_gsmtap,
LINKTYPE_ETHERNET,
)
-from simtrace2_pysniff.gsmtap import build_gsmtap_packet, GSMTAP_SIM_ATR, GSMTAP_SIM_APDU
+from simtrace2_pysniff.gsmtap import (build_gsmtap_packet, GSMTAP_SIM_ATR,
+ GSMTAP_SIM_APDU, GSMTAP_SIM_RST_EVENT,
+ GSMTAP_SIM_VCC_EVENT)
def _gsmtap_hdr(sub_type):
@@ -54,6 +56,19 @@ class TestParsePcap(unittest.TestCase):
(2.5, 'tpdu', b'\x80\xf2\x00\x00\x00'),
])
+ def test_roundtrip_line_events(self):
+ # sigrok-iso7816-stream custom sub-types survive a PCAP round-trip.
+ packets = [
+ (_gsmtap_hdr(GSMTAP_SIM_RST_EVENT), b'\x01\x00\x00', 1.0),
+ (_gsmtap_hdr(GSMTAP_SIM_VCC_EVENT), b'\x00\x00\x00', 1.5),
+ ]
+ data = build_pcap(packets)
+ parsed = [(round(ts, 1), t, payload) for ts, t, payload in parse_pcap(data)]
+ self.assertEqual(parsed, [
+ (1.0, 'rst', b'\x01\x00\x00'),
+ (1.5, 'vcc', b'\x00\x00\x00'),
+ ])
+
def test_no_gsmtap(self):
# A packet that is not GSMTAP-SIM yields nothing.
frame = wrap_gsmtap(b'\x03' + b'\x00' * 15) # type=3, not SIM
@@ -197,7 +212,7 @@ class TestImportEndpoint(unittest.TestCase):
class TestVersion(unittest.TestCase):
def test_package_version(self):
from simtrace2_pysniff import __version__
- self.assertEqual(__version__, '1.20.2')
+ self.assertEqual(__version__, '1.21.0')
def test_status_includes_version(self):
import os