Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Interpret first byte as length if command doesn't match expected #6

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 8 additions & 5 deletions ugsimple/GPIB.py
Original file line number Diff line number Diff line change
Expand Up @@ -165,15 +165,18 @@ def device_read( self, address ):
# Read USB a single byte to see if a valid command has been received
command = self.usb_read()[0]
if command != address:
print ("ERROR: '0x{0:2x}' does not match expected command '0x{0:2x}".format( command, address ) )
return None
# print ("ERROR: '0x{0:2x}' does not match expected command '0x{1:2x}".format( command, address ) )
# return None
# If the command doesn't match what was expected, try interpreting the first byte as the length.
# This seems to happen when issuing multiple read commands in a row.
length = command
else:
# Valid command, read next byte to determine length of command
length = self.usb_read()[0]

if self.debug_mode:
print ( "READ CMD:", command )

# Valid command, read next byte to determine length of command
length = self.usb_read()[0]

if self.debug_mode:
print ( "READ LEN:", length )

Expand Down