From 974d61ff51026d81bdfb3fcc1a1c69fc94e99871 Mon Sep 17 00:00:00 2001 From: lilian Date: Tue, 9 Feb 2021 16:43:27 +0100 Subject: [PATCH] =?UTF-8?q?Avancement=20de=20la=20structure=20basique=20(t?= =?UTF-8?q?out=20est=20dans=20main.py),=20mauvaise=20lecture=20de=20ce=20q?= =?UTF-8?q?u'envoie=20Arduino.=20Prochain=20ajout=20:=20code=20Arduino=20e?= =?UTF-8?q?t=20graphiques=20de=20donn=C3=A9es=20raw=20temps=20r=C3=A9el?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- LICENSE | 19 +++++++++++++ README.md | 7 +++++ main.py | 79 +++++++++++++++++++++++++++++++++++++++++++++++++++++++ 3 files changed, 105 insertions(+) create mode 100644 LICENSE create mode 100644 README.md create mode 100755 main.py diff --git a/LICENSE b/LICENSE new file mode 100644 index 0000000..204b93d --- /dev/null +++ b/LICENSE @@ -0,0 +1,19 @@ +MIT License Copyright (c) + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is furnished +to do so, subject to the following conditions: + +The above copyright notice and this permission notice (including the next +paragraph) shall be included in all copies or substantial portions of the +Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS +FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS +OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, +WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF +OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. diff --git a/README.md b/README.md new file mode 100644 index 0000000..a7efd8d --- /dev/null +++ b/README.md @@ -0,0 +1,7 @@ +## Poeles-Dragon-Calculator 0.1 + +Ce logiciel est distribué sous license MIT. + +Poeles-Dragon-Calculator (PoDoCor) est un logiciel d'expérimentation développé pour les besoins du Low-Tech Bordeaux. + +Pour l'instant il n'existe pas d'interface graphique, de plus il n'existe qu'en français. Cela sera développé plus tard. diff --git a/main.py b/main.py new file mode 100755 index 0000000..955f463 --- /dev/null +++ b/main.py @@ -0,0 +1,79 @@ +import serial +import numpy as np +import matplotlib.pyplot as plt +import msvcrt #clavier +import time + +#Variables principales + +serial_path = '/dev/tty.usbserial' +file_path = "~/PoDoCor" +data_nb = 10 + +#Variables cachees + +flag_data = 0 +data_buff_max = 10 +data_buff_nb = 0 +data_buff = "" +pressed_key = '' +data = np.empty(1, data_nb) +raw_data_temp = np.empty(1, data_nb) + + +#Programme principal + +#init +arduino_ser = serial.Serial(serial_path, 9600) #communication avec Arduino + +while(1): + pressed_key = msvcrt.getch() #detection de touche pressee (demarrage procedure acquisition) + if(pressed_key == 'P'): + flag_data = 1 + data_buff_nb = 0 + file_name = file_path + "/" + time.asctime()+".csv" + file = open(file_name, "w") + file.close() + else: + flag_data = 0 + + while(flag_data == 1): #boucle de reception des donnees + arduino_ser.write('1') #envoi de '1' a l'Arduino + raw_data_txt = ser.readline() #format des donnees: data1,data2,data3\n raw data + data_buff_nb +=1 + data_buff = data_buff + raw_data_txt + "\n" #add 1 data line in buffer + + #procedure extraction donnees pour affichage + for i in range(data_nb): + carac_coma_nb = 1 + while((raw_data_txt[carac_coma_nb] != ',') or (raw_data[carac_coma_nb:carac_coma_nb+2] != "\n")): #fin de la donnee ou de la ligne + carac_coma_nb +=1 + single_data = int(raw_data_txt[0:carac_coma_nb]) + raw_data_txt = raw_data_txt[carac_coma_nb+1:] + raw_data_temp[0,i] = single_data + np.append(data, raw_data, axis=1) + raw_data_temp = raw_data*0 + + # procedure d'ecriture fichier + if(data_buff_nb == data_buff_max): + file = open(file_name,"a") #mode append + file.write(data_buff) + file.close() + data_buff = "" #remise a zero + data_buff_nb = 0 + + pressed_key = msvcrt.getch() #detection de touche pressee (arret procedure acquisition) + if(pressedKey == 'P'): + flag_data = 0 + else: + flag_data = 1 + + + assert msvcrt.getch() != b'P' "Sortie de la boucle de reception des donnees" + + if(data_buff_nb > 0): + file = open(file_name,"a") + file.write(data_buff) + file.close() + data_buff = "" + data_buff_nb = 0