~pygarmin-dev/pygarmin/trunk

« back to all changes in this revision

Viewing changes to garmin.py

  • Committer: Bjorn Tillenius
  • Date: 2008-07-29 17:35:20 UTC
  • Revision ID: bjorn.tillenius@gmail.com-20080729173520-bcve5oe97ymq8l2m
Restart the USB session if we get a "No error" error.

This fixes the problem with the USBLink only works every second time.
See bug 252730 for more information.

Show diffs side-by-side

added added

removed removed

Lines of Context:
2089
2089
            raise LinkException("No Garmin device found!")
2090
2090
        self.handle = self.garmin_dev.open()
2091
2091
        self.handle.claimInterface(0)
2092
 
        self.startSession()
 
2092
 
 
2093
        try:
 
2094
            self.startSession()
 
2095
        except usb.USBError, error:
 
2096
            if error.message == "No error":
 
2097
                # I'm not sure why we get a "No error" error something,
 
2098
                # but I suspect the device wasn't in a good state.
 
2099
                # Simply restarting the session once seems to solve it.
 
2100
                self.startSession()
 
2101
            else:
 
2102
                raise
2093
2103
 
2094
2104
    def startSession(self):
2095
2105
        """Start the USB session."""