@@ -137,7 +137,9 @@ def _check_inpos(self) -> None:
137
137
drive_says_track0 = not self ._track0 .value
138
138
we_think_track0 = track == 0
139
139
if drive_says_track0 != we_think_track0 :
140
- raise RuntimeError (f"Drive lost position (target={ track } , track0 sensor { drive_says_track0 } )" )
140
+ raise RuntimeError (
141
+ f"Drive lost position (target={ track } , track0 sensor { drive_says_track0 } )"
142
+ )
141
143
142
144
@property
143
145
def track (self ) -> typing .Optional [int ]:
@@ -217,7 +219,7 @@ def flux_readinto(self, buf: "circuitpython_typing.WritableBuffer") -> int:
217
219
return floppyio .flux_readinto (buf , self ._rddata , self ._index )
218
220
219
221
220
- class FloppyBlockDevice :
222
+ class FloppyBlockDevice : # pylint: disable=too-many-instance-attributes
221
223
"""Wrap an MFMFloppy object into a block device suitable for `storage.VfsFat`
222
224
223
225
The default heads/sectors/tracks setting are for 3.5", 1.44MB floppies.
@@ -238,12 +240,20 @@ class FloppyBlockDevice:
238
240
print(os.listdir("/floppy"))
239
241
"""
240
242
241
- def __init__ (self , floppy , heads = 2 , sectors = 18 , tracks = 80 , flux_buffer = None , t1_nom_ns : float = 1000 ):
243
+ def __init__ ( # pylint: disable=too-many-arguments
244
+ self ,
245
+ floppy ,
246
+ heads = 2 ,
247
+ sectors = 18 ,
248
+ tracks = 80 ,
249
+ flux_buffer = None ,
250
+ t1_nom_ns : float = 1000 ,
251
+ ):
242
252
self .floppy = floppy
243
253
self .heads = heads
244
254
self .sectors = sectors
245
255
self .tracks = tracks
246
- self .flux_buffer = flux_buffer or buffer (sectors * 12 * 512 )
256
+ self .flux_buffer = flux_buffer or bytearray (sectors * 12 * 512 )
247
257
self .track0side0_cache = memoryview (bytearray (sectors * 512 ))
248
258
self .track0side0_validity = bytearray (sectors )
249
259
self .track_cache = memoryview (bytearray (sectors * 512 ))
@@ -257,7 +267,6 @@ def __init__(self, floppy, heads=2, sectors=18, tracks=80, flux_buffer=None, t1_
257
267
self .cached_track = - 1
258
268
self .cached_side = - 1
259
269
260
-
261
270
def deinit (self ):
262
271
"""Deinitialize this object"""
263
272
self .floppy .deinit ()
@@ -316,5 +325,13 @@ def _mfm_readinto(self, track_data, validity):
316
325
for i in range (5 ):
317
326
self .floppy .flux_readinto (self .flux_buffer )
318
327
print ("timing bins" , self ._t2_5_max , self ._t3_5_max )
319
- n = floppyio .mfm_readinto (track_data , self .flux_buffer , self ._t2_5_max , self ._t3_5_max , validity , i == 0 )
320
- if n == self .sectors : break
328
+ n = floppyio .mfm_readinto (
329
+ track_data ,
330
+ self .flux_buffer ,
331
+ self ._t2_5_max ,
332
+ self ._t3_5_max ,
333
+ validity ,
334
+ i == 0 ,
335
+ )
336
+ if n == self .sectors :
337
+ break
0 commit comments