-
Notifications
You must be signed in to change notification settings - Fork 36
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
Python 3 Support, PM5 Bug Fix, and Updated Readme #8
base: master
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,10 +1,10 @@ | ||
|
||
#ToDo: change print statments to proper errors | ||
#ToDo: change print() calls to proper errors | ||
import csafe_dic | ||
|
||
def __int2bytes(numbytes, integer): | ||
if not 0 <= integer <= 2 ** (8 * numbytes): | ||
print "Integer is outside the allowable range" | ||
print("Integer is outside the allowable range") | ||
|
||
byte = [] | ||
for k in range(numbytes): | ||
|
@@ -122,24 +122,25 @@ def write(arguments): | |
|
||
#check for frame size (96 bytes) | ||
if len(message) > 96: | ||
print "Message is too long: " + len(message) | ||
print("Message is too long: " + len(message)) | ||
|
||
#report IDs | ||
maxmessage = max(len(message) + 1, maxresponse) | ||
|
||
if maxmessage <= 21: | ||
message.insert(0, 0x01) | ||
message += [0] * (21 - len(message)) | ||
elif maxmessage <= 63: | ||
message.insert(0, 0x04) | ||
message += [0] * (63 - len(message)) | ||
## see https://github.com/wemakewaves/PyRow/issues/5 | ||
#elif maxmessage <= 63: | ||
# message.insert(0, 0x04) | ||
# message += [0] * (63 - len(message)) | ||
Comment on lines
-133
to
+136
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This change (i.e. just the commit this was in) can be straight up cherry picked onto the py3row codebase with no merge conflicts Thanks for keeping the commits organized and separated btw! |
||
elif (len(message) + 1) <= 121: | ||
message.insert(0, 0x02) | ||
message += [0] * (121 - len(message)) | ||
if maxresponse > 121: | ||
print "Response may be too long to recieve. Max possible length " + str(maxresponse) | ||
print("Response may be too long to recieve. Max possible length " + str(maxresponse)) | ||
else: | ||
print "Message too long. Message length " + str(len(message)) | ||
print("Message too long. Message length " + str(len(message))) | ||
message = [] | ||
|
||
return message | ||
|
@@ -164,7 +165,7 @@ def __check_message(message): | |
|
||
#checks checksum | ||
if checksum != 0: | ||
print "Checksum error" | ||
print("Checksum error") | ||
return [] | ||
|
||
#remove checksum from end of message | ||
|
@@ -188,7 +189,7 @@ def read(transmission): | |
elif startflag == csafe_dic.Standard_Frame_Start_Flag: | ||
j = 2 | ||
else: | ||
print "No Start Flag found." | ||
print("No Start Flag found.") | ||
return [] | ||
|
||
while j < len(transmission): | ||
|
@@ -199,7 +200,7 @@ def read(transmission): | |
j += 1 | ||
|
||
if not stopfound: | ||
print "No Stop Flag found." | ||
print("No Stop Flag found.") | ||
return [] | ||
|
||
message = __check_message(message) | ||
|
@@ -247,7 +248,7 @@ def read(transmission): | |
|
||
#checking that the recieved data byte is the expected length, sanity check | ||
if abs(sum(msgprop[1])) != 0 and bytecount != abs(sum(msgprop[1])): | ||
print "Warning: bytecount is an unexpected length" | ||
print("Warning: bytecount is an unexpected length") | ||
|
||
#extract values | ||
for numbytes in msgprop[1]: | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -31,9 +31,9 @@ def __init__(self, erg): | |
if erg.is_kernel_driver_active(INTERFACE): | ||
erg.detach_kernel_driver(INTERFACE) | ||
else: | ||
print "DEBUG: usb kernel driver not on " + sys.platform | ||
print("DEBUG: usb kernel driver not on " + sys.platform) | ||
except: | ||
print "EXCEPTION" | ||
print("EXCEPTION") | ||
|
||
#Claim interface (Needs Testing To See If Necessary) | ||
usb.util.claim_interface(erg, INTERFACE) | ||
|
@@ -116,7 +116,7 @@ def get_force_plot(self): | |
results = self.send(command) | ||
|
||
forceplot = {} | ||
datapoints = results['CSAFE_PM_GET_FORCEPLOTDATA'][0] / 2 | ||
datapoints = results['CSAFE_PM_GET_FORCEPLOTDATA'][0] // 2 | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This has already been fixed in Py3Row so no need to port it over |
||
forceplot['forceplot'] = results['CSAFE_PM_GET_FORCEPLOTDATA'][1:(datapoints+1)] | ||
forceplot['strokestate'] = results['CSAFE_PM_GET_STROKESTATE'][0] | ||
|
||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This and all the print() fixes are already fixed in Py3Row