Wake Up bzw. Sleep Mode

Alles rund um TX(T) und RoboPro, mit ft-Hard- und Software
Computing using original ft hard- and software
Forumsregeln
Bitte beachte die Forumsregeln!
sunnyheaven
Beiträge: 31
Registriert: 04 Jan 2021, 05:32

Wake Up bzw. Sleep Mode

Beitrag von sunnyheaven » 26 Mär 2021, 20:36

Hallo zusammen,

ein cooles Feature wäre eine Wake Up- oder Sleep Mode-Funktion für den TXT.
Entweder der TXT wacht selber auf (er hat ja eine RTC) oder er wird über ein externes Triggersignal geweckt (z.B. Pins des EXT Anschlusses oder USB).
Wie es scheint gibt es so eine Funktion mit RoboPro nicht. Mit CFW soll es sowas ja geben (ist aber erst mal keine Option).
Hat jemand eine Idee?

Gruß
Jan

vleeuwen
Beiträge: 1557
Registriert: 31 Okt 2010, 22:23
Wohnort: Enschede (NL)
Kontaktdaten:

Re: Wake Up bzw. Sleep Mode

Beitrag von vleeuwen » 27 Mär 2021, 08:45

You could try a dummy read to I2C device.( every <5 sec as documented on the fischertechnik Github site)
I did not test did yet but I have the idea that it will work.
Zuletzt geändert von vleeuwen am 27 Mär 2021, 23:18, insgesamt 1-mal geändert.
software enigineer/teacher/advisor
Google translate
http://tescaweb.nl/Carel/?p=713

Benutzeravatar
MasterOfGizmo
Beiträge: 2720
Registriert: 30 Nov 2014, 07:44

Re: Wake Up bzw. Sleep Mode

Beitrag von MasterOfGizmo » 27 Mär 2021, 20:23

I don''t understand your answer at all. What device is supposed to send a dummy request where and what do you expect to happen then?
Arduino für fischertechnik: ftDuino http://ftduino.de, ftDuino32 http://ftduino.de/32

vleeuwen
Beiträge: 1557
Registriert: 31 Okt 2010, 22:23
Wohnort: Enschede (NL)
Kontaktdaten:

Re: Wake Up bzw. Sleep Mode

Beitrag von vleeuwen » 27 Mär 2021, 23:17

See the fischertechnik GitHub site.
It has been documented there.
I2C is implemented with SLI and required also an action within 5 sec.
software enigineer/teacher/advisor
Google translate
http://tescaweb.nl/Carel/?p=713

Benutzeravatar
PHabermehl
Beiträge: 2427
Registriert: 20 Dez 2014, 22:59
Wohnort: Bad Hersfeld

Re: Wake Up bzw. Sleep Mode

Beitrag von PHabermehl » 27 Mär 2021, 23:19

Dear Carel,

I don't get that, too. The question was how to wake up a switched off TXT remotely. A switched off TXT can not receive I2C messages, so how would you wake up (boot) the TXT by I2C?

Kind regards
Peter
https://www.MINTronics.de -- der ftDuino & TX-Pi Shop!

viele Grüße
Peter

vleeuwen
Beiträge: 1557
Registriert: 31 Okt 2010, 22:23
Wohnort: Enschede (NL)
Kontaktdaten:

Re: Wake Up bzw. Sleep Mode

Beitrag von vleeuwen » 28 Mär 2021, 00:58

