Quellcode durchsuchen

lecture float arduino et flushInput du serial Arduino avant boucle reception données

tags/PoDoCor-v0.2^2
lilian vor 2 Jahren
Ursprung
Commit
952c47bf02
2 geänderte Dateien mit 8 neuen und 2 gelöschten Zeilen
  1. +2
    -2
      bin/data.py
  2. +6
    -0
      main.py

+ 2
- 2
bin/data.py Datei anzeigen

@@ -127,7 +127,7 @@ class Arduino_data():
if(coma_places == -1 and len(raw_data_txt) < 2):
print("Donnees non transmises par l'Arduino.")
elif(coma_places == -1 and len(raw_data_txt) > 2):
raw_data_temp[0,0] = int(raw_data_txt)
raw_data_temp[0,0] = float(raw_data_txt)
if(len(coma_places) != self.nb_captor_signals-1):
if(len(coma_places) < self.nb_captor_signals-1):
print("Il y a moins de donnees transmises que de capteurs. Vérifiez les donnees transmises.")
@@ -138,7 +138,7 @@ class Arduino_data():
coma_places.insert(0,-1)
coma_places.append(len(raw_data_txt))
for i in range(min(len(coma_places)-1, self.nb_captor_signals)):
self.raw_data_temp[0,i] = int(raw_data_txt[coma_places[i]+1:coma_places[i+1]])
self.raw_data_temp[0,i] = float(raw_data_txt[coma_places[i]+1:coma_places[i+1]])
self.data_array = np.append(self.data_array, self.raw_data_temp, axis=0)

def create_data_file(self):


+ 6
- 0
main.py Datei anzeigen

@@ -12,6 +12,10 @@ parameters_path = os.path.abspath(os.path.dirname(__file__)) + "/parameters.txt"
data_nb = 10
captors_path = os.path.abspath(os.path.dirname(__file__)) + "/captors.txt"
serial_path = fc.read_line_file(parameters_path)
#si '\n' a l'interieur du lien, peut ne pas fonctionner, donc a enlever
bad_path_enter_place = serial_path.find("\n")
if(bad_path_enter_place > 0):
serial_path = serial_path[0:bad_path_enter_place]+serial_path[bad_path_enter_place+2:]

#Variables cachees

@@ -72,6 +76,7 @@ while(flag_state > 0):
figures.create_figure(titles_list)
data_buff_nb = 0
arduino_data.create_data_file()
arduino_ser.flushInput()
time_0 = time.time()-1
while(flag_state == 2): #boucle de reception des donnees
time_0 = time_0+1
@@ -90,6 +95,7 @@ while(flag_state > 0):
data_buff_nb +=1
data_buff = data_buff + str(raw_data_txt)[2:-5] + "\n" #add 1 data line in buffer
#procedure extraction donnees pour affichage
#print(str(raw_data_txt)[2:-5], "azerty")
arduino_data.extract_data_to_array(str(raw_data_txt)[2:-5])




Laden…
Abbrechen
Speichern