openthread / wpantund

Wireless Network Interface Daemon for Low-Power Wireless SoCs
Apache License 2.0
174 stars 110 forks source link

NCP(USB CDC ACM) hard reset support #492

Closed lmaciejonczyk closed 3 years ago

lmaciejonczyk commented 3 years ago

This commit handles the situation when NCP(USB CDC ACM) performs hard reset after receiving SPINEL_CMD_RESET.

When NCP is connected by USB CDC ACM and we reset it, the NCP device is reattached to the host operating system. So far for NCP(USB CDC ACM) pseudo reset has been performing meaning only specific parts of firmware were reset. It is error-prone solution for bare metal device and almost unreachable for devices working under RTOS. But what's most important it does not guarantee the clean init state of the NCP device. It's far easier and better to hard reset NCP and properly handle the USB connection on the host side.

It uses udev library to check if device enumeration has ended.

It works based on symlink to the NCP device created by udev in /dev/serial/by-id/ directory.

lmaciejonczyk commented 3 years ago

@abtink I've addressed your comment, I hope this is what you expected. Is there anything I can do more here?

abtink commented 3 years ago

Thanks @lmaciejonczyk . LGTM. I trigger a CI run on branch. Will merge after it passes.