I probably misunderstood the question.
My answer is from the point of view of the ROBOPro and the ROBOPro runtime.
This to react on the question about ROBOPro
1)
There exist a problem with the SLI and I2C. To solve this problem, there is a need for a keep awake(stay alive) action.
Without an action in relation with the SLI loader, this part fall in sleep after 5 sec of in-activity. It can not be wake up again without restarting the program.
2)
By my knowledge the TXT with the fischertechnik firmware does normally not fall in sleep.
From the EXT connector, the I2C is the only connection that can be used programmatically under the ROBOPro runtime. The serial pins are preserved for low level loading actions and no useable programmatically.
The USB could be used programmatically in a SLI and to be part of an ROBOPro element.
From the point of view of the ROBOPro runtime it is possible to develop an ROBOPro SLI extension element which poles an I2C device or an USB device or an (embedded web) socket to awake the ROBOPro program. Because ROBOPro is using data flow for the inter-proces communication, the data flow will need to signal the workflow processes to fall in sleep or to wake up.
So the ROBOPro runtime needs to be actif, for the communication with the Motor/IO control and for the ROBOPro program.
By my knowledge there is, with the TXT under the fischertechnik firmware, no hardware interrupt available or defined that can serve as hardware wake up to start the ROBOPro runtime or even the OS.
Some I2C devices are able to generate a hardware interrupt for activating the master but this line needs to be connected with a hardware interrupt of the master. The only option in combination with ROBOPro is using one of the I(put)'s; but this is already possible in ROBOPro without addition ROBOPro SLI extension element.
software enigineer/teacher/advisor
Google translate
http://tescaweb.nl/Carel/?p=713

Benutzeravatar
MasterOfGizmo
Beiträge: 2720
Registriert: 30 Nov 2014, 07:44

Re: Wake Up bzw. Sleep Mode

Beitrag von MasterOfGizmo » 28 Mär 2021, 08:40

vleeuwen hat geschrieben:
28 Mär 2021, 00:58
I probably misunderstood the question.
Indeed you did.
Arduino für fischertechnik: ftDuino http://ftduino.de, ftDuino32 http://ftduino.de/32

sunnyheaven
Beiträge: 31
Registriert: 04 Jan 2021, 05:32

Re: Wake Up bzw. Sleep Mode

Beitrag von sunnyheaven » 28 Mär 2021, 10:08

Yes, Carel misunderstood...
Wood have been a cool function.

vleeuwen
Beiträge: 1557
Registriert: 31 Okt 2010, 22:23
Wohnort: Enschede (NL)
Kontaktdaten:

Re: Wake Up bzw. Sleep Mode

Beitrag von vleeuwen » 28 Mär 2021, 10:27

Wood have been a cool function
If possible could you explain this? I don't see this in relation with the concept of ROBOPro runtime (multi process work flow with data flow for process synchronisation, which is the main starting point and base in this thread.)
software enigineer/teacher/advisor
Google translate
http://tescaweb.nl/Carel/?p=713

Benutzeravatar
The Rob
Moderator
Beiträge: 968
Registriert: 03 Dez 2015, 12:54

Re: Wake Up bzw. Sleep Mode

Beitrag von The Rob » 28 Mär 2021, 12:07

vleeuwen hat geschrieben:
28 Mär 2021, 10:27
Wood have been a cool function
If possible could you explain this? I don't see this in relation with the concept of ROBOPro runtime (multi process work flow with data flow for process synchronisation, which is the main starting point and base in this thread.)
I think you still seem to misunderstand the topic at hand.
Sunnyheaven wants to know if there is a way to wake up a TXT.
This can be meant either after putting it to sleep with an internal or external signal, or because it does afaik not automatically start after a power cycle.

Benutzeravatar
MasterOfGizmo
Beiträge: 2720
Registriert: 30 Nov 2014, 07:44

Re: Wake Up bzw. Sleep Mode

Beitrag von MasterOfGizmo » 28 Mär 2021, 17:41

The TXT technically has the ability to power itself on. To accomplish this it has a coin cell battery backup powered hardware clock inside. This hardware runs even if the TXT is powered down to keep and advance this internal clock. If the TXT is connected to a 9v power source but powered off then it's possible that this clock can wake the TXT up. The CFW can do this. It can program the clock for automatic wakeup at a given time. If you then shut the TXT down it's clock will make it power up at the programmed time.

