Grove GPS Sensor slow to read

Are you doing that?

If so, you have to put a mutex around grovepi access.

1 Like

Correct me if I am wrong, but didn’t Cleoqc say that - by default - mutexes are not used, but there is a setting somewhere, (I think it was something like “mutex = true” that would default everything to using mutexes?

I remember saying that if it’s such a desirable thing, why isn’t it the default - and your reply was that “it’s a part of the pedagogy”. (And then I made a snarky comment that went something like “if jumping off a building is a bad idea, does that mean we should do it, just to learn not to do it?”   :wink:

I can’t find it right now - do you remember that posting?

That is for EasyGoPiGo3() only.

grovepi is not a class, and does not offer mutex protected methods. The user must either put all grovepi accesses in a single thread and use a thread_lock, or create a mutex protected grovepi class, or create a mutex, and use it:

import threading

gplock = threading.Lock()

.
.
def any_func_that_accesses_grovepi()
    global gplock

    with gplock:
        grovepi.xxx()

If it is the I2C of grovepi that you are worried about, then you can use the dexter I2C_mutex:

from I2C_mutex import Mutex
.
.
gpmutex = Mutex()      # or Mutex(debug=True)

.
.
.
def any_func_that_uses_grovepi()
    global gpmutex

    with gpmutex:
        grovepi.xxxx()

1 Like