Coder Social home page Coder Social logo

py3row's Introduction

Py3Row

Build Status

NOTE

  • This code may not function as advertised.
  • This documentation is incomplete
  • Please submit PRs to improve this

ABOUT

Code history

Original Site: http://www.newhavenrowingclub.org/pyrow/
Forked from: https://github.com/uvd/PyRow

Description

PyRow is python3 code that allows one to interact with a Concept2 Rowing Ergometer PM3, PM4 or PM5 monitor using python. PyRow sends and receives information from the Ergometer using csafe commands or built in functions (listed below). The goal of PyRow is to allow for multiple platforms to have easy access to the Ergometer.

CSAFE

For an explanation of the csafe commands please use the documentation found here:

LICENSE

Copyright (c) 2011 - 2015, Sam Gambrell Copyright (c) 2016 - 2017, Michael Droogleever Licensed under the Simplified BSD License.

REQUIREMENTS

Py3Row has not been widely tested but should be able to work on any machine that can run Python & PyUSB. This has not been tested and confirmed.

Tested Configurations

ArchLinux

# sudo pacman -S python libusb or # sudo pacman -S python libusb python-pyusb (unstested)

INSTALLING

  • After the software has become stable the software will be packaged as a module, you can try using pip install -e git+https://github.com/droogmic/Py3Row.git#egg=pyrow.
  • For now copying he pyrow directory and importing will work.

Include PyRow in your code with the following line of code: from pyrow import pyrow

RUNNING

pyrow.find() - returns an array of all the ergs currently connected to the computer


pyrow.PyErg(erg) - creates an object for communicating with the erg, erg is obtained from the pyrow.find() function ex: creating a pyrow object from the first erg found ergs = pyrow.find() erg = pyrow.pyrow(ergs[0])

PAZI tukaj... ta ergs je "generator" stuff of pythona. Ne mores tko delat, kot pise. Lahko naredis ergs = pyrow.find() nato pa ... erg = next(ergs)

pa delaj kot ROOT zaradi permissionov na USB, ali pa uredi le te.

nato inicializiraj v object -> .... moj_object = pyrow.PyErg(erg)


pyrow.PyErg.get_status() - returns status of machine as a number

  • 0 = 'Error'
  • 1 = 'Ready'
  • 2 = 'Idle'
  • 3 = 'Have ID'
  • 4 = 'N/A'
  • 5 = 'In Use'
  • 6 = 'Pause'
  • 7 = 'Finished'
  • 8 = 'Manual'
  • 9 = 'Offline'

pyrow.PyErg.get_monitor(forceplot=False) - returns data from the monitor in dictionary format, keys listed below with descriptions

  • time = Monitor time in seconds
  • distance = Monitor distance in meters
  • spm = Strokes per Minute
  • power = Power in watts
  • pace = /500m pace
  • calhr = Calories Burned per Hours
  • calories = Total Calories Burned
  • heartrate = Current Heart Rate
  • status = Machine Status If keyvalue forceplot is set to true
  • forceplot = Force Plot Data
  • strokestate = Stroke State

pyrow.PyErg.get_forceplot() - returns force plot data and stroke state in dictionary format, keys listed below with descriptions

  • forceplot = Force Plot Data (array varying in length from 0 to 16)
  • strokestate = Stroke State
  • status = Machine status

pyrow.PyErg.get_workout() - returns data related to the overall workout in dictionary format, keys listed below with descriptions

  • userid = User ID
  • type = Workout Type
  • state = Workout State
  • inttype = Interval Type
  • intcount = Workout Interval Count
  • status = Machine Status

pyrow.PyErg.get_erg() - returns non workout related data about the erg in dictionary format, keys listed below with descriptions

  • mfgid = Manufacturing ID
  • cid = CID
  • model = Erg Model
  • hwversion = Hardware Version
  • swversion = Software Version
  • serial = Ascii Serial Number
  • maxrx = Max Rx Frame
  • maxtx = Max Tx Frame
  • mininterframe = Min Interframe
  • status = Machine status

pyrow.PyErg.set_clock() - sets the clock on the erg equal to the clock on the computer


pyrow.PyErg.set_workout() - if machine is in the ready state function will set the workout and display the start workout screen, allowable parameters are listed below (the current PM SDK does not allow for setting invervaled workouts)

Choose one

program=programNumber - number from 0 to 10 (15 if the log card is installed), 1 thru 10 relate to workouts saved in the monitor.

time=[hours, minutes, seconds] - Min allowable is 20 sec & max allowable is 9:59:59.

distance=meters - Min allowable is 100 and max allowable is 20000.

Not required, can only chose if time or distance is set

split=seconds - If time is set or meters if distance is set, must be less than the total goal and greater than or equal to 20 seconds or 100 meters, cannot occur more then 30 times during the workout, time has a resolution of .01 sec

Not required, chose one

pace=seconds - Seconds for pace boat to complete 500 meters (/500m) powerpace=watts - Watts for pace boat to generate calpace=cal - Calories per hour for pace boat to burn

ex: set a 2000m workout with a 500m split and a pace boat with a 2 minute pace (120 seconds)

erg.set_workout(distance=2000, split=500, pace=120)


pyrow.PyErg.send(command) - sends a csafe command to the rowing machine and returns the result. The command is an array and results are returned as a dictionary with the key being the csafe command name

ex: setting a workout of 10 minutes with a split of 1 minute (60 seconds)

command = ['CSAFE_SETTWORK_CMD', 0, 10, 0,'CSAFE_PM_SET_SPLITDURATION', 0, 60]
erg.send(command)

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]))

FILES

pyrow

  • pyrow.py - file to be loaded by user, used to connect to erg and send/receive data on a low-level
  • simpyrow.py - file to be loaded by user, used to simulate erg communication on a low-level
  • ergmanager.py - file to be loaded by user, used to connect to erg and send/receive data on a high-level
  • csafe
    • csafe_cmd.py - converts between csafe commands and byte arrays for pyrow.py, user does not need to load this file directly
    • csafe_dic.py - contains dictionaries of the csafe commands to be used by csafe_cmd.py, user does not need to load this file directly

tests - contains unittests

examples

  • stdio.py - User I/O demo
  • socketstream.py
  • socketstreamer.py
  • superceded
    • strokelog.py - an example program that records time, distance, strokes per min, pace, and force plot data for each stroke to a csv file
    • statshow.py - an example program that displays the current machine, workout, and stroke status

py3row's People

Contributors

droogmic avatar tomazbracic avatar vjftw avatar alexlongshaw avatar

Watchers

James Cloos avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.