It might be possible to achieve this under RoboPro as well with those SLI stuff. This depends on the TXT's firmware and if it includes the necessary drivers for the clock chip and if it leaves the remaining hardware in a state where it can be woken up that way.

May I suggest that people only answer questions if they actually know a valid answer? Otherwise this only confuses people.

And BTW: The TX-Pi can do the same when using the TX-Pi HAT. It will be interesting to see if the new TXT will also be able to do this. I doubt it ...
Arduino für fischertechnik: ftDuino http://ftduino.de, ftDuino32 http://ftduino.de/32

sunnyheaven
Beiträge: 31
Registriert: 04 Jan 2021, 05:32

Re: Wake Up bzw. Sleep Mode

Beitrag von sunnyheaven » 28 Mär 2021, 20:22

MasterOfGizmo hat geschrieben:
28 Mär 2021, 17:41
The TXT technically has the ability to power itself on. To accomplish this it has a coin cell battery backup powered hardware clock inside. This hardware runs even if the TXT is powered down to keep and advance this internal clock. If the TXT is connected to a 9v power source but powered off then it's possible that this clock can wake the TXT up. The CFW can do this. It can program the clock for automatic wakeup at a given time. If you then shut the TXT down it's clock will make it power up at the programmed time.

It might be possible to achieve this under RoboPro as well with those SLI stuff. This depends on the TXT's firmware and if it includes the necessary drivers for the clock chip and if it leaves the remaining hardware in a state where it can be woken up that way.

May I suggest that people only answer questions if they actually know a valid answer? Otherwise this only confuses people.

And BTW: The TX-Pi can do the same when using the TX-Pi HAT. It will be interesting to see if the new TXT will also be able to do this. I doubt it ...

Great idea, I will try this the next days!
@all: did anybody tried this?
@MarsterOf Gizmo: Do you know whether there is a driver for the clock in C?

Gruß
Jan

Benutzeravatar
MasterOfGizmo
Beiträge: 2720
Registriert: 30 Nov 2014, 07:44

Re: Wake Up bzw. Sleep Mode

Beitrag von MasterOfGizmo » 28 Mär 2021, 20:51

sunnyheaven hat geschrieben:
28 Mär 2021, 20:22
@MarsterOf Gizmo: Do you know whether there is a driver for the clock in C?
I actually don't even remember who did this in the CFW. Imho it was Raphael. And I always assumed there was something broken on hardware side with this as ft never implemented this feature.

But the driver should imho be there as the TXT uses the clock to display the time.

Edit: Here are the details: viewtopic.php?f=33&t=3826
Arduino für fischertechnik: ftDuino http://ftduino.de, ftDuino32 http://ftduino.de/32

sunnyheaven
Beiträge: 31
Registriert: 04 Jan 2021, 05:32

Re: Wake Up bzw. Sleep Mode

Beitrag von sunnyheaven » 24 Apr 2021, 20:41

Hi zusammen,

hab mir die Links von MasterOfGizmo und alles andere in dem Zusammenhang nochmal angeschaut. Ich krieg das einfach nicht auf die Kette. Kenn mich natürlich aus mit RoboPro (bringt hier wohl nix), bisschen SLI, die CFW hab ich auch installiert. Das war's dann schon...

Hintergrund: ich hätte gerne eine Funktion, die in definierten Abständen, z.B. alle 24h, aufwacht und z.B. Sensordaten speichert.

Kann mir jemand Tipps geben, wo ich ansetzen kann?

Gruß
Jan


WildCat
Beiträge: 32
Registriert: 29 Mai 2021, 10:26

Re: Wake Up bzw. Sleep Mode

Beitrag von WildCat » 30 Mai 2021, 18:55

Ich hatte mal eine App für die CFW für den Autostart gemacht. Sie benötigt allerdings root Rechte. Einfach Zeit einstellen und herunterfahren. :D

Code: Alles auswählen

#! /usr/bin/env python3
# -*- coding: utf-8 -*-
#

