Welcome to the Pycom forum Forum
    • \[\[global:header.categories\]\]
    • \[\[global:header.recent\]\]
    • \[\[global:header.tags\]\]
    • \[\[global:header.popular\]\]
    • Login

    Explore Pybytes | Official Documentation | Report a Firmware Bug/Issue | GitHub

    Unable to satisfy from uasyncio.websocket.server import WSReader, WSWriter

    Scheduled Pinned Locked Moved MicroPython
    1 Posts 1 Posters 25 Views 1 Watching
    Loading More Posts
    • Oldest to Newest
    • Newest to Oldest
    • Most Votes
    Reply
    • Reply as topic
    Log in to reply
    This topic has been deleted. Only users with topic management privileges can see it.
    • G Offline
      Gary Kuipers
      last edited by

      Problem: I have a program that uses this:
      import uasyncio
      from uasyncio.websocket.server import WSReader, WSWriter

      I have tried:
      upip.install('uasyncio')
      upip.install('uasyncio.websocket')
      upip.install('uasyncio.websocket.server')

      First Steps: (Proof of virginity)
      python3 /home/gk/.local/bin/esptool.py --chip esp32 --port /dev/ttyUSB0 erase_flash
      python3 /home/gk/.local/bin/esptool.py --chip esp32 --port /dev/ttyUSB0 --baud 460800 write_flash -z 0x1000 ../esp32-20220618-v1.19.1.bin
      Set up boot.py for network access and boothed the ESP32

      Starting from the top: upip.install('uasyncio')

      import upip
      upip.install('uasyncio')
      Installing to: /lib/
      Warning: micropython.org SSL certificate is not validated
      Installing uasyncio 3.0 from https://micropython.org/pi/uasyncio/uasyncio-3.0.tar.gz
      then:
      import main
      Traceback (most recent call last):
      ...
      ImportError: no module named 'uasyncio.websocket'

      Fair enough: do first steps again for a virgin board: upip.install('uasyncio.websocket')

      import upip
      upip.install('uasyncio.websocket')
      Installing to: /lib/
      Warning: micropython.org SSL certificate is not validated
      Error installing 'uasyncio.websocket': Package not found, packages may be partially installed

      Here I am confused ... how can it be "partially installed" if the board was cleared and the bin re-written to it?

      OK, so: do first steps again for a virgin board: no upip install this time:

      import main
      Traceback (most recent call last):
      ...
      ImportError: no module named 'uasyncio.websocket'

      Not sure what is going on.

      Help please!

      Thisis from: https://forum.micropython.org/viewtopic.php?f=15&t=6568
      <code>
      import uasyncio
      from uasyncio.websocket.server import WSReader, WSWriter

      def echo(reader, writer):
      # Consume GET line
      yield from reader.readline()

      reader = yield from WSReader(reader, writer)
      writer = WSWriter(reader, writer)
      
      while 1:
          l = yield from reader.readline()
          print(l)
          if l == b"\r":
              await writer.awrite(b"\r\n")
          else:
              await writer.awrite(l)
      

      import logging
      logging.basicConfig(level=logging.INFO)
      logging.basicConfig(level=logging.DEBUG)
      loop = uasyncio.get_event_loop()
      loop.create_task(uasyncio.start_server(echo, "192.168.4.1", 8081))
      loop.run_forever()
      loop.close()
      </code>

      1 Reply Last reply Reply Quote 0

      Hello! It looks like you're interested in this conversation, but you don't have an account yet.

      Getting fed up of having to scroll through the same posts each visit? When you register for an account, you'll always come back to exactly where you were before, and choose to be notified of new replies (either via email, or push notification). You'll also be able to save bookmarks and upvote posts to show your appreciation to other community members.

      With your input, this post could be even better 💗

      Register Login
      • 1 / 1
      • First post
        Last post

      Pycom on Twitter

      Pycom