How to save an input value to a file?

Alles rund um TX(T) und RoboPro, mit ft-Hard- und Software
Computing using original ft hard- and software
Forumsregeln
Bitte beachte die Forumsregeln!
Antworten
zhengtzer
Beiträge: 15
Registriert: 22 Aug 2023, 12:11

How to save an input value to a file?

Beitrag von zhengtzer » 22 Aug 2023, 12:22

Hi,


i just bought a txt4.0, in testing how to read/write csv file through python code in robo pro coding

may i ask how?
it is showing in console, just not writing anything to file, anything i did wrong?


thanks
Jonathan
Dateianhänge
switch.png
switch.png (125.7 KiB) 4205 mal betrachtet

Benutzeravatar
fishfriend
Beiträge: 1823
Registriert: 26 Nov 2010, 11:45

Re: How to save an input value to a file?

Beitrag von fishfriend » 22 Aug 2023, 16:17

Hallo...
I am not shure.
If the Button ist presed, you want to write -one- time s.t. like utf8 ?
It do not added something to a file. ('a')

Mit freundlichen Grüßen
Holger
ft Riesenräder PDF: ftcommunity.de/knowhow/bauanleitungen
TX-Light: Arduino und ftduino mit RoboPro

zhengtzer
Beiträge: 15
Registriert: 22 Aug 2023, 12:11

Re: How to save an input value to a file?

Beitrag von zhengtzer » 22 Aug 2023, 19:01

HiHi!!!

[Question 1]
i want to write the word "close" into file everytime i pressed a button
i want to know how to write value into a local file

check user guide, its showing empty~~LOL?
empty_guide.png
empty_guide.png (131.62 KiB) 4168 mal betrachtet
so that i can add timestamp later on and "mimic" IoT locally
as now i seriosuly struggling with ft MQTT


[Question 2]
if doesn't change the file path, where exactly will the file been saved?


until now no luck, need some light here :shock:


thanks
Jonathan

Benutzeravatar
fishfriend
Beiträge: 1823
Registriert: 26 Nov 2010, 11:45

Re: How to save an input value to a file?

Beitrag von fishfriend » 23 Aug 2023, 21:28

Hallo...
Maybe in Python not in RoboPro Coding.

...
datei = open('test_data.cvs','a')
datei.write("\r\nClose")

so you get:

Close
Close
...
in test_data.cvs

Mit freundlichen Grüßen
Holger
ft Riesenräder PDF: ftcommunity.de/knowhow/bauanleitungen
TX-Light: Arduino und ftduino mit RoboPro

zhengtzer
Beiträge: 15
Registriert: 22 Aug 2023, 12:11

Re: How to save an input value to a file?

Beitrag von zhengtzer » 25 Aug 2023, 16:23

Hallo,


did you know where is "/home/ftgui" filepath?
ft_writeLocal_02.png
ft_writeLocal_02.png (106.35 KiB) 3997 mal betrachtet

code seem correct, but cant locate the file

tyty
Jonathan

Benutzeravatar
fishfriend
Beiträge: 1823
Registriert: 26 Nov 2010, 11:45

Re: How to save an input value to a file?

Beitrag von fishfriend » 25 Aug 2023, 19:16

Hallo...
My point of view

os.chdir
only change the path
but in r" "
That ist not the correct name of the path.

The print only show the path where the file test_data.cvs is / is written.

So you find the file test_data.cvs in: home/ftgui/

Mit freundlichen Grüßen
Holger
ft Riesenräder PDF: ftcommunity.de/knowhow/bauanleitungen
TX-Light: Arduino und ftduino mit RoboPro

zhengtzer
Beiträge: 15
Registriert: 22 Aug 2023, 12:11

Re: How to save an input value to a file?

Beitrag von zhengtzer » 27 Aug 2023, 08:17

Hihi


i have no idea where [home/ftgui/] come from, its not from my pc directory

allow me to post some screenshot, as noticed the file path seem cant be changed
error2.png
error2.png (101 KiB) 3884 mal betrachtet
error3.png
error3.png (33.62 KiB) 3884 mal betrachtet

thanks
Jonathan

Benutzeravatar
fishfriend
Beiträge: 1823
Registriert: 26 Nov 2010, 11:45

Re: How to save an input value to a file?

Beitrag von fishfriend » 27 Aug 2023, 09:31

Hallo...
Hmmm...
Is there under User... a direktory ...99_trestData ?
And it is in the OneDireve -Cloud?
Maybe ist ist easyer to get only the User/Document dir on your own computer.

Mit freundlichen Grüßen
Holger
ft Riesenräder PDF: ftcommunity.de/knowhow/bauanleitungen
TX-Light: Arduino und ftduino mit RoboPro

zhengtzer
Beiträge: 15
Registriert: 22 Aug 2023, 12:11

Re: How to save an input value to a file?

Beitrag von zhengtzer » 28 Aug 2023, 06:42

Hi,


the directory had successfully changed
the main issue is, the [home/ftgui], the front part of directory seem unable to change
error4.png
error4.png (14.27 KiB) 3816 mal betrachtet
so the file is written to [home/ftgui] where i dont know where is it :cry:


