GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — GIT: Merge branch 'development' · SiLab-Bonn/pySiLibUSB@df5b48f

File tree

Expand file treeCollapse file tree
Open diff view settings
Filter options
  • SiLibUSB
    • siusbdevice.py
Expand file treeCollapse file tree
Open diff view settings
Collapse file

‎SiLibUSB/siusbdevice.py‎

Copy file name to clipboardExpand all lines: SiLibUSB/siusbdevice.py
+18-9Lines changed: 18 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -72,6 +72,8 @@
7272
- bump version for pypi, no changes
7373
2.0.8:
7474
- fixing imports in __init__.py
75+
3.0.0:
76+
- Python 3 support
7577
"""
7678

7779
import usb.core
@@ -85,7 +87,7 @@
8587
from itertools import chain, islice
8688
# import sys
8789

88-
__version__ = '2.0.8'
90+
__version__ = '3.0.0'
8991
__version_info__ = (tuple([int(num) for num in __version__.split('.')]), 'final', 0)
9092

9193
# set debugging options for pyUSB
@@ -308,19 +310,27 @@ def _write_sur(self, stype, direction, address, size):
308310

309311
def GetFWVersion(self):
310312
ret = self._read(self.SUR_TYPE_FWVER, 0, 2)
311-
return ret.tostring()
313+
try:
314+
return ret.tobytes().decode("utf-8", "ignore")
315+
except AttributeError:
316+
return ret.tostring()
312317

313318
def GetName(self):
314319
ret = self.ReadEEPROM(self.EEPROM_NAME_ADDR, self.EEPROM_NAME_SIZE)
315-
return ret[1:1 + ret[0]].tostring()
320+
try:
321+
return ret[1:1 + ret[0]].tobytes().decode("utf-8", "ignore")
322+
except AttributeError:
323+
return ret[1:1 + ret[0]].tostring()
316324

317325
def SetName(self, name):
318326
raise NotImplementedError()
319327

320328
def GetBoardId(self):
321329
ret = self.ReadEEPROM(self.EEPROM_ID_ADDR, self.EEPROM_ID_SIZE)
322-
# return ret[1:1+ret[0]].tostring()
323-
return ret[1:-1].tostring()
330+
try:
331+
return ret[1:-1].tobytes().decode("utf-8", "ignore")
332+
except AttributeError:
333+
return ret[1:-1].tostring()
324334

325335
def SetBoardId(self, board_id):
326336
raise NotImplementedError()
@@ -345,7 +355,6 @@ def _read_bit_file_section(self, f):
345355
return letter, f.read(alen)
346356

347357
def _read_bit_file(self, bit_file_name):
348-
# print bit_file_name
349358
with open(bit_file_name, "rb") as f:
350359
head13 = array.array('B', f.read(13))
351360
if head13.tolist() != [0, 9, 15, 240, 15, 240, 15, 240, 15, 240, 0, 0, 1]:
@@ -533,6 +542,6 @@ def GetUSBDevices():
533542
if __name__ == "__main__":
534543
boards = GetUSBBoards()
535544
for board in boards:
536-
print "Name:", board.GetName()
537-
print "BoardId:", board.GetBoardId()
538-
print "FWVersion:", board.GetFWVersion()
545+
print("Name: %s" % board.GetName())
546+
print("BoardId: %s" % board.GetBoardId())
547+
print("FWVersion: %s" % board.GetFWVersion())

0 commit comments

Comments
0 (0)
You are visitor 01402792 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.