-
Notifications
You must be signed in to change notification settings - Fork 16
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
Conversation
…o feature/easy_libraries
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.
All acquire
s & release
s seem to be at their place. This looks fine for now.
Splitting easydi_sensors into 3 libraries. Please take another look
I'm wondering if we can not repeat ourselves with those 2 functions: |
C has the possibility to include outside files. Not sure if Python does. |
Ok, found a method to get rid of those multiple instances of acquire/release functions |
''' | ||
MUTEX HANDLING | ||
''' | ||
from di_sensors.easy_mutex import * |
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.
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:
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.mutex
variable which should not get imported at all -> imagine doing some mutex work ineasy_whatever_sensor.py
file in the future and forgetting about this imported variable -> things could go haywire.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.- Whatever variable that can get into conflict with whatever is/(will be) defined in our
easy_whatever_sensor.py
.
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.
reason I went with import *
is that all of those lines were already in each of the files.
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.
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.
Python/di_sensors/easy_mutex.py
Outdated
''' | ||
import I2C_mutex | ||
mutex = I2C_mutex.Mutex(debug = False) | ||
overall_mutex = mutex.overall_mutex() |
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.
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.
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.
Havent seen any issues yet
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.
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.
* 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)
* 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
easydi_sensors is a wrapper around our own sensors.