@@ -481,21 +481,21 @@ def write(self, data):
481
481
# Compute length low and high bytes.
482
482
# NOTE: Must actually send length minus one because the MPSSE engine
483
483
# considers 0 a length of 1 and FFFF a length of 65536
484
- # splitting into two lists for two commands to prevent buffer errors
485
- data1 = data [:len (data )/ 2 ]
486
- data2 = data [len (data )/ 2 :]
484
+ # splitting into two lists for two commands to prevent buffer errors
485
+ data1 = data [:len (data )/ 2 ]
486
+ data2 = data [len (data )/ 2 :]
487
487
len_low1 = (len (data1 ) - 1 ) & 0xFF
488
488
len_high1 = ((len (data1 ) - 1 ) >> 8 ) & 0xFF
489
- len_low2 = (len (data2 ) - 1 ) & 0xFF
489
+ len_low2 = (len (data2 ) - 1 ) & 0xFF
490
490
len_high2 = ((len (data2 ) - 1 ) >> 8 ) & 0xFF
491
491
self ._assert_cs ()
492
492
# Send command and length, then data, split into two commands, handle for length 1
493
- if len (data1 ) > 0 :
493
+ if len (data1 ) > 0 :
494
494
self ._ft232h ._write (str (bytearray ((command , len_low1 , len_high1 ))))
495
495
self ._ft232h ._write (str (bytearray (data1 )))
496
496
if len (data2 ) > 0 :
497
- self ._ft232h ._write (str (bytearray ((command , len_low2 , len_high2 ))))
498
- self ._ft232h ._write (str (bytearray (data2 )))
497
+ self ._ft232h ._write (str (bytearray ((command , len_low2 , len_high2 ))))
498
+ self ._ft232h ._write (str (bytearray (data2 )))
499
499
self ._deassert_cs ()
500
500
501
501
def read (self , length ):
@@ -513,13 +513,13 @@ def read(self, length):
513
513
# Compute length low and high bytes.
514
514
# NOTE: Must actually send length minus one because the MPSSE engine
515
515
# considers 0 a length of 1 and FFFF a length of 65536
516
- #force odd numbers to round up instead of down
517
- lengthR = length
518
- if length % 2 == 1 :
519
- lengthR += 1
520
- lengthR = lengthR / 2
521
- #when odd length requested, get the remainder instead of the same number
522
- lenremain = length - lengthR
516
+ #force odd numbers to round up instead of down
517
+ lengthR = length
518
+ if length % 2 == 1 :
519
+ lengthR += 1
520
+ lengthR = lengthR / 2
521
+ #when odd length requested, get the remainder instead of the same number
522
+ lenremain = length - lengthR
523
523
len_low = (lengthR - 1 ) & 0xFF
524
524
len_high = ((lengthR - 1 ) >> 8 ) & 0xFF
525
525
self ._assert_cs ()
@@ -559,12 +559,12 @@ def bulkread(self, data = [], lengthR = 'None', readmode = 1):
559
559
len_highW = ((lengthW ) >> 8 ) & 0xFF
560
560
commandR = 0x20 | (self .lsbfirst << 3 ) | (self .read_clock_ve << 2 )
561
561
#force odd numbers to round up instead of down
562
- length = lengthR
563
- if lengthR % 2 == 1 :
564
- length += 1
565
- length = length / 2
562
+ length = lengthR
563
+ if lengthR % 2 == 1 :
564
+ length += 1
565
+ length = length / 2
566
566
#when odd length requested, get the remainder instead of the same number
567
- lenremain = lengthR - length
567
+ lenremain = lengthR - length
568
568
len_lowR = (length - 1 ) & 0xFF
569
569
len_highR = ((length - 1 ) >> 8 ) & 0xFF
570
570
#logger debug info
@@ -602,25 +602,25 @@ def transfer(self, data):
602
602
# NOTE: Must actually send length minus one because the MPSSE engine
603
603
# considers 0 a length of 1 and FFFF a length of 65536
604
604
data1 = data [:len (data )/ 2 ]
605
- data2 = data [len (data )/ 2 :]
606
- len_low1 = (len (data1 ) - 1 ) & 0xFF
605
+ data2 = data [len (data )/ 2 :]
606
+ len_low1 = (len (data1 ) - 1 ) & 0xFF
607
607
len_high1 = ((len (data1 ) - 1 ) >> 8 ) & 0xFF
608
- len_low2 = (len (data2 ) - 1 ) & 0xFF
608
+ len_low2 = (len (data2 ) - 1 ) & 0xFF
609
609
len_high2 = ((len (data2 ) - 1 ) >> 8 ) & 0xFF
610
- payload1 = ''
611
- payload2 = ''
612
- #start command set
610
+ payload1 = ''
611
+ payload2 = ''
612
+ #start command set
613
613
self ._assert_cs ()
614
614
# Perform twice to prevent error from hardware defect/limits
615
- # Send command and length, then data, split into two commands, handle for length 1
616
- if len (data1 ) > 0 :
617
- self ._ft232h ._write (str (bytearray ((command , len_low1 , len_high1 ))))
618
- self ._ft232h ._write (str (bytearray (data1 )))
619
- payload1 = self ._ft232h ._poll_read (len (data1 ))
620
- if len (data2 ) > 0 :
621
- self ._ft232h ._write (str (bytearray ((command , len_low2 , len_high2 ))))
622
- self ._ft232h ._write (str (bytearray (data2 )))
623
- payload2 = self ._ft232h ._poll_read (len (data2 ))
615
+ # Send command and length, then data, split into two commands, handle for length 1
616
+ if len (data1 ) > 0 :
617
+ self ._ft232h ._write (str (bytearray ((command , len_low1 , len_high1 ))))
618
+ self ._ft232h ._write (str (bytearray (data1 )))
619
+ payload1 = self ._ft232h ._poll_read (len (data1 ))
620
+ if len (data2 ) > 0 :
621
+ self ._ft232h ._write (str (bytearray ((command , len_low2 , len_high2 ))))
622
+ self ._ft232h ._write (str (bytearray (data2 )))
623
+ payload2 = self ._ft232h ._poll_read (len (data2 ))
624
624
#self._ft232h._write('\x87')
625
625
self ._deassert_cs ()
626
626
# Read response bytes.
0 commit comments