Browse Source

Avancement de la structure basique (tout est dans main.py), mauvaise lecture de ce qu'envoie Arduino. Prochain ajout : code Arduino et graphiques de données raw temps réel

tags/PoDoCor-v0.1
lilian 3 years ago
commit
974d61ff51
3 changed files with 105 additions and 0 deletions
  1. +19
    -0
      LICENSE
  2. +7
    -0
      README.md
  3. +79
    -0
      main.py

+ 19
- 0
LICENSE View File

@@ -0,0 +1,19 @@
MIT License Copyright (c) <year> <copyright holders>

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.

+ 7
- 0
README.md View File

@@ -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.

+ 79
- 0
main.py View File

@@ -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

Loading…
Cancel
Save