import sys, os
from subprocess import call
import time
import ftrobopy
from TouchStyle import *
from TxtStyle import *
from TouchAuxiliary import *

class FtcGuiApplication(TouchApplication):
    def __init__(self, args):
        TouchApplication.__init__(self, args)

        # create the empty main window
        w = TxtWindow("Autostart")
        
        self.vbox = QVBoxLayout()
        #________________________ Anfang

        
            
        bt = QPushButton("Herunterfahren")
        bt.clicked.connect(self.her)
        self.vbox.addWidget(bt)
        
        llb = QLabel("Zeit einstellen:")
        self.vbox.addWidget(llb)
        
        self.input = QLineEdit()
        self.vbox.addWidget(self.input)
        
        auto = QPushButton("fertig!")
        auto.clicked.connect(self.autostart)
        self.vbox.addWidget(auto)
        
        
  
        #_________________________ Ende
        w.centralWidget.setLayout(self.vbox)
        
        

        w.show()
        self.exec_()
        
    
    def her(self):
        call(["sudo", "poweroff"])
        
    def autostart(self):
        timee = self.input.text()
        f = open('/sys/class/rtc/rtc1/since_epoch',"r")
        jetzt = f.read()
        try:
            gleich = int(jetzt) + int(timee)
            print("jetzt ist es:", jetzt)
            print("Wenn ich wieder an gehe ist es:", gleich)


            call(["sudo", "chmod", "a+w", "/sys/class/rtc/rtc1/wakealarm"])
            wake = open('/sys/class/rtc/rtc1/wakealarm',"a")
            wake.write(str(gleich))
            wake.close()
        except:
            print("Keine Zahl!")
    	
 
if __name__ == "__main__":
    FtcGuiApplication(sys.argv)

sunnyheaven
Beiträge: 31
Registriert: 04 Jan 2021, 05:32

Re: Wake Up bzw. Sleep Mode

Beitrag von sunnyheaven » 31 Mai 2021, 00:01

Hi WildCat,

coole Idee, danke!
Kann die CFW automatisch ein RoboPro-Programm starten? Muss ich mal probieren.

WildCat
Beiträge: 32
Registriert: 29 Mai 2021, 10:26

Re: Wake Up bzw. Sleep Mode

Beitrag von WildCat » 01 Jun 2021, 18:27

Du kannst RoboPro-Programme (Lv.1) mit dem RoProPreter( https://github.com/ftCommunity/ftcommun ... preter.zip ) in der CFW starten.

sunnyheaven
Beiträge: 31
Registriert: 04 Jan 2021, 05:32

Re: Wake Up bzw. Sleep Mode

Beitrag von sunnyheaven » 03 Jun 2021, 21:24

Hi WildCat,

prinzipiell ne coole Sache, Level 1 ist halt recht reduziert.
Ich komm wohl um ftrobopy nicht drumrum, wenn ich mehr Funktionen haben will. Kann auch ein Python-Programm automatisch gestartet werden?

Gruß
Jan

WildCat
Beiträge: 32
Registriert: 29 Mai 2021, 10:26

Re: Wake Up bzw. Sleep Mode

Beitrag von WildCat » 04 Jun 2021, 11:14

Hi,
Du kannst dich über SSH als ftc anmelden und eine App starten, indem du den Dateipfad zum Python-Programm eingibst. Z.B. kannst du TXTShow über

Code: Alles auswählen

/opt/ftc/apps/user/37681ea0-dc00-11e6-9598-0800200c9a66/txtshow.py
starten ;)

Edit: Du kannst das Python-Programm auch durch ein Programm in /etc/init.d beim Systemstart starten. Um TXTShow zu starten, musst du ein Programm /etc/init.d/S99Autostart erstellen mit dem Inhalt

Code: Alles auswählen

#! /usr/bin/sh

sudo -u ftc /opt/ftc/apps/user/37681ea0-dc00-11e6-9598-0800200c9a66/txtshow.py

Antworten