Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

No data is returned with read_data() #16

Open
davidskeck opened this issue Apr 25, 2020 · 16 comments
Open

No data is returned with read_data() #16

davidskeck opened this issue Apr 25, 2020 · 16 comments

Comments

@davidskeck
Copy link

davidskeck commented Apr 25, 2020

Hello,

I have followed the setup instructions for Windows, but when I try to follow the example, I get no data from the read_data() call.

import co2meter as co2
mon = co2.CO2monitor()
mon.info  # data is returned here
mon.read_data()  # this call waits forever and has no printout

Any ideas?

@crgwbr
Copy link

crgwbr commented Aug 18, 2020

👍 I get the same issue

@vfilimonov
Copy link
Owner

Hello guys, sorry for coming back late to you.

Unfortunately I don't have any device with Windows installed anymore, so I suspect that I could not be of a help any time soon here..

But in case you figure out the solution by yourself - could you please let me know about it, so I'll add it to the readme. Many thanks!

@crgwbr
Copy link

crgwbr commented Aug 24, 2020

FWIW, this wasn't a Windows issue for me—I got the same problem on MacOS and Raspbian Linux.

@a-r-w
Copy link

a-r-w commented Sep 9, 2020

I encountered the same issue with my ZGm053UKA which identified itself as:

>>> mon.info
{'vendor_id': 1241, 'product_id': 41042, 'manufacturer': 'Holtek', 'product_name': 'USB-zyTemp', 'serial_no': '2.00'}

I found this document describing the protocol, which matches what a raw hid read was giving me. i.e. it's not encrypted. The following solved the issue for me:

     def hid_read(self):
         """ Read 8-byte string from HID device """
-        msg = self._h.read(8)
-        return self._decrypt(msg)
+        return self._h.read(8)
 
     @contextmanager
     def co2hid(self, send_magic_table=True):

Hope that's helpful.

@olli666
Copy link

olli666 commented Jan 1, 2021

@a-r-w I can confirm that your fix also worked for me. OS X 10.14.6, Python3, Device: TFA-Dostmann AirControl Mini CO2.

Thanks!

@vfilimonov
Copy link
Owner

vfilimonov commented Jan 1, 2021

Hello all. I've added an argument to __init__: bypass_decrypt. If set to True, read_data will not call _decrypt. Please let me know if it's ok and I'll push the new version to pypi.

@a-r-w Thanks a lot for the solution!

@olli666
Copy link

olli666 commented Jan 3, 2021

New co2meter.py is not working. The hack from a-r-w already works fine.

`Olivers-MacMini2018:co2meter Oliver$ ls

pycache co2meter.sh log_co2.csv usage.txt
co2meter.py co2meter_old.py readCO2meter.py
Olivers-MacMini2018:co2meter Oliver$ python3
Python 3.9.0 (default, Dec 4 2020, 12:07:11)
[Clang 10.0.0 (clang-1000.10.44.4)] on darwin
Type "help", "copyright", "credits" or "license" for more information.

import co2meter as co2
mon = co2.CO2monitor()
mon.read_data()
co2 temp
2021-01-03 19:24:48 None None

Olivers-MacMini2018:co2meter Oliver$ python3
Python 3.9.0 (default, Dec 4 2020, 12:07:11)
[Clang 10.0.0 (clang-1000.10.44.4)] on darwin
Type "help", "copyright", "credits" or "license" for more information.

import co2meter as co2
mon = co2.CO2monitor()
mon.read_data()
co2 temp
2021-01-03 19:25:51 1072 22.0375

`

@vfilimonov
Copy link
Owner

import co2meter as co2
mon = co2.CO2monitor(bypass_decrypt=True)
mon.read_data()

should do the same as #16 (comment)

@olli666
Copy link

olli666 commented Jan 3, 2021

Works perfectly. Sorry for the inconvinience.

@a-r-w
Copy link

a-r-w commented Jan 3, 2021

Hi @vfilimonov, glad it was useful. I can also confirm 5d4187d is working fine for me with bypass_decrypt=True. Thank you!

@Pinkers
Copy link

Pinkers commented Jun 28, 2021

I tried a-r-w's hack and the new commit's bypass-decrypt approach but I am still getting the hang-up when calling read_data(). Has anyone had this issue with the newer Co2Meters? Is there maybe a new way that the data is encrypted or something? Mine's info is: {'vendor_id': 1241, 'product_id': 41042, 'manufacturer': 'Holtek', 'product_name': 'USB-zyTemp', 'serial_no': '2.00'}

@vfilimonov
Copy link
Owner

Hi @Pinkers Thank you for your interest in co2meter and I’m sorry about your issues.

To be honest there’s little what I can do or suggest about other vendors. I did not find any proper documentation and just hacked myself out looking for boots and pieces in the Internet and other repos (see readme - resources).

Where exactly the code hangs?

It worth looking at what self._h.read() returns for different message lengths. Perhaps the message is not encrypted but shorter/longer.

If encrypted - worth trying different magic words - e.g. your vendor name.

That are the obvious things that come to my mind to start with.

@Pinkers
Copy link

Pinkers commented Jun 30, 2021

@vfilimonov Thank you so much for the quick reply! After many days of debugging it is now working though I have no idea why. The only thing that has changed is that I ran it with the proprietary software found here. Maybe that configured the HID driver for the device or something, honestly I am stumped. But I really appreciate the help, and I am grateful it is now working

@Pinkers
Copy link

Pinkers commented Jul 20, 2021

To update this, read_data() only returns when the ZG.exe (proprietary software mentioned earlier) is running first, then the CO2Meter is connected via USB, then read_data() is called. Any insights into why are welcome.

@eriwst
Copy link

eriwst commented Sep 27, 2021

I can also confirm this issue, With the device TFA AIRCO2NTROL COACH ({'vendor_id': 1241, 'product_id': 41042, 'manufacturer': 'Holtek', 'product_name': 'USB-zyTemp', 'serial_no': '2.00'}), read_data() only shows values when the ZG.exe was started before.

@vfilimonov
Copy link
Owner

@Pinkers @eriwst thank you for reporting. I've added the note to readme.md.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

7 participants