Commit e62147c92617b04289786e02cdd7307f5a836afa
1 parent
679fa31a
MAJ Makefile
Showing
3 changed files
with
88 additions
and
8 deletions
Show diff stats
@@ -0,0 +1,82 @@ | @@ -0,0 +1,82 @@ | ||
1 | +export CC = avr-gcc | ||
2 | + | ||
3 | +export MCU = atmega328p | ||
4 | +export TARGET_ARCH = -mmcu=$(MCU) | ||
5 | + | ||
6 | +export CFLAGS = -Wall -I. -DF_CPU=16000000 -Os #-pedantic -std=c99#-g | ||
7 | +export LDFLAGS = -g $(TARGET_ARCH) -lm -Wl,--gc-sections # -Os | ||
8 | + | ||
9 | +TARGET = main | ||
10 | +TERM0 = /dev/ttyACM0 | ||
11 | +TERM1 = /dev/ttyACM1 | ||
12 | +CPPFLAGS = -mmcu=$(MCU) | ||
13 | +#PGMER = -c stk500v1 -b 57600 -P $(TERM) | ||
14 | + | ||
15 | +#Dans le cas de l'upload par USB (selon le port) | ||
16 | +PGMERISP0 = -c stk500v1 -b 115200 -P $(TERM0) | ||
17 | +PGMERISP1 = -c stk500v1 -b 115200 -P $(TERM1) | ||
18 | +ARVDUDECONF= -C /etc/avrdude.conf | ||
19 | +export DUDE = /usr/bin/avrdude -F -v -p $(MCU) $(AVRDUDECONF) | ||
20 | + | ||
21 | +#Dans le cas de l'upload par SPI depuis la raspberry | ||
22 | +PGMERISP_RPI = -c pi_3 | ||
23 | +ARVDUDECONF_RPI = -C ~/avrdude_gpio.conf | ||
24 | +export DUDE_RPI = /usr/bin/avrdude -F -v -p $(MCU) $(AVRDUDECONF_RPI) | ||
25 | + | ||
26 | +C_SRC = $(wildcard *.c) | ||
27 | +OBJS = $(C_SRC:.c=.o) | ||
28 | + | ||
29 | +all: $(TARGET).hex | ||
30 | + | ||
31 | +clean: | ||
32 | + rm -f *.o *.hex *.elf | ||
33 | + | ||
34 | +%.o:%.c | ||
35 | + $(CC) -c $< $(CPPFLAGS) $(CFLAGS) | ||
36 | + | ||
37 | +$(TARGET).elf: $(OBJS) | ||
38 | + $(CC) -o $@ $^ $(LDFLAGS) | ||
39 | + | ||
40 | +$(TARGET).hex: $(TARGET).elf | ||
41 | + avr-objcopy -j .text -j .data -O ihex $(TARGET).elf $(TARGET).hex | ||
42 | + avr-objcopy -j .eeprom --set-section-flags=.eeprom="alloc,load" --change-section-lma .eeprom=0 -O ihex $(TARGET).elf eeprom.hex | ||
43 | + | ||
44 | +#UPLOAD CONDITIONNEL | ||
45 | +FOLDER = $(notdir $(CURDIR)) | ||
46 | + | ||
47 | +upload: $(TARGET).hex | ||
48 | +#CAPTEUR 1 connecté en USB | ||
49 | +ifeq ($(FOLDER), capteur1-0) | ||
50 | + | ||
51 | + stty -F $(TERM0) hupcl # reset | ||
52 | + # $(DUDE) $(PGMER) -U flash:w:$(TARGET).hex | ||
53 | + $(DUDE) $(PGMERISP0) -U flash:w:$(TARGET).hex | ||
54 | +endif | ||
55 | + | ||
56 | +#CAPTEUR 1 connecté en SPI | ||
57 | +ifeq ($(FOLDER), capteur1-1) | ||
58 | + | ||
59 | + stty -F $(TERM0) hupcl # reset | ||
60 | + # $(DUDE) $(PGMER) -U flash:w:$(TARGET).hex | ||
61 | + $(DUDE_RPI) $(PGMERISP_RPI) -U flash:w:$(TARGET).hex | ||
62 | +endif | ||
63 | + | ||
64 | +#CAPTEUR 2 connecté en USB | ||
65 | +ifeq ($(FOLDER), capteur2-0) | ||
66 | + | ||
67 | + stty -F $(TERM1) hupcl # reset | ||
68 | + # $(DUDE) $(PGMER) -U flash:w:$(TARGET).hex | ||
69 | + $(DUDE) $(PGMERISP1) -U flash:w:$(TARGET).hex | ||
70 | +endif | ||
71 | + | ||
72 | +#CAPTEUR 2 connecté en SPI | ||
73 | +ifeq ($(FOLDER), capteur2-1) | ||
74 | + | ||
75 | + stty -F $(TERM1) hupcl # reset | ||
76 | + # $(DUDE) $(PGMER) -U flash:w:$(TARGET).hex | ||
77 | + $(DUDE_RPI) $(PGMERISP_RPI) -U flash:w:$(TARGET).hex | ||
78 | +endif | ||
79 | + | ||
80 | +size: $(TARGET).elf | ||
81 | + avr-size --format=avr --mcu=$(MCU) $(TARGET).elf | ||
82 | + |
site/fichiersRPI/Rpi_to_server.py
@@ -21,14 +21,14 @@ ip_address = file.readline()[:-1] | @@ -21,14 +21,14 @@ ip_address = file.readline()[:-1] | ||
21 | 21 | ||
22 | num_capteur = int(os.path.abspath(".")[-1]) | 22 | num_capteur = int(os.path.abspath(".")[-1]) |
23 | 23 | ||
24 | - | ||
25 | ser = serial.Serial("/dev/ttyACM0", 9600, timeout=1) | 24 | ser = serial.Serial("/dev/ttyACM0", 9600, timeout=1) |
26 | value = ser.readline() | 25 | value = ser.readline() |
27 | -while (value in ['\r', '', '\n']): | 26 | +print(value) |
27 | +while (value in ['\r', ' ', '\n', "b''"]): | ||
28 | value = ser.readline() | 28 | value = ser.readline() |
29 | data = str(float(value[0:4])) | 29 | data = str(float(value[0:4])) |
30 | 30 | ||
31 | - | ||
32 | params = {"ip_address": ip_address, "numero": num_capteur, "data": data, "date": date} | 31 | params = {"ip_address": ip_address, "numero": num_capteur, "data": data, "date": date} |
33 | -r = requests.post("http://projet-p10.plil.fr/requests.php", data = params) | ||
34 | -print(data) | ||
35 | \ No newline at end of file | 32 | \ No newline at end of file |
33 | +r = requests.post("http://projet-p10.plil.fr/IMA3_P10/site/requests.php", data = params) | ||
34 | +print(data) | ||
35 | +print(num_capteur) |