Beispiel #1
0
    def stop(self):

        if self.sw_client:
            self.sw_client.close()
            uos.dupterm_notify(self.sw_client.socket)  # deactivate dupterm
            uos.dupterm(None)
            self.sw_client = None
Beispiel #2
0
    def poll(self, ignore=None):
        if self.keyboard.poll():
            uos.dupterm_notify(self)

        if self.screen.last_change:
            if time.ticks_diff(time.ticks_ms(),
                               self.screen.last_change) > DEBOUNCE_PERIOD:
                self.screen.update_screen()

        self.poller.init(period=10,
                         mode=Timer.ONE_SHOT,
                         callback=self.schedule_poll_ref)
Beispiel #3
0
    async def client_rx(self):

        while True:
            if self.sw_client != None:
                try:
                    yield asyncio.IORead(self.sw_client.socket)
                    uos.dupterm_notify(True)  # dupterm_notify will somehow make a copy of sw_client

                except:
                    # clean up
                    log.info("Telnet client disconnected ...")
                    yield asyncio.IOReadDone(self.sw_client.socket)
                    self.stop()

                await asyncio.sleep_ms(1)
            else:
                await asyncio.sleep(1)
Beispiel #4
0
 def __check(self):
     import utime
     from uio import StringIO
     from uos import dupterm, dupterm_notify
     exec_fime = "execfile('" + self.name + "')\r\n"
     dupterm(StringIO(exec_fime))
     dupterm_notify(None)
     bak, last_time = self.__file_time(), utime.ticks_ms()
     while (self.state):
         if (utime.ticks_ms() > last_time + 2000):
             tmp, last_time = self.__file_time(), utime.ticks_ms()
             if (bak != tmp and lock.acquire()):
                 bak = tmp
                 dupterm(StringIO("\x03\x43"))
                 dupterm_notify(None)
                 dupterm(StringIO(exec_fime))
                 dupterm_notify(None)
                 lock.release()
     _thread.exit()
Beispiel #5
0
def _check_file():
    import utime
    from uio import StringIO
    from uos import dupterm, dupterm_notify
    global _file, _state, _time
    run_cmd = "execfile('%s')\r\n" % (_file)
    dupterm(StringIO(run_cmd))
    dupterm_notify(None)
    bak, last_time = _file_time(_file), utime.time()
    while (_state):
        if (utime.time() > last_time + _time):
            tmp, last_time = _file_time(_file), utime.time()
            if (bak != tmp and lock.acquire()):
                bak = tmp
                dupterm(StringIO("\x03\x43"))
                dupterm_notify(None)
                dupterm(StringIO(run_cmd))
                dupterm_notify(None)
                lock.release()
    _thread.exit()
Beispiel #6
0
 def read_from_sock(self, sock):
     uos.dupterm_notify(sock)