This hopefully "fixes" the observed MZ-RH1 download hangs. --- netmd/libnetmd.py | 15 +++++++++++++++ 1 files changed, 15 insertions(+), 0 deletions(-) diff --git a/netmd/libnetmd.py b/netmd/libnetmd.py index 3bcdc25..d2a3d4a 100644 --- a/netmd/libnetmd.py +++ b/netmd/libnetmd.py @@ -208,6 +208,20 @@ class NetMD(object): """ self.usb_handle.bulkWrite(BULK_WRITE_ENDPOINT, data) + def flushWriteBulk(self): + """ + Send some dummy data to the device, with a low timeout. + Used to help against lockups on music download. + The MZ-RH1 seems to need it sometimes, while an ancient Sharp + unit is fine without. + """ + try: + self.usb_handle.bulkWrite(BULK_WRITE_ENDPOINT, "\0"*128, 1) + except libusb1.USBError as result: + if result.value != libusb1.LIBUSB_ERROR_TIMEOUT: + raise + + ACTION_PLAY = 0x75 ACTION_PAUSE = 0x7d ACTION_FASTFORWARD = 0x39 @@ -1184,6 +1198,7 @@ class MDSession: self.sessionkey = retailmac(ekbobject.getRootKey(), nonce) def downloadtrack(self, trk): + self.md.net_md.flushWriteBulk() self.md.setupDownload(trk.getContentID(), trk.getKEK(), self.sessionkey) dataformat = trk.getDataFormat() (track,uuid,ccid) = self.md.sendTrack(dataformat, diskforwire[dataformat], \ -- 1.7.1