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

Revert "Remove UART thread (#598)" #604

Merged
merged 1 commit into from
Dec 29, 2023

Conversation

puddly
Copy link
Contributor

@puddly puddly commented Dec 28, 2023

This reverts commit 1ac01ed.

The UART thread unfortunately is still necessary: even though writes are done outside of the event loop, notifications to read the serial port's file descriptor are not and any event loop slowdown will cause traffic from the radio to the library to effectively be halted.

Example:

2023-12-28 14:05:17.843 DEBUG (MainThread) [serialpy.descriptor_transport] Event loop woke up reader
2023-12-28 14:05:17.843 DEBUG (MainThread) [serialpy.descriptor_transport] Received b"\x07t\xb1\xedT.\x14\xb6R\x95K%\xabU\x920b\xe07t\x121o\x93=\xccf\x8c\xdd\xec;{\x1f~\x17t\xb1\xedT.\x14\xb6R\x95K%\xabU\x923`\xe37t\x121o\x93<\xcck\x8c\xdd]?\xc4}3~'t\xb1\xedT.\x14\xb6R\x95K%\xabU\x922k\xe17t\x121o\x93?\xcch\x8c\xd5w?\x8c\xe1~7t\xb1\xedT.\x14\xb0^\x95K%\xabU\x925c\xe37t\x121k\x93>\xccc\x89\xd9\xd2\x8b\xfe\xe6\xcd\xdex\x8f~Gt\xb1\xedT.\x14\xb6R\x95K%\xabU\x924{\xe37t\x121o\x939\xcck\x8c\xdd]?\xa2}8~\x0ft\xb1\xedT.\x14\xb6R\x95K%\xabU\x920b\xe07t\x121o\x93=\xccf\x8c\xdd\xec;J\xd3~\x1ft\xb1\xedT.\x14\xb6R\x95K%\xabU\x923`\xe37t\x121o\x93<\xcck\x8c\xdd]?\xf5\xdf~/t\xb1\xedT.\x14\xb6R\x95K%\xabU\x922k\xe17t\x121o\x93?\xcch\x8c\xd5w?\xbd-~?t\xb1\xedT.\x14\xb0^\x95K%\xabU\x925c\xe37t\x121k\x93>\xccc\x89\xd9\xd2\x8b\xfe\xe6\xcd\xdeqD~Ot\xb1\xedT.\x14\xb6R\x95K%\xabU\x924{\xe37t\x121o\x939\xcck\x8c\xdd]?\x93\xd4~\x0ft\xb1\xedT.\x14\xb6R\x95K%\xabU\x920b\xe07t\x121o\x93=\xccf\x8c\xdd\xec;J\xd3~\x1ft\xb1\xedT.\x14\xb6R\x95K%\xabU\x923`\xe37t\x121o\x93<\xcck\x8c\xdd]?\xf5\xdf~/t\xb1\xedT.\x14\xb6R\x95K%\xabU\x922k\xe17t\x121o\x93?\xcch\x8c\xd5w?\xbd-~?t\xb1\xedT.\x14\xb0^\x95K%\xabU\x925c\xe37t\x121k\x93>\xccc\x89\xd9\xd2\x8b\xfe\xe6\xcd\xdeqD~Ot\xb1\xedT.\x14\xb6R\x95K%\xabU\x924{\xe37t\x121o\x939\xcck\x8c\xdd]?\x93\xd4~\x0ft\xb1\xedT.\x14\xb6R\x95K%\xabU\x920b\xe07t\x121o\x93=\xccf\x8c\xdd\xec;J\xd3~\x1ft\xb1\xedT.\x14\xb6R\x95K%\xabU\x923`\xe37t\x121o\x93<\xcck\x8c\xdd]?\xf5\xdf~/t\xb1\xedT.\x14\xb6R\x95K%\xabU\x922k\xe17t\x121o\x93?\xcch\x8c\xd5w?\xbd-~?t\xb1\xedT.\x14\xb0^\x95K%\xabU\x925c\xe37t\x121k\x93>\xccc\x89\xd9\xd2\x8b\xfe\xe6\xcd\xdeqD~Ot\xb1\xedT.\x14\xb6R\x95K%\xabU\x924{\xe37t\x121o\x939\xcck\x8c\xdd]?\x93\xd4~\xc2\x02Q\xa8\xbd~"
2023-12-28 14:05:17.843 DEBUG (MainThread) [serialpy.descriptor_transport] Immediately writing b'\x81`Y~'
2023-12-28 14:05:17.844 DEBUG (MainThread) [serialpy.descriptor_transport] Sent 4 of 4 bytes
2023-12-28 14:05:17.844 DEBUG (MainThread) [bellows.ezsp.protocol] Application frame received incomingMessageHandler: [<EmberIncomingMessageType.INCOMING_UNICAST: 0>, EmberApsFrame(profileId=260, clusterId=2820, sourceEndpoint=1, destinationEndpoint=1, options=<EmberApsOption.APS_OPTION_ENABLE_ROUTE_DISCOVERY: 256>, groupId=0, sequence=121), 254, -82, 0xdf10, 255, 255, b'\x18\xc0\n\x05\x05!\x92\x04']
2023-12-28 14:05:17.845 DEBUG (MainThread) [bellows.zigbee.application] Received incomingMessageHandler frame with [<EmberIncomingMessageType.INCOMING_UNICAST: 0>, EmberApsFrame(profileId=260, clusterId=2820, sourceEndpoint=1, destinationEndpoint=1, options=<EmberApsOption.APS_OPTION_ENABLE_ROUTE_DISCOVERY: 256>, groupId=0, sequence=121), 254, -82, 0xdf10, 255, 255, b'\x18\xc0\n\x05\x05!\x92\x04']
2023-12-28 14:05:17.845 DEBUG (MainThread) [zigpy.application] Received a packet: ZigbeePacket(timestamp=datetime.datetime(2023, 12, 28, 20, 5, 17, 845700, tzinfo=datetime.timezone.utc), src=AddrModeAddress(addr_mode=<AddrMode.NWK: 2>, address=0xDF10), src_ep=1, dst=AddrModeAddress(addr_mode=<AddrMode.NWK: 2>, address=0x0000), dst_ep=1, source_route=None, extended_timeout=False, tsn=121, profile_id=260, cluster_id=2820, data=Serialized[b'\x18\xc0\n\x05\x05!\x92\x04'], tx_options=<TransmitOptions.NONE: 0>, radius=0, non_member_radius=0, lqi=254, rssi=-82)
2023-12-28 14:05:17.847 DEBUG (MainThread) [zigpy.zcl] [0xDF10:1:0x0b04] Received ZCL frame: b'\x18\xc0\n\x05\x05!\x92\x04'
2023-12-28 14:05:17.847 DEBUG (MainThread) [zigpy.zcl] [0xDF10:1:0x0b04] Decoded ZCL frame header: ZCLHeader(frame_control=FrameControl(frame_type=<FrameType.GLOBAL_COMMAND: 0>, is_manufacturer_specific=0, direction=<Direction.Client_to_Server: 1>, disable_default_response=1, reserved=0, *is_cluster=False, *is_general=True), tsn=192, command_id=10, *direction=<Direction.Client_to_Server: 1>)
2023-12-28 14:05:17.849 DEBUG (MainThread) [zigpy.zcl] [0xDF10:1:0x0b04] Decoded ZCL frame: ElectricalMeasurement:Report_Attributes(attribute_reports=[Attribute(attrid=0x0505, value=TypeValue(type=uint16_t, value=1170))])
2023-12-28 14:05:17.849 DEBUG (MainThread) [zigpy.zcl] [0xDF10:1:0x0b04] Received command 0x0A (TSN 192): Report_Attributes(attribute_reports=[Attribute(attrid=0x0505, value=TypeValue(type=uint16_t, value=1170))])
2023-12-28 14:05:17.850 DEBUG (MainThread) [zigpy.zcl] [0xDF10:1:0x0b04] Attribute report received: rms_voltage=1170
2023-12-28 14:05:17.852 DEBUG (MainThread) [serialpy.descriptor_transport] Immediately writing b'\x82P:~'
2023-12-28 14:05:17.853 DEBUG (MainThread) [serialpy.descriptor_transport] Sent 4 of 4 bytes
...

Copy link

codecov bot commented Dec 28, 2023

Codecov Report

All modified and coverable lines are covered by tests ✅

Comparison is base (09b2782) 99.78% compared to head (94e0e6e) 99.81%.

Additional details and impacted files
@@            Coverage Diff             @@
##              dev     #604      +/-   ##
==========================================
+ Coverage   99.78%   99.81%   +0.02%     
==========================================
  Files          67       68       +1     
  Lines        4728     4817      +89     
==========================================
+ Hits         4718     4808      +90     
+ Misses         10        9       -1     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@puddly puddly marked this pull request as ready for review December 29, 2023 18:02
@puddly puddly merged commit d917e99 into zigpy:dev Dec 29, 2023
14 checks passed
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

Successfully merging this pull request may close these issues.

1 participant