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

Remove text formating and new line insertion #3

Open
wants to merge 1 commit into
base: pylink
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 4 additions & 7 deletions main.py
Original file line number Diff line number Diff line change
Expand Up @@ -156,11 +156,8 @@ def __next__(self) -> Union[str, Type[StopIteration]]:
"""Read line, blocking mode"""
if not self.connected:
return StopIteration
# Wait for new line indefinitely, remove newline characters at the end and convert it to string
rx_data = self.read_blocking()
for line in rx_data.split("\n"):
# Sometimes lines end with "\r\n", sometimes with "\n" only.
return line.rstrip()
# Wait for new data block indefinitely
return self.read_blocking()

def __exit__(self, exc_type, exc_val, exc_tb):
try:
Expand All @@ -176,8 +173,8 @@ def connected(self) -> bool:

def main() -> None:
with SeggerRTTListener() as listener:
for line in listener:
print(line)
for data_block in listener:
print(data_block, end = '')


if __name__ == '__main__':
Expand Down