Permalink
Browse files

Return False if ft232r.open() fails

Instead of raising an exception, print a nice error message and exit.
  • Loading branch information...
1 parent d9048a6 commit 2080139c0be71cfcfe8b960ad5a5f0922888549d @fizzisist fizzisist committed Feb 3, 2012
Showing with 8 additions and 6 deletions.
  1. +3 −2 ft232r.py
  2. +5 −4 mine.py
View
@@ -143,8 +143,6 @@ def open(self, devicenum, portlist):
if devicenum is not None:
self.handle = d2xx.open(devicenum)
- else:
- raise NoAvailableDevices()
if self.handle is not None:
self._log("Opened device %i" % devicenum)
@@ -154,6 +152,9 @@ def open(self, devicenum, portlist):
self._setBaudRate(DEFAULT_FREQUENCY)
self._setSyncMode()
self._purgeBuffers()
+ return True
+ else:
+ return False
def close(self):
if self.handle is None:
View
@@ -122,7 +122,6 @@ def mineLoop(fpga_list):
nonce = fpga.readNonce()
#logger.reportDebug("%d: Writing job..." % fpga.id)
fpga.writeJob(job)
- #fpga.clearQueue()
if nonce is not None:
handleNonce(fpga.current_job, nonce, fpga.id)
fpga.current_job = job
@@ -153,9 +152,11 @@ def mineLoop(fpga_list):
# open FT232R
ft232r = FT232R()
portlist = FT232R_PortList(7, 6, 5, 4, 3, 2, 1, 0)
- ft232r.open(settings.devicenum, portlist)
-
- logger.reportOpened(ft232r.devicenum, ft232r.serial)
+ if ft232r.open(settings.devicenum, portlist):
+ logger.reportOpened(ft232r.devicenum, ft232r.serial)
+ else:
+ logger.log("ERROR: FT232R device not opened!", False)
+ exit()
if settings.chain == 0 or settings.chain == 1:
fpga_list.append(FPGA(ft232r, settings.chain, logger))

0 comments on commit 2080139

Please sign in to comment.