Commit 18e1fb7
Add Sony RC-S956 support and multi-device PN53x discovery (#224)
* Add Sony RC-S956 support and multi-device PN53x discovery
Handle PN53x error frames (0x7F) in transport layer by throwing
PN533CommandException, enabling graceful fallback when SAMConfiguration
is unsupported. RC-S956 devices (Sony RC-S370/P) use an alternative
init sequence: resetMode + setParameters + RF configuration.
Add openAll() to PN533Device for multi-device discovery, and wire
dynamic backend creation in DesktopCardScanner so all connected
PN53x readers scan independently.
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
* Remove resetMode from RC-S956 init, guard writeRegister
resetMode (cmd 0x18) returns error frame 0x7F on the RC-S370/P —
the device is already in reader mode over USB so it's not needed.
writeRegister (cmd 0x08) may also be unsupported on some firmware
versions, so wrap it in try/catch.
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
* Make RC-S956 init resilient: try each command individually
Wrap every init command in tryCommand() so unsupported commands
are logged and skipped rather than crashing the backend. This lets
us see exactly which commands the RC-S956 accepts.
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
* Match nfcpy rcs956.py init sequence exactly
Key fixes based on reading nfcpy source:
- resetMode() must send ACK frame + 10ms delay after command
- Never try SAMConfiguration on RC-S956 (corrupts state machine)
- Detect RC-S956 from firmware version (version < 2)
- Use nfcpy's exact init order: resetMode, rfFieldOff, RF config,
setParameters, resetMode again, writeRegister
- Fix 106A RF config first byte: 0x5A not 0x59
- Use nfcpy's MaxRetries values: [0x00, 0x00, 0x01]
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
* Separate RC-S956 into its own backend class
Extract shared poll/read logic into abstract PN53xReaderBackend.
PN533ReaderBackend now only contains the SAM-based init (untouched
from the PN533 PR). RCS956ReaderBackend has the nfcpy-based init
sequence in complete isolation.
DesktopCardScanner probes firmware version to create the right
backend type for each discovered transport.
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
* Fix RC-S956 mute: use auto RFCA (0x02) not RF off (0x00)
nfcpy's mute() sends rf_configuration(0x01, [0x02]) which enables
auto RF collision avoidance — the field activates on demand when
InListPassiveTarget polls. Our rfFieldOff() was sending 0x00 which
fully disables the field, causing InListPassiveTarget to return
error frame 0x7F.
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
* Match nfcpy init exactly: initial ACK + 3 resetMode calls
nfcpy init(transport) sends ACK as the very first action before
any commands. Device.__init__ then does:
resetMode #1 → getFirmwareVersion → mute (resetMode #2 + auto
RFCA) → RF config → setParameters → resetMode #3 → writeRegister
Previously we were probing firmware before sending ACK, and only
had 2 resetMode calls instead of 3 (mute calls resetMode + rfConfig,
not just rfConfig).
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
* Fix FeliCa polling on RC-S956: pass SENSF_REQ initiator data
RC-S956 requires explicit SENSF_REQ initiator data (00 FF FF 01 00) for
FeliCa InListPassiveTarget, unlike PN533 which generates defaults
internally. Without it, RC-S956 returns error frame 0x7F.
- Pass SENSF_REQ in both pollLoop and waitForRemoval FeliCa polls
- Catch PN533CommandException in inListPassiveTarget as fallback
- Add wire-level debug logging (disabled by default)
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
* Use InCommunicateThru for RC-S956 ISO-DEP data exchange
RC-S956 firmware does not support InDataExchange (0x40), returning error
frame 0x7F. nfcpy uses InCommunicateThru (0x42) for all target
communication on PN53x devices.
Add PN533CommunicateThruTransceiver that wraps APDUs in ISO-DEP I-blocks
(alternating block numbers) and handles S(WTX) waiting time extensions.
RC-S956 backend overrides createTransceiver to use it.
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
---------
Co-authored-by: Claude Opus 4.6 <noreply@anthropic.com>1 parent d1b6c42 commit 18e1fb7
File tree
8 files changed
+505
-196
lines changed- app/desktop/src/jvmMain/kotlin/com/codebutler/farebot/desktop
- card/src/jvmMain/kotlin/com/codebutler/farebot/card/nfc/pn533
8 files changed
+505
-196
lines changedLines changed: 27 additions & 6 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
23 | 23 | | |
24 | 24 | | |
25 | 25 | | |
| 26 | + | |
| 27 | + | |
26 | 28 | | |
27 | 29 | | |
28 | 30 | | |
| |||
63 | 65 | | |
64 | 66 | | |
65 | 67 | | |
66 | | - | |
67 | | - | |
68 | | - | |
69 | | - | |
70 | | - | |
71 | | - | |
72 | 68 | | |
73 | 69 | | |
74 | 70 | | |
75 | 71 | | |
76 | 72 | | |
77 | 73 | | |
| 74 | + | |
78 | 75 | | |
79 | 76 | | |
80 | 77 | | |
| |||
116 | 113 | | |
117 | 114 | | |
118 | 115 | | |
| 116 | + | |
| 117 | + | |
| 118 | + | |
| 119 | + | |
| 120 | + | |
| 121 | + | |
| 122 | + | |
| 123 | + | |
| 124 | + | |
| 125 | + | |
| 126 | + | |
| 127 | + | |
| 128 | + | |
| 129 | + | |
| 130 | + | |
| 131 | + | |
| 132 | + | |
| 133 | + | |
| 134 | + | |
| 135 | + | |
| 136 | + | |
| 137 | + | |
| 138 | + | |
| 139 | + | |
119 | 140 | | |
120 | 141 | | |
Lines changed: 8 additions & 181 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
22 | 22 | | |
23 | 23 | | |
24 | 24 | | |
25 | | - | |
26 | | - | |
27 | | - | |
28 | | - | |
29 | | - | |
30 | | - | |
31 | 25 | | |
32 | | - | |
33 | | - | |
34 | | - | |
35 | | - | |
36 | | - | |
37 | | - | |
38 | | - | |
39 | | - | |
40 | | - | |
| 26 | + | |
41 | 27 | | |
42 | 28 | | |
43 | | - | |
44 | | - | |
45 | | - | |
46 | | - | |
| 29 | + | |
47 | 30 | | |
48 | | - | |
| 31 | + | |
| 32 | + | |
| 33 | + | |
49 | 34 | | |
50 | 35 | | |
51 | | - | |
52 | | - | |
53 | | - | |
54 | | - | |
55 | | - | |
56 | | - | |
57 | | - | |
58 | | - | |
59 | | - | |
60 | | - | |
61 | | - | |
62 | | - | |
63 | | - | |
64 | | - | |
65 | | - | |
66 | | - | |
67 | | - | |
68 | | - | |
69 | | - | |
70 | | - | |
| 36 | + | |
71 | 37 | | |
72 | | - | |
73 | | - | |
| 38 | + | |
74 | 39 | | |
75 | | - | |
76 | | - | |
77 | | - | |
78 | | - | |
79 | | - | |
80 | | - | |
81 | | - | |
82 | | - | |
83 | | - | |
84 | | - | |
85 | | - | |
86 | | - | |
87 | | - | |
88 | | - | |
89 | | - | |
90 | | - | |
91 | | - | |
92 | | - | |
93 | | - | |
94 | | - | |
95 | | - | |
96 | | - | |
97 | | - | |
98 | | - | |
99 | | - | |
100 | | - | |
101 | | - | |
102 | | - | |
103 | | - | |
104 | | - | |
105 | | - | |
106 | | - | |
107 | | - | |
108 | | - | |
109 | | - | |
110 | | - | |
111 | | - | |
112 | | - | |
113 | | - | |
114 | | - | |
115 | | - | |
116 | | - | |
117 | | - | |
118 | | - | |
119 | | - | |
120 | | - | |
121 | | - | |
122 | | - | |
123 | | - | |
124 | | - | |
125 | | - | |
126 | | - | |
127 | | - | |
128 | | - | |
129 | | - | |
130 | | - | |
131 | | - | |
132 | | - | |
133 | | - | |
134 | | - | |
135 | | - | |
136 | | - | |
137 | | - | |
138 | | - | |
139 | | - | |
140 | | - | |
141 | | - | |
142 | | - | |
143 | | - | |
144 | | - | |
145 | | - | |
146 | | - | |
147 | | - | |
148 | | - | |
149 | | - | |
150 | | - | |
151 | | - | |
152 | | - | |
153 | | - | |
154 | | - | |
155 | | - | |
156 | | - | |
157 | | - | |
158 | | - | |
159 | | - | |
160 | | - | |
161 | | - | |
162 | | - | |
163 | | - | |
164 | | - | |
165 | | - | |
166 | | - | |
167 | | - | |
168 | | - | |
169 | | - | |
170 | | - | |
171 | | - | |
172 | | - | |
173 | | - | |
174 | | - | |
175 | | - | |
176 | | - | |
177 | | - | |
178 | | - | |
179 | | - | |
180 | | - | |
181 | | - | |
182 | | - | |
183 | | - | |
184 | | - | |
185 | | - | |
186 | | - | |
187 | | - | |
188 | | - | |
189 | | - | |
190 | | - | |
191 | | - | |
192 | | - | |
193 | | - | |
194 | | - | |
195 | | - | |
196 | | - | |
197 | | - | |
198 | | - | |
199 | | - | |
200 | | - | |
201 | | - | |
202 | | - | |
203 | | - | |
204 | | - | |
205 | | - | |
206 | | - | |
207 | | - | |
208 | | - | |
209 | | - | |
210 | | - | |
211 | | - | |
212 | | - | |
213 | | - | |
| 40 | + | |
214 | 41 | | |
215 | 42 | | |
0 commit comments