-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathTools.py
More file actions
38 lines (25 loc) · 954 Bytes
/
Tools.py
File metadata and controls
38 lines (25 loc) · 954 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
# -*- coding: utf-8 -*-
import serial
#----serielle Verbindung über UART----------------
ser = serial.Serial("/dev/serial0") #Serielle Verbindung aufbauen
ser.baudrate = 9600 #Baudrate festlegen
#-------------Methods---------------------------
def recievecommand(): #Wartet bis ein Befehl von dem Nextion Display gesendet wird
value_undecoded=ser.readline()
print(value_undecoded)
value_decoded=value_undecoded.decode()[:-2]
return value_decoded
def leereInputBuffer():
ser.flushInput()
def sendcommand(command): #Sendet Kommando an Nextion Display
if ser.isOpen():
ser.write(command.encode())
ser.write(b'\xFF\xFF\xFF')
def ReadFile(File_Path):
with open(File_Path) as file:
value=file.readline()
return value
def writeInFile(text, path_file):
file = open(path_file, "w")
file.write(text)
file.close()