-
Notifications
You must be signed in to change notification settings - Fork 41
Unable to use zigpy-znp library with Z-Stack 3.0.x on CC2531 USB dongle #56
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
Comments
Hi Lucas, I have tested zigpy-znp on Windows only a handful of times but it has worked in the past and I still expect it to, since PySerial is cross-platform. The debug log shows the exact bytes sent/received by zigpy-znp over serial and it does look like your CC2531 does not respond to the Functionally, the only difference between your two scripts is the use of Some suggestions:
|
try downgrading pyserial to previsous version on windows |
Also, the For example, setting |
Hi puddly, with Python 3.8, I tried the following command that reads firmware version on :
In all the situations, the serial connection is successfully established, but I still have the TimeoutError. Using pyserial library to send the SYS_VERSION command manually works fine in all these 3 situations (I get an answer from the USB dongle). I searched a little more in the library and I noticed that it uses pyserial-asyncio library. I first thought it wasn't working on windows because this library seems to not work for Windows as written in the readme.md file on github. But I have the same TimeoutError problem also on UNIX OS. Same TimeoutError with the following script using import asyncio
asyncio.set_event_loop_policy(asyncio.WindowsSelectorEventLoopPolicy())
import logging
logging.basicConfig()
logging.root.setLevel(logging.DEBUG)
from zigpy_znp.api import ZNP
from zigpy_znp import config
import zigpy_znp.commands as cmd
CFG = config.CONFIG_SCHEMA(
{"znp_config": {"skip_bootloader": True}, "device": {"path": "COM6", "baudrate": 115200}}
)
znp = ZNP(CFG)
async def main():
await znp.connect(test_port=False)
await znp.request_callback_rsp(
request=cmd.UBL.HandshakeReq.Req(),
callback=cmd.UBL.HandshakeRsp.Callback(partial=True),
)
if __name__ == "__main__":
asyncio.run(main()) As Adminiuga suggested, I also tried other versions of pyserial-asyncio or zigpy-znp, same TimeoutError. I will spend more time on monday, I'll keep you informed. Thanks |
check if you can get zigbee2mqtt running with your adapter on an Ubuntu VM. Just to confirm the adapter is working. |
It's not just you, I can confirm this bug on Windows 10. Same symptoms with a fresh installation of Python 3.9.1 after creating a virtualenv and installing just zigpy-znp from PyPI. Interestingly the bootloader skip bytes being sent don't cause the green LED to turn off (indicating that the bootloader is inactive), meaning that nothing is being sent by pyserial-asyncio. You can fix this by downgrading pyserial-asyncio: $ pip install zigpy-znp
$ python -m zigpy_znp.tools.energy_scan -vv COM4 # fails to receive a response to the Version req
$ pip install pyserial-asyncio==0.4
$ python -m zigpy_znp.tools.energy_scan -vv COM4 # works |
For reference, this has been reported as pyserial/pyserial-asyncio#69 and was fixed by pyserial/pyserial-asyncio#70. There however hasn't been a 0.5.1 release yet of |
As for your timeout issue on non-Windows platforms, this may be because you're configuring ZNP with import asyncio
import logging
logging.basicConfig()
logging.root.setLevel(logging.DEBUG)
from zigpy_znp.api import ZNP
from zigpy_znp import config
import zigpy_znp.commands as cmd
znp = ZNP(config.CONFIG_SCHEMA({
"znp_config": {
"skip_bootloader": True
},
"device": {
"path": "COM6",
"baudrate": 115200
}
}))
async def main():
await znp.connect(test_port=False)
version = await znp.request(cmd.SYS.Version.Req())
print('Reported version is', version)
if __name__ == "__main__":
asyncio.run(main()) The |
Hi, You are right. Problem solved by downgrading pyserial-asyncio to version 0.4. Thank you ! PS : I missclicked on button "close" |
Hi,
I followed the zigpy-znp readme and I'm using a CC2531 based USB dongle with Z Stack 3.0.x coordinator firmware that I successfully flashed with TI SmartRF Flash Programmer. When I'm running the following script, I'm getting a TimeoutError exception.
Python Console Log
I tried the following script to send the SYS_PING request over serial manually using the "Monitor and Test API" document, to be sure that the firmware works over the correct COM port.
And I'm getting a response from the dongle.
I'm a beginner and I have some difficulties to identify the reasons. I expect a misconfiguration or the misuse of the python library in my script.
What are the things that I could have missed ? Or am I totally wrong with the use of the library in my script.
I also specify that I have the same problem with the zigpy-cc library but with the Z Stack 1.2 firmware, which could highlight my misunderstanding of library...
In addition, are there examples of use of this library (or more precise documentation) ?
Thank you
Lucas
PS: I'm not sure if my question is relevent in this category, I'm not completely comfortable with github yet...
The text was updated successfully, but these errors were encountered: