Skip to content

Commit

Permalink
write: Return the number of written bytes rather than boolean/success.
Browse files Browse the repository at this point in the history
  • Loading branch information
andrewleech committed Jun 22, 2020
1 parent ce69414 commit daa66b8
Showing 1 changed file with 5 additions and 4 deletions.
9 changes: 5 additions & 4 deletions winusbpy/winusbpy.py
Original file line number Diff line number Diff line change
Expand Up @@ -96,8 +96,7 @@ def list_usb_devices(self, **kwargs):

name = buff_friendly_name.value
else:
err = self.get_last_error_code()
print(err)
print(ctypes.WinError()

This comment has been minimized.

Copy link
@tommasofurieri

tommasofurieri Jul 10, 2020

closing bracket is missing

self.device_paths[name] = path
i += 1
member_index = DWORD(i)
Expand Down Expand Up @@ -207,8 +206,10 @@ def control_transfer(self, setup_packet, buff=None):

def write(self, pipe_id, write_buffer):
write_buffer = create_string_buffer(write_buffer)
return self.api.exec_function_winusb(WinUsb_WritePipe, self.handle_winusb, c_ubyte(pipe_id), write_buffer,
c_ulong(len(write_buffer) - 1), byref(c_ulong(0)), None)
written = c_ulong(0)
self.api.exec_function_winusb(WinUsb_WritePipe, self.handle_winusb[self._index], c_ubyte(pipe_id), write_buffer,
c_ulong(len(write_buffer) - 1), byref(written), None)
return written.value

def read(self, pipe_id, length_buffer):
read_buffer = create_string_buffer(length_buffer)
Expand Down

0 comments on commit daa66b8

Please sign in to comment.