diff --git a/README.md b/README.md index b59f828..0839e51 100644 --- a/README.md +++ b/README.md @@ -10,11 +10,9 @@ PyRow is python code that allows one to interact with a Concept 2 Rowing Ergomet For an explanation of the csafe commands please use the following documentation: -- [Concept2 PM Communication Interface Definition](http://www.concept2.com/service/software/software-development-kit) +- [Concept2 PM Communication Interface Definition](https://www.concept2.com/files/pdf/us/monitors/PM5_CSAFECommunicationDefinition.pdf) -_Need to download the SDK to get the document_ - -- [Communications Specification for Fitness Equipment](http://www.fitlinxx.com/CSAFE/) +- [Communications Specification for Fitness Equipment](https://web.archive.org/web/20080614002257/http://www.fitlinxx.com/CSAFE/) Site: http://www.newhavenrowingclub.org/pyrow/ @@ -26,7 +24,7 @@ Licensed under the Simplified BSD License. PyRow has been tested on an Ubuntu machine with the software versions listed below, PyRow should be able to work on any machine that can run Python & PyUSB but this has not been tested and confirmed. -- [Python](http://python.org/) (Tested with 2.7.2) +- [Python](http://python.org/) - [libusb](http://www.libusb.org/) sudo apt-get install libudev-dev libusb-dev python @@ -169,8 +167,8 @@ ex: getting pace and printing it out command = ['CSAFE_GETPACE_CMD',] result = erg.send(command) - print "Stroke Pace = " + str(result['CSAFE_GETPACE_CMD'][0]) - print "Stroke Units = " + str(result['CSAFE_GETPACE_CMD'][1]) + print("Stroke Pace = " + str(result['CSAFE_GETPACE_CMD'][0])) + print("Stroke Units = " + str(result['CSAFE_GETPACE_CMD'][1])) ## FILES diff --git a/csafe_cmd.py b/csafe_cmd.py index b686327..235bb7c 100755 --- a/csafe_cmd.py +++ b/csafe_cmd.py @@ -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,7 +122,7 @@ 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) @@ -130,16 +130,17 @@ def write(arguments): 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)) 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]: diff --git a/pyrow.py b/pyrow.py index 90769a8..de11d9d 100755 --- a/pyrow.py +++ b/pyrow.py @@ -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 forceplot['forceplot'] = results['CSAFE_PM_GET_FORCEPLOTDATA'][1:(datapoints+1)] forceplot['strokestate'] = results['CSAFE_PM_GET_STROKESTATE'][0] diff --git a/statshow.py b/statshow.py index 96124f8..6d99cb5 100755 --- a/statshow.py +++ b/statshow.py @@ -7,7 +7,7 @@ if len(ergs) == 0: exit("No ergs found.") erg = pyrow.pyrow(ergs[0]) - print "Connected to erg." + print("Connected to erg.") #Create a dictionary of the different status states state = ['Error', 'Ready', 'Idle', 'Have ID', 'N/A', 'In Use', @@ -35,11 +35,11 @@ results = erg.send(command) if cstate != (results['CSAFE_GETSTATUS_CMD'][0] & 0xF): cstate = results['CSAFE_GETSTATUS_CMD'][0] & 0xF - print "State " + str(cstate) + ": " + state[cstate] + print("State " + str(cstate) + ": " + state[cstate]) if cstroke != results['CSAFE_PM_GET_STROKESTATE'][0]: cstroke = results['CSAFE_PM_GET_STROKESTATE'][0] - print "Stroke " + str(cstroke) + ": " + stroke[cstroke] + print("Stroke " + str(cstroke) + ": " + stroke[cstroke]) if cworkout != results['CSAFE_PM_GET_WORKOUTSTATE'][0]: cworkout = results['CSAFE_PM_GET_WORKOUTSTATE'][0] - print "Workout " + str(cworkout) + ": " + workout[cworkout] + print("Workout " + str(cworkout) + ": " + workout[cworkout]) time.sleep(1) diff --git a/strokelog.py b/strokelog.py index 06eae2f..ff895dc 100755 --- a/strokelog.py +++ b/strokelog.py @@ -9,7 +9,7 @@ exit("No ergs found.") erg = pyrow.pyrow(ergs[0]) - print "Connected to erg." + print("Connected to erg.") #Open and prepare file write_file = open('workout.csv', 'w') @@ -17,11 +17,11 @@ #Loop until workout has begun workout = erg.get_workout() - print "Waiting for workout to start ..." + print("Waiting for workout to start ...") while workout['state'] == 0: time.sleep(1) workout = erg.get_workout() - print "Workout has begun" + print("Workout has begun") #Loop until workout ends while workout['state'] == 1: @@ -57,4 +57,4 @@ workout = erg.get_workout() write_file.close() - print "Workout has ended" + print("Workout has ended")