Skip to content

Commit ca95765

Browse files
author
Brad Powell
committed
In asyntest.py changed how to detect the platform.
1 parent d976db9 commit ca95765

File tree

1 file changed

+14
-8
lines changed

1 file changed

+14
-8
lines changed

asyntest.py

Lines changed: 14 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,23 +1,29 @@
11
# asyntest.py Test/demo of asychronous use of MessagePack
22

3-
# Configured for a Pyboard. Link pins X1 and X2.
4-
53
# Copyright (c) 2021 Peter Hinch Released under the MIT License see LICENSE
64

7-
# Free RAM after reset 101504 bytes. Free RAM while running 82944 bytes
8-
# Usage 18560 bytes i.e. ~18.1KiB
9-
# This compares with 5312 bytes for a similar script sending plain text.
10-
# The MessagePack overhead is thus 13,248 bytes (12.9KiB).
5+
# From testing on a pyboard:
6+
# Free RAM after reset 101504 bytes. Free RAM while running 82944 bytes
7+
# Usage 18560 bytes i.e. ~18.1KiB
8+
# This compares with 5312 bytes for a similar script sending plain text.
9+
# The MessagePack overhead is thus 13,248 bytes (12.9KiB).
1110

11+
from sys import platform
1212
import asyncio
1313
import umsgpack
1414
from machine import UART, Pin
1515
import gc
1616

17-
try:
17+
18+
if platform == "pyboard":
1819
uart = UART(4, 9600) # Pyboard (link pins X1 and X2)
19-
except ValueError:
20+
elif platform == "rp2":
2021
uart = UART(0, baudrate=9600, tx=Pin(0), rx=Pin(1)) # Pi Pico (link pins 0 and 1)
22+
elif platform == "esp32":
23+
uart = UART(2, baudrate=9600, tx=17, rx=16) # Adafruit Huzzah32 (link pins TX and RX)
24+
else:
25+
raise OSError(f"Unknown platform {platform}")
26+
2127

2228
async def sender():
2329
swriter = asyncio.StreamWriter(uart, {})

0 commit comments

Comments
 (0)