You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I modified this routine to show what I think it should be. Before it was flags = OP_FLAG_TERMCHAR_SET if a terminating char exists but was immediately followed by flags = 0.
But I'm also confused by the behavior if term_char is set. It looks like the intent is the convert it to an integer than append to data. I've been passing bytes objects to this routine. This will fail when it attempts data += term_char. Also you cannot specify term_char as a single element bytes literal such as b'\r'.
If the encoding is assumed to be 'UTF-8' anyway shouldn't this line simply be ord(term_char)?
I might also change the if self.term_char is not None to if self.term_char for readability/simplicity.
def write_raw(self, data):
"Write binary data to instrument"
if self.link is None:
self.open()
# TODO: Test
flags = 0
if self.term_char is not None:
flags |= OP_FLAG_TERMCHAR_SET
term_char = str(self.term_char).encode('utf-8')[0]
data += term_char
# Was this: flags = 0
num = len(data)
The text was updated successfully, but these errors were encountered:
I'm using Python 3.5 on Ubuntu.
I modified this routine to show what I think it should be. Before it was
flags = OP_FLAG_TERMCHAR_SET
if a terminating char exists but was immediately followed byflags = 0
.But I'm also confused by the behavior if term_char is set. It looks like the intent is the convert it to an integer than append to data. I've been passing bytes objects to this routine. This will fail when it attempts
data += term_char
. Also you cannot specify term_char as a single element bytes literal such as b'\r'.If the encoding is assumed to be 'UTF-8' anyway shouldn't this line simply be ord(term_char)?
I might also change the
if self.term_char is not None
toif self.term_char
for readability/simplicity.The text was updated successfully, but these errors were encountered: