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

Feature/system wide mutex+ easydi_sensors library #36

Merged
merged 14 commits into from
Feb 23, 2018

Conversation

CleoQc
Copy link
Member

@CleoQc CleoQc commented Feb 22, 2018

easydi_sensors is a wrapper around our own sensors.

@CleoQc CleoQc requested a review from RobertLucian February 22, 2018 21:59
RobertLucian
RobertLucian previously approved these changes Feb 23, 2018
Copy link
Contributor

@RobertLucian RobertLucian left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

All acquires & releases seem to be at their place. This looks fine for now.

@CleoQc CleoQc dismissed RobertLucian’s stale review February 23, 2018 17:56

Splitting easydi_sensors into 3 libraries. Please take another look

@RobertLucian
Copy link
Contributor

I'm wondering if we can not repeat ourselves with those 2 functions: _ifMutexAcquire and _ifMutexRelease. These 2 are identical in all 3 files that you've split.

@CleoQc
Copy link
Member Author

CleoQc commented Feb 23, 2018

C has the possibility to include outside files. Not sure if Python does.

@CleoQc
Copy link
Member Author

CleoQc commented Feb 23, 2018

Ok, found a method to get rid of those multiple instances of acquire/release functions

@CleoQc CleoQc self-assigned this Feb 23, 2018
'''
MUTEX HANDLING
'''
from di_sensors.easy_mutex import *
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Everywhere we have the statement from di_sensors.easy_mutex import * we'd better replace the * with the functions we're interested in - in this case it's ifMutexAcquire and ifMutexRelease.

I'm saying this because it's best to lower the chances of getting into unreasonable conflicts in the future(that are really hard to understand). In easy_mutex.py there is:

  1. I2C_Mutex class that we don't want to inherit -> this class is already imported in this file, so it's redundant to do it twice in a row.
  2. mutex variable which should not get imported at all -> imagine doing some mutex work in easy_whatever_sensor.py file in the future and forgetting about this imported variable -> things could go haywire.
  3. overall_mutex variable which could pose a smaller chance of creating issues in the future and yet, it's something we don't want to import.
  4. Whatever variable that can get into conflict with whatever is/(will be) defined in our easy_whatever_sensor.py.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

reason I went with import * is that all of those lines were already in each of the files.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

But now, they are separate, which means they could "evolve" separately.

Should someone else come and edit this library, they could make the simple mistake of ignoring one of the files and thus create conflicts.
It's always best to be safe than sorry.

'''
import I2C_mutex
mutex = I2C_mutex.Mutex(debug = False)
overall_mutex = mutex.overall_mutex()
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Are we sure overall_mutex method is going to do it's job all the time?
I'm seeing posts on the internet saying os.path.isfile could throw a FileNotFoundError exception.

We wouldn't want to use mutexes if the user has specified not to.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Havent seen any issues yet

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Researching more onto this, I don't see any comments on exceptions on os.path.isfile in the official documentation, which theoretically and most likely, this means the only 2 outcomes are of either getting a False or a True.

Still, I don't see why posts on FileNotFoundError would appear. And if you say you haven't found any issues, then it must be this way I think.

@CleoQc CleoQc merged commit 060ba51 into DexterInd:develop Feb 23, 2018
CleoQc pushed a commit that referenced this pull request Apr 26, 2018
* Add Line Follower drivers and example

* Update dexter_i2c.py

Update dexter_i2c.py to be simpler and more universal by combining
functions.

* Update line_follower.py

Update line_follower.py for recent dexter_i2c.py update

* Feature/easy libraries (#35)

* Move Distance Sensor and Line Follower in here

* remove dependency on mock_package

* remove alias for read_sensors until we know if we need it (probably not)

* Feature/system wide mutex+ easydi_sensors library  (#36)

* Move Distance Sensor and Line Follower in here

* remove dependency on mock_package

* remove alias for read_sensors until we know if we need it (probably not)

* get easydi_sensors from DexterOS

* Check for overall mutex need

* Add systemwide mutex comment

* Add license header and description

* Add license header

* change year in license header

* split easydi_sensors into 3 components for systematic naming convention

* Remove copies of ifMutexAcquire and ifMutexRelease. Keep them in one file

* Be more strict in what we're pulling in from easy_mutex

* poll overall_mutex each time

* remove print statement (#37)

reconfig_bus() is now mutex protected

* feature - update documentation for the latest (#41)

* feature - configuring the environment for RTD

* feature - bulk changes to docs

* feature - add comment on how to build documentation

* feature - add part of the documentation

* feature - completing the documentation for easy sensors + tutorials

* feature - work on the tutorials + other stuff

* feature - fix the mutexes tutorial

* feature - change organization of documentation

* feature - remove an unnecessary section

* feature - show the right command for installing di-sensors

* feature - small changes

* feature - fix documentation & and missing parts

* feature - fix naming of the package

* Revert commit

* minor fixes to docs (#42)

* minor fixes to docs

* minor fixes to doc

* fix grammar

* rename safe_heading to heading_name and re-instate the parameter (#43)

* rename safe_heading to heading_name and re-instate the parameter

* rename from heading_name to convert_heading

* add punctuation

* fix - change name of method in library description section

* Remove references to line follower (#45)
RobertLucian added a commit that referenced this pull request Jun 1, 2018
* Add Line Follower drivers and example

* Update dexter_i2c.py

Update dexter_i2c.py to be simpler and more universal by combining
functions.

* Update line_follower.py

Update line_follower.py for recent dexter_i2c.py update

* Feature/easy libraries (#35)

* Move Distance Sensor and Line Follower in here

* remove dependency on mock_package

* remove alias for read_sensors until we know if we need it (probably not)

* Feature/system wide mutex+ easydi_sensors library  (#36)

* Move Distance Sensor and Line Follower in here

* remove dependency on mock_package

* remove alias for read_sensors until we know if we need it (probably not)

* get easydi_sensors from DexterOS

* Check for overall mutex need

* Add systemwide mutex comment

* Add license header and description

* Add license header

* change year in license header

* split easydi_sensors into 3 components for systematic naming convention

* Remove copies of ifMutexAcquire and ifMutexRelease. Keep them in one file

* Be more strict in what we're pulling in from easy_mutex

* poll overall_mutex each time

* remove print statement (#37)

reconfig_bus() is now mutex protected

* feature - update documentation for the latest (#41)

* feature - configuring the environment for RTD

* feature - bulk changes to docs

* feature - add comment on how to build documentation

* feature - add part of the documentation

* feature - completing the documentation for easy sensors + tutorials

* feature - work on the tutorials + other stuff

* feature - fix the mutexes tutorial

* feature - change organization of documentation

* feature - remove an unnecessary section

* feature - show the right command for installing di-sensors

* feature - small changes

* feature - fix documentation & and missing parts

* feature - fix naming of the package

* Revert commit

* minor fixes to docs (#42)

* minor fixes to docs

* minor fixes to doc

* fix grammar

* rename safe_heading to heading_name and re-instate the parameter (#43)

* rename safe_heading to heading_name and re-instate the parameter

* rename from heading_name to convert_heading

* add punctuation

* fix - change name of method in library description section

* Remove references to line follower (#45)

* feature - add old line follower in (#46)

* feature - adding in the line follower and making basic fixes and adjusts

* feature - fixing paths

* feature - import both versions of the line follower

* feature - change paths accordingly

* feature - fix path issues with di_sensors

* feature - fix path issues

* feature - check if installer runs on GUI-enabled OS

* feature - yet another path issue fixed

* feature - go back to using the same import for the line follower

* feature - import line_sensor correctly in new module

* feature - fix the paths yet again

* feature - add python-periphery as required packafe for line follower

* feature - change how the installation of the sensors goes (#48)

* feature - add installer script for di-sensors

* feature - add install requires for python-periphery

* feature - use the name of the module when identifying the python package

* feature - resize logo to a better aspect ratio

* feature - adjust simple install command

* feature - add readme in installation directory

* feature - modify repo readme

* feature - fix global variable issue

* feature - change how the installation goes

* feature - add the red line follower to the installation

* feature - call configure function for the red line follower

* feature - add/remove feedback instructions in install script

* feature - change version of red line follower to 1.0.0

* fix Line Follower Calibration GUI (#49)

* fix - install sources (#50)

* fix - fix path issue for desktop icon (#51)

* feature - change references for script_tools (#52)

* fix Line Follower Calibration GUI

* Fix path to line_sensor_gui in the desktop file

* feature - change references for script_tools

* use direct links instead of redirects
@CleoQc CleoQc deleted the feature/easy_libraries branch March 13, 2019 15:57
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants