Skip to content

Commit

Permalink
misc fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
iloveicedgreentea committed Mar 9, 2024
1 parent 91b2372 commit bf858e6
Show file tree
Hide file tree
Showing 3 changed files with 24 additions and 6 deletions.
20 changes: 15 additions & 5 deletions madvr/madvr.py
Original file line number Diff line number Diff line change
Expand Up @@ -360,12 +360,19 @@ async def read_notifications(self) -> None:
"Connection reset by peer. Attempting to reconnect..."
)
await self._reconnect()
except (AttributeError, asyncio.TimeoutError, OSError) as err:
except asyncio.TimeoutError as err:
# if no new notifications, just keep going
self.logger.debug("No new notifications to read: %s", err)
except AttributeError as err:
self.logger.error("Attribute error with notifications: %s", err)
await self._reconnect()
continue
except OSError as err:
self.logger.error("Reading notifications failed or timed out: %s", err)
continue

if not msg:
await asyncio.sleep(1)
await asyncio.sleep(0.1)
continue

await self._process_notifications(msg.decode("utf-8"))
Expand All @@ -377,14 +384,17 @@ async def _process_notifications(self, msg: str) -> None:
# for each /r/n split it by title, then the rest are values
for notification in notifications:
title, *signal_info = notification.split(" ")

if "NoSignal" in title:
self.msg_dict["is_signal"] = False

# dont process empty values
if not signal_info:
continue
# at least madvr sends attributes in a consistent order
# could use zip here but why? this works and is simple
if "NoSignal" in title:
self.msg_dict["is_signal"] = False
elif "IncomingSignalInfo" in title:

if "IncomingSignalInfo" in title:
self.msg_dict["is_signal"] = True
self.msg_dict["incoming_res"] = signal_info[0]
self.msg_dict["incoming_frame_rate"] = signal_info[1]
Expand Down
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@

setuptools.setup(
name="py_madvr2",
version="1.4.91",
version="1.4.92",
author="iloveicedgreentea2",
description="A package to control MadVR Envy over IP",
long_description=long_description,
Expand Down
8 changes: 8 additions & 0 deletions tests/testMadVR.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ async def test_process_info(self):
"incoming_frame_rate": "60p",
"incoming_color_space": "444",
"incoming_bit_depth": "12bit",
"is_signal": True,
"hdr_flag": True,
"incoming_colorimetry": "2020",
"incoming_black_levels": "TV",
Expand All @@ -43,3 +44,10 @@ async def test_process_info(self):
"outgoing_black_levels": "TV",
},
)
async def test_send_command(self):
"""Verify the send command func works"""
await madvr.send_command(["GetIncomingSignalInfo"])
await madvr.read_notifications()
# s = await madvr.send_command(["GetAspectRatio"])

print(madvr.msg_dict)

0 comments on commit bf858e6

Please sign in to comment.