Home › Forums › Mooshimeter Support › TypeError during connection with Python API
- This topic has 4 replies, 2 voices, and was last updated 6 years, 6 months ago by admin.
Am experimenting with using the Python API but the following error keeps being thrown during the main_meter.connect() call:
Traceback (most recent call last):
File “example.py”, line 57, in <module>
File “C:\Users\delphinus\repos\denebola\Mooshimeter-PythonAPI\Mooshimeter.py”, line 220, in connect
File “C:\Users\delphinus\repos\denebola\Mooshimeter-PythonAPI\BGWrapper.py”, line 58, in enableNotify
File “C:\Users\delphinus\repos\denebola\Mooshimeter-PythonAPI\BGWrapper.py”, line 149, in enableNotify
TypeError: exceptions must be old-style classes or derived from BaseException, not NoneType
Has anyone else experienced this issue?
Just in case any one needs to know…!
A firmware update via the iPhone app seemed to sort the issue, although the packets seem to be arriving very intermittently, so I need to get to the bottom of that now.
I looked at the error and corrected it. Check the master branch on the github repo.
It looks like the script was having trouble enabling notifications for your meter because something went wrong in the characteristic discovery process. I’m not sure what would cause that. Please let me know if the issue keeps coming up and what changes.
Thanks James, I’ll check it out and will let you know if it recurs.
Also, you wouldn’t happen to know why the output to the screen seems slow (i.e. in the order of one sample per two seconds with both Ch.A and Ch.B activated)? I’ve not changed the default set-up values.
Ah! Thanks for pointing that out.
I looked at the Example.py script. See the lines that say:12main_meter.sendCommand('sampling:rate 0') # Rate 125Hzmain_meter.sendCommand('sampling:depth 3') # Depth 256
You can mess with those to change the sample rates. Right now it’s set to 125Hz, 256 samples (so about 1 sample/2seconds, just as you observed). sampling:rate 1 would give 250Hz, sampling:rate 2 would give 500Hz, etc. sampling:depth 2 gives buffer depth 128, etc. So if you change to12main_meter.sendCommand('sampling:rate 0') # Rate 125Hzmain_meter.sendCommand('sampling:depth 1') # Depth 64
That should give a sample every 0.5second