@@ -76,14 +76,14 @@ def _wait_ready(self, timeout=1):
76
76
status = bytearray ([reverse_bit (_SPI_STATREAD ), 0 ])
77
77
78
78
timestamp = time .monotonic ()
79
- while ( time . monotonic () - timestamp ) < timeout :
80
- with self . _spi as spi :
81
- # time.sleep(0.02) # required
79
+ with self . _spi as spi :
80
+ while ( time . monotonic () - timestamp ) < timeout :
81
+ time .sleep (0.02 ) # required (not needed when tested on rPi 3)
82
82
spi .write_readinto (status , status ) #pylint: disable=no-member
83
- if reverse_bit (status [1 ]) == 0x01 : # LSB data is read in MSB
84
- return True # Not busy anymore!
85
- # else:
86
- # time.sleep(0.01) # pause a bit till we ask again
83
+ if reverse_bit (status [1 ]) == 0x01 : # LSB data is read in MSB
84
+ return True # Not busy anymore!
85
+ else : # (not needed when tested on rPi 3)
86
+ time .sleep (0.01 ) # pause a bit till we ask again
87
87
# We timed out!
88
88
return False
89
89
@@ -95,21 +95,21 @@ def _read_data(self, count):
95
95
frame [0 ] = reverse_bit (_SPI_DATAREAD )
96
96
97
97
with self ._spi as spi :
98
- # time.sleep(0.02) # required
98
+ time .sleep (0.02 ) # required (not needed when tested on rPi 3)
99
99
spi .write_readinto (frame , frame ) #pylint: disable=no-member
100
100
for i , val in enumerate (frame ):
101
101
frame [i ] = reverse_bit (val ) # turn LSB data to MSB
102
- # if self.debug:
103
- # print("Reading: ", [hex(i) for i in frame[1:]])
102
+ if self .debug :
103
+ print ("Reading: " , [hex (i ) for i in frame [1 :]])
104
104
return frame [1 :]
105
105
106
106
def _write_data (self , framebytes ):
107
107
"""Write a specified count of bytes to the PN532"""
108
108
# start by making a frame with data write in front,
109
109
# then rest of bytes, and LSBify it
110
110
rev_frame = [reverse_bit (x ) for x in bytes ([_SPI_DATAWRITE ]) + framebytes ]
111
- # if self.debug:
112
- # print("Writing: ", [hex(i) for i in rev_frame])
111
+ if self .debug :
112
+ print ("Writing: " , [hex (i ) for i in rev_frame ])
113
113
with self ._spi as spi :
114
- # time.sleep(0.02) # required
114
+ time .sleep (0.02 ) # required (not needed when tested on rPi 3)
115
115
spi .write (bytes (rev_frame )) #pylint: disable=no-member
0 commit comments