thanks
Jonathan

Benutzeravatar
fishfriend
Beiträge: 1823
Registriert: 26 Nov 2010, 11:45

Re: How to save an input value to a file?

Beitrag von fishfriend » 28 Aug 2023, 16:19

Hallo...
RoboPro Coding is not installed like the normal Programs. It is installed as a Aplikation App.
There are hidden direktorys some thing leike Windows/App/RoboProCoding/...
May be there is your lost direktory.

An other ting is, wehen you logt in Windows, not as an Admin or a User who has not read acsess to that.
Mit freundlichen Grüßen
Holger
ft Riesenräder PDF: ftcommunity.de/knowhow/bauanleitungen
TX-Light: Arduino und ftduino mit RoboPro

Benutzeravatar
fishfriend
Beiträge: 1823
Registriert: 26 Nov 2010, 11:45

Re: How to save an input value to a file?

Beitrag von fishfriend » 28 Aug 2023, 16:33

Hallo...
OK, it is possible that the file is on the TXT 4.0 ?
So, i know it from the AI-Sortingline that the LOG-File is there.
Mit freundlichen Grüßen
Holger
ft Riesenräder PDF: ftcommunity.de/knowhow/bauanleitungen
TX-Light: Arduino und ftduino mit RoboPro

zhengtzer
Beiträge: 15
Registriert: 22 Aug 2023, 12:11

Re: How to save an input value to a file?

Beitrag von zhengtzer » 30 Aug 2023, 12:30

Hihi,


just checked in windows app, folder and subfolder all, not there
beemo.png
beemo.png (23.87 KiB) 3701 mal betrachtet
search on txt4.0, not there either

from your experience, is this how ft work?
let us user self study to dig out product info?


tyty

Benutzeravatar
fishfriend
Beiträge: 1823
Registriert: 26 Nov 2010, 11:45

Re: How to save an input value to a file?

Beitrag von fishfriend » 30 Aug 2023, 16:29

Hallo...
IF you use wlan or USB (or BT).
Check the IP Adress on the TXT 4.0. Linke: 192.168.2.101
Info/WLan
Take a browser, insert the IP Ardess.
Then you must insert: ft
and in the second Line: fischertechnik

And now go to TXT 4.0 folder.
Ther are a direktory(s) where the file (may be) is.
The upper dir (I think that ist the /ft/GUI)

Cause the Python Program runs on the TXT 4.0.
The TXT 4.0 has no permission to write a file on the PC.
Mit freundlichen Grüßen
Holger
ft Riesenräder PDF: ftcommunity.de/knowhow/bauanleitungen
TX-Light: Arduino und ftduino mit RoboPro

zhengtzer
Beiträge: 15
Registriert: 22 Aug 2023, 12:11

Re: How to save an input value to a file?

Beitrag von zhengtzer » 31 Aug 2023, 12:41

Hi


thanks, i learn something from you today :D
dont know ft txt4.0 can be access in such as way
ft_web.png
ft_web.png (76.3 KiB) 3637 mal betrachtet
i search through all folder, no file to be seen
ft_gui.png
ft_gui.png (98.4 KiB) 3637 mal betrachtet
i try manual key in ft/gui, not here
ft_web_gui.png
ft_web_gui.png (91.91 KiB) 3637 mal betrachtet

**studying the new AI sorting line, found out "ui" path, share with you
sortingLine.png
sortingLine.png (518.24 KiB) 3594 mal betrachtet
below is usual txt4.0 controller, will show node-red dashboard @_@
usual_txt40.png
usual_txt40.png (41.92 KiB) 3593 mal betrachtet


thanks
Jonathan

Benutzeravatar
fishfriend
Beiträge: 1823
Registriert: 26 Nov 2010, 11:45

Re: How to save an input value to a file?

Beitrag von fishfriend » 31 Aug 2023, 16:27

Hallo...
The AI Program stored two Files.
1. A log.txt File and
2. last-image.png picture.
If you look in the AI Program.
The "logging" is with
import logging
logging.basicConfig(level=logging.ERROR, format="%(asctime)s %(levelname)-10s %(funcName)3s %(message)s #%(filename)3s:%(lineno)d")
May be you can wirte other things in the file.

But there must be a way without the logging.
I will search about it, but it take some time in the moment.

There a saveral ways, to connect the PC with the TXT 4.0 . SSH, Node Red, MQTT ...
Mit freundlichen Grüßen
Holger
ft Riesenräder PDF: ftcommunity.de/knowhow/bauanleitungen
TX-Light: Arduino und ftduino mit RoboPro

Techum
Beiträge: 84
Registriert: 25 Dez 2014, 20:50
Kontaktdaten:

Re: How to save an input value to a file?

Beitrag von Techum » 19 Nov 2023, 16:37

zhengtzer hat geschrieben:
22 Aug 2023, 19:01
HiHi!!!

[Question 1]
i want to write the word "close" into file everytime i pressed a button
i want to know how to write value into a local file
[Question 2]
if doesn't change the file path, where exactly will the file been saved?
HI Jonathan, check here:
viewtopic.php?f=8&t=7482&p=63902#p63902
Techum

Antworten