clssn / numato-gpio

Python API for Numato GPIO Expanders
MIT License
4 stars 6 forks source link

Attemt to solve NumatoGpioError when response is not lowercase #17

Closed lwej closed 2 years ago

lwej commented 2 years ago

Hi, I have also encountered issue #14 and in my tests - this solution seems to work

I have not yet found a solution for unexpected line endings, but currently working on this..

lwej commented 2 years ago

I am unsure if the unexpected line ending issue might be related to port range when calling adc_read

I get the following errors using a 64 port module, which accepts values 00 - 31

Traceback (most recent call last):
  File "/..../python3.9/site-packages/numato_gpio/__init__.py", line 227, in adc_read
    try:              return int(resp[: resp.find(self._eol)])
ValueError: invalid literal for int() with base 10: ''

Traceback (most recent call last):
  File "/..../gpio.py", line 119, in <module>
    print(dev.adc_read(3))
  File "/..../python3.9/site-packages/numato_gpio/__init__.py", line 230, in adc_read
    raise NumatoGpioError(
numato_gpio.NumatoGpioError: Query ''adc read 3'' returned unexpected result '>'. Expected 10 bit decimal integer.

From what I can understand, this is because adc_read might be the only function using port directly ?

see: 6c963d4ede4068887733962c04fb31b5df018fa1

lwej commented 2 years ago

I overlooked this reading the docs. I have only 32 port devices so couldn't test a real device. Thanks for your contribution!

Thank you!