File tree Expand file tree Collapse file tree 3 files changed +27
-4
lines changed
Expand file tree Collapse file tree 3 files changed +27
-4
lines changed Original file line number Diff line number Diff line change 11
2- __version__ = "1.10 .0"
2+ __version__ = "1.11 .0"
33
44__all__ = ["epsonprinter" ,"testpage" ]
55
Original file line number Diff line number Diff line change 22from contextlib import contextmanager
33import usb .core
44import usb .util
5- import time
65
6+ from .utils import to_hex , byte_to_bits
77
88
99ESC = 27
@@ -148,7 +148,7 @@ def in_endpoint_match(ep):
148148
149149
150150 def write_bytes (self , byte_array , timeout = 5000 ):
151- msg = '' . join ([ chr ( b ) for b in byte_array ] )
151+ msg = to_hex ( byte_array )
152152 self .write (msg , timeout )
153153
154154 def write (self , msg , timeout = 5000 ):
@@ -247,7 +247,8 @@ def paper_present(self):
247247 self .transmit_real_time_status (4 )
248248 with time_limit (1 ):
249249 data = self .blocking_read ()
250- return data == 18
250+ bits = byte_to_bits (data )
251+ return bits [5 ] == 0
251252 except :
252253 return False
253254
Original file line number Diff line number Diff line change 1+ import math
2+
3+
4+ def to_hex (arr ):
5+ """ convert a decimal array to an hexadecimal String"""
6+ return '' .join (chr (b ) for b in arr )
7+
8+
9+ def byte_to_bits (b ):
10+
11+ assert b <= 255
12+
13+ r = b
14+
15+ bits = {}
16+
17+ for i in range (0 , 8 ):
18+ a = math .pow (2 , 7 - i )
19+ bits [7 - i ] = int (r // a )
20+ r = r % a
21+
22+ return bits
You can’t perform that action at this time.
0 commit comments