You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I am using the pigpio library to read an encoder and convert its value into degrees. One big issue I face is that to my understanding the pigpio.callback uses its own thread and has its own memory. To start the encoder reading process I use a multiprocessing.Queue to get information about a signal (homing complete) and then I want to start reading the pulses. The trouble is even by using multiprocessing.Queue or even a threading.queue() i cannot get the callback function to read the value from the thread (probably because callbacks run in their own special type of thread.
In this code a pass a multiprocessing.Queue() to this thread (because another process was responsible for that signal), and then use the .get() method to get its value and store in a local class variable but the callback function is not able to read that variable. Im just printing to show in reakl scenario it will be sent via udp protocol.
@Joan maybe you can clarify, It is also suggested not to read a gpio within the callback in the documentation.
Anyway around for this. Need urgent help
Also posted this on the raspi forums
The text was updated successfully, but these errors were encountered:
I am using the pigpio library to read an encoder and convert its value into degrees. One big issue I face is that to my understanding the pigpio.callback uses its own thread and has its own memory. To start the encoder reading process I use a multiprocessing.Queue to get information about a signal (homing complete) and then I want to start reading the pulses. The trouble is even by using multiprocessing.Queue or even a threading.queue() i cannot get the callback function to read the value from the thread (probably because callbacks run in their own special type of thread.
`
class encoder_T(Thread):
def init(self, pinNumber1, direction_pin, scale_value, calibration_value, gpio, port_number, homing_queue):
super().init()
self.gpio = gpio
self.pinNumber1 = pinNumber1
self.direction_pin = direction_pin
self.calibration_value = calibration_value
self.cb1 = self.gpio.callback(self.pinNumber1, pigpio.EITHER_EDGE, self.callback_func)
self.cb2 = self.gpio.callback(self.direction_pin, pigpio.EITHER_EDGE, self.callback_func)
self.scale_value = scale_value
self.position_pulses = 0
self.position_degrees = 0
self.direction = 0
self.homing_queue = homing_queue
self.HOMING = False
`
In this code a pass a multiprocessing.Queue() to this thread (because another process was responsible for that signal), and then use the .get() method to get its value and store in a local class variable but the callback function is not able to read that variable. Im just printing to show in reakl scenario it will be sent via udp protocol.
@Joan maybe you can clarify, It is also suggested not to read a gpio within the callback in the documentation.
Anyway around for this. Need urgent help
Also posted this on the raspi forums
The text was updated successfully, but these errors were encountered: