Failed to write value to characteristic(Error trying to issue command mid state)
Hi All:
I am using the class TestGpioAdcPulse(TestMetaWearBase) test example as a guide (https://github.com/mbientlab/MetaWear-SDK-Cpp/blob/0.16.3/test/test_dataprocessor.py#L289) to create a Gpio Pin monitor script.
Here's my code snippet:
class TestGpioSensor():
def __init__(self, *args, **kwargs):
self.device = MetaWear(sys.argv[1])
self.handler_fn = FnVoid_VoidP_VoidP(self.proc_handler)
self.state_handler_fn = FnVoid_VoidP_DataP(self.state_handler)
self.status_handler_fn = FnVoid_VoidP_VoidP_Int(self.status_handler)
self.pattern= LedPattern(repeat_count= 10)
self.sensor_data_handler= FnVoid_VoidP_DataP(self.sensorDataHandler)
self.event = Event()
self.setUpGpio()
self.t1 = Thread(target=self.flag)
self.t2 = Thread(target=self.StartMonitoring)
def handle_sensor_data(context, data):
print("data received: %s" % (parse_value(data)))
def pulse_processor_created(self, context, pulse):
self.pulse_signal= pulse
libmetawear.mbl_mw_datasignal_subscribe(pulse, None, self.fn_wrapper)
self.event.set()
def setUpGpio(self):
self.fn_wrapper = FnVoid_VoidP_DataP(self.handle_sensor_data)
self.pulse_handler= FnVoid_VoidP_VoidP(self.pulse_processor_created)
def WaitForGpio(self):
self.gpio_adc_signal= libmetawear.mbl_mw_gpio_get_analog_input_data_signal(self.device.board, 0, GpioAnalogReadMode.ADC)
libmetawear.mbl_mw_dataprocessor_pulse_create(self.gpio_adc_signal, PulseOutput.PEAK, 500.0, 10, None, self.pulse_handler)
self.event.wait()
In WaitForGpio(self): calling libmetawear.mbl_mw_dataprocessor_pulse_create(self.gpio_adc_signal, PulseOutput.PEAK, 500.0, 10, None, self.pulse_handler) results in error:
"Failed to write value to characteristic(Error trying to issue command mid state)"
rp@SS: python DC.py F9:4E:B7:A1:F7:CE
error 1542066425.108170: Error on line: 296 (src/blestatemachine.cc): Operation now in progress
Connected (1)
Failed to write value to characteristic(Error trying to issue command mid state)
Segmentation fault
I tried to google for the error but could not find any direction.
Can anyone please help what I'm missing here?
Thank you.
Comments
Post a script that consistently produces this issue that can be run as is.
Monitor the BT adapter and post the activity log leading up to the crash.
Hi Eric:
Since you added data_fuser.py, I did a clean build/install the MetaWear-SDK-Python (0.6.1) and MetaWear-SDK-Cpp (0.17.0).
Then, to derive from data_fuser.py, first I ran data_fuser.py (unchanged, except adding the debug printfs) but the script seg faults when calling libmetawear.mbl_mw_datasignal_subscribe() on line 38 (https://github.com/mbientlab/MetaWear-SDK-Python/blob/0.6.1/examples/data_fuser.py):
spy35_env) pi@SS:~/SSquare/sspy35_env/MB/MetaWear-SDK-Python/examples $ python data_fuser.py F9:4E:B7:A1:F7:CE
error 1542810072.026808: Error on line: 296 (src/blestatemachine.cc): Operation now in progress
Connected to F9:4E:B7:A1:F7:CE
configuring F9:4E:B7:A1:F7:CE
mbl_mw_settings_set_connection_parameters
mbl_mw_acc_get_acceleration_data_signal
mbl_mw_gyro_bmi160_get_rotation_data_signal
mbl_mw_dataprocessor_fuser_create
Segmentation fault
(sspy35_env) pi@SS:~/SSquare/sspy35_env/MB/MetaWear-SDK-Python/examples $
If I comment out the mbl_mw_datasignal_subscribe() then the output is:
(sspy35_env) pi@SS:~/SSquare/sspy35_env/MB/MetaWear-SDK-Python/examples $ !py
python data_fuser.py F9:4E:B7:A1:F7:CE
error 1542811687.837156: Error on line: 296 (src/blestatemachine.cc): Operation now in progress
Connected to F9:4E:B7:A1:F7:CE
configuring F9:4E:B7:A1:F7:CE
mbl_mw_settings_set_connection_parameters
mbl_mw_acc_get_acceleration_data_signal
mbl_mw_gyro_bmi160_get_rotation_data_signal
mbl_mw_dataprocessor_fuser_create
mbl_mw_datasignal_subscribe
mbl_mw_gyro_bmi160_enable_rotation_sampling
mbl_mw_acc_enable_acceleration_sampling
mbl_mw_gyro_bmi160_start
mbl_mw_acc_start
resetting devices
(sspy35_env) pi@SS:~/SSquare/sspy35_env/MB/MetaWear-SDK-Python/examples $
Once I get through the above problem I can step forward modifying for my application.
Thanks for your help.
Post the information I requested in my previous post.
Eric:
Here is the script I added print statements.
It crashes if I call libmetawear.mbl_mw_datasignal_subscribe().
There is no output other than the print statements I sent earlier.
Thanks
The data fuser script has nothing to do with the issue in this thread.
Post the information I requested in my previous post.
Since the old code is no longer being used in the pre-(data fuser) release, consider this issue closed. I wlll open a new one.
Thanks