Giter Club home page Giter Club logo

Comments (8)

nevercast avatar nevercast commented on July 23, 2024 1

I worked around this by adding a stub class.

class StreamHandler:

    def __init__(self, stream=None):
        self.stream = stream
        self.terminator = '\n'

    def emit(self, record):
        pass

    def flush(self):
        pass

    def setStream(self, stream):
        old_stream = self.stream
        self.stream = stream
        return old_stream

and a stub method

class Logger:
    def addHandler(self, handler):
        pass

This is a Python 3.8 feature which MicroPython doesn't explictly support.

from pysm.

pgularski avatar pgularski commented on July 23, 2024

This is actually a great idea. Will have a look at it.

from pysm.

pgularski avatar pgularski commented on July 23, 2024

I started to tinker with pyboards only recently and for what it's worth I tweaked the pysm internals a bit to make it work with pyboards.

I tested it against the ESP-32S board and works flawlessly.

See the https://github.com/pgularski/upysm/ for details.

One can install it basically with

import upip; pip.install('upysm')

Provided there's wifi support.

from pysm.

mattytrentini avatar mattytrentini commented on July 23, 2024

Just wanted to say thanks! Recently I've been looking for a state machine module that I could use in MicroPython and had resigned myself to porting or creating a new library. pysm is exactly what I was looking for! Thanks again for going to the trouble to add MicroPython compatibility.

from pysm.

pgularski avatar pgularski commented on July 23, 2024

Wow, for comments like this it's well worth sharing one's work as the open source software. Totally appreciate your feedback, Matt! Thanks!

from pysm.

nevercast avatar nevercast commented on July 23, 2024

Hi, a commit has broken MicroPython compatibility, 1fde9e1#diff-5225765ccd6201cc9a3f939e749fb117R10

MicroPython does not have a logging.StreamHandler class. This has landed in upysm

from pysm.

pgularski avatar pgularski commented on July 23, 2024

Hi @nevercast ,
Thanks for having a look and letting me know. The logging WAS working last time I was testing the pysm library, so either you've got a different version of MicroPython or something has changed.

The workaround you sent is actually pretty much what I'd suggest. One more thing though, I'd wrap the import logging statement in the try/except block and would call your stub code only if the import of the logging module fails.

I'll take a look at it some time this week, hopefully. I don't have much time now tho and my ESP32 is somewhere around... I do have it, I swear :)

If you could craft a pull request, preferably with some tests, I'd appreciate it.

Once again, thanks for using the pysm module!

from pysm.

nevercast avatar nevercast commented on July 23, 2024

I'm using the ESP32 port on MicroPython#master at https://github.com/micropython/micropython. The logging library, and collections.[deque|defaultdict] libraries came from https://github.com/micropython/micropython-lib. (I'm not using the native deque library at this time because you've used kwargs in your driver and the native library doesn't work with kwargs)

I'd say this port is probably the reference implementation, but I understand you may want to support ESP8266 also.

from pysm.

Related Issues (10)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.