-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
2 changed files
with
68 additions
and
21 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
#!/usr/bin/env python3 | ||
""" | ||
simple listener to receive data from the mock robot | ||
Copyright (c) 2024 ROX Automation - Jev Kuznetsov | ||
""" | ||
|
||
import logging | ||
from data_generator import WS_HOST, WS_PORT | ||
from websockets.sync.client import connect | ||
from roxbot import LOG_FORMAT | ||
import coloredlogs | ||
|
||
log = logging.getLogger("listener") | ||
|
||
coloredlogs.install(level=logging.DEBUG, fmt=LOG_FORMAT) | ||
|
||
|
||
def echo() -> None: | ||
uri = f"ws://{WS_HOST}:{WS_PORT}" | ||
with connect(uri) as websocket: | ||
while True: | ||
msg = websocket.recv() | ||
log.info(f"Received: {str(msg)}") # Decode the bytes before formatting | ||
|
||
|
||
if __name__ == "__main__": | ||
try: | ||
echo() | ||
except KeyboardInterrupt: | ||
pass |