Commit 28da8e7b4c09bf04c08234cae3ee3ab4fc25833b
1 parent
9348158f
UPDATE
Showing
9 changed files
with
145 additions
and
243 deletions
Show diff stats
Moteur/Moteur.c
@@ -3,8 +3,8 @@ | @@ -3,8 +3,8 @@ | ||
3 | #include "serial.h" | 3 | #include "serial.h" |
4 | #include <avr/interrupt.h> | 4 | #include <avr/interrupt.h> |
5 | 5 | ||
6 | -#define LED_ON 0x01 | ||
7 | -#define LED_OFF 0x02 | 6 | +#define LED_ON 0x21 |
7 | +#define LED_OFF 0x22 | ||
8 | #define MOVE_RIGHT 0x04 | 8 | #define MOVE_RIGHT 0x04 |
9 | #define MOVE_LEFT 0x08 | 9 | #define MOVE_LEFT 0x08 |
10 | #define MOVE_STOP 0x10 | 10 | #define MOVE_STOP 0x10 |
No preview for this file type
@@ -0,0 +1 @@ | @@ -0,0 +1 @@ | ||
1 | +:00000001FF |
No preview for this file type
No preview for this file type
@@ -0,0 +1,33 @@ | @@ -0,0 +1,33 @@ | ||
1 | +:100000000C9434000C943E000C943E000C943E0082 | ||
2 | +:100010000C943E000C943E000C943E000C943E0068 | ||
3 | +:100020000C943E000C943E000C943E000C943E0058 | ||
4 | +:100030000C943E000C943E000C943E000C943E0048 | ||
5 | +:100040000C943E000C943E000C943E000C943E0038 | ||
6 | +:100050000C943E000C943E000C943E000C943E0028 | ||
7 | +:100060000C943E000C943E0011241FBECFEFD8E04C | ||
8 | +:10007000DEBFCDBF0E94A5000C94FC000C940000D4 | ||
9 | +:10008000F894219A81E880938000E1E8F0E08DE027 | ||
10 | +:1000900080838FEF90E0909389008093880084B1F3 | ||
11 | +:1000A000866084B98081816080837894089580E837 | ||
12 | +:1000B00090E09093890080938800089588E090E014 | ||
13 | +:1000C000909389008093880008958FEF90E090933B | ||
14 | +:1000D0008900809388000895579A1BB808955F9A05 | ||
15 | +:1000E00008955F9808959B01AC0184E0220F331FAF | ||
16 | +:1000F000441F551F8A95D1F760E074E284EF90E0C9 | ||
17 | +:100100000E94DA00215031093093C5002093C400C9 | ||
18 | +:1001100088E18093C10086E08093C200E0ECF0E0CB | ||
19 | +:1001200080818D7F808308959091C00095FFFCCFE2 | ||
20 | +:100130008093C60008958091C00087FFFCCF809116 | ||
21 | +:10014000C600089581E00C9494000E946C0060E861 | ||
22 | +:1001500075E280E090E00E9473000E94400000E899 | ||
23 | +:1001600010E088E0E82EF12CCFEFD0E00E949B0059 | ||
24 | +:100170008031C9F048F4843089F08830B9F7F092C2 | ||
25 | +:100180008900E092880013C0813229F0823271F731 | ||
26 | +:100190000E9471000CC00E946F0009C0109389007A | ||
27 | +:1001A0000093880004C0D0938900C09388000E9407 | ||
28 | +:1001B000A200DCCFA1E21A2EAA1BBB1BFD010DC0C1 | ||
29 | +:1001C000AA1FBB1FEE1FFF1FA217B307E407F50707 | ||
30 | +:1001D00020F0A21BB30BE40BF50B661F771F881FE3 | ||
31 | +:1001E000991F1A9469F760957095809590959B0179 | ||
32 | +:0C01F000AC01BD01CF010895F894FFCFD1 | ||
33 | +:00000001FF |
USB/usb_driver
No preview for this file type
USB/usb_driver.c
@@ -7,49 +7,26 @@ | @@ -7,49 +7,26 @@ | ||
7 | #include <unistd.h> | 7 | #include <unistd.h> |
8 | 8 | ||
9 | 9 | ||
10 | +#define LED_ON 0x21 | ||
11 | +#define LED_OFF 0x22 | ||
12 | +#define MOVE_RIGHT 0x04 | ||
13 | +#define MOVE_LEFT 0x08 | ||
14 | +#define MOVE_STOP 0x10 | ||
15 | + | ||
16 | + | ||
17 | +#define ACM_CTRL_DTR 0x01 | ||
18 | +#define ACM_CTRL_RTS 0x02 | ||
19 | + | ||
20 | +static int ep_in_addr = 0x83; | ||
21 | +static int ep_out_addr = 0x04; | ||
22 | + | ||
10 | libusb_device **list; | 23 | libusb_device **list; |
11 | libusb_device_handle *handle = NULL; | 24 | libusb_device_handle *handle = NULL; |
12 | libusb_device *device; | 25 | libusb_device *device; |
13 | -struct termios termios_p; | ||
14 | - | ||
15 | - | ||
16 | -int init_serial(char *device,int speed) //Initialisation du port série | ||
17 | -{ | ||
18 | -int fd=open(device,O_RDWR); | ||
19 | -if(fd<0){perror(device); exit(-1);} | ||
20 | -//Lecture des parametres courants | ||
21 | -tcgetattr(fd,&termios_p); | ||
22 | -//On ignore les BREAK et les caracteres avec erreurs de parite | ||
23 | -termios_p.c_iflag = IGNBRK | IGNPAR; | ||
24 | -//Pas de mode de sortie particulier | ||
25 | -termios_p.c_oflag = 0; | ||
26 | -//Liaison a 9600 bps avec 7 bits de donnees et une parite paire | ||
27 | -termios_p.c_cflag = B9600 | CS7 | PARENB; | ||
28 | -//Mode non-canonique avec echo | ||
29 | -termios_p.c_lflag = ECHO; | ||
30 | -//Caracteres immediatement disponibles | ||
31 | -termios_p.c_cc[VMIN] = 1; | ||
32 | -termios_p.c_cc[VTIME] = 0; | ||
33 | -//Sauvegarde des nouveaux parametres | ||
34 | -tcsetattr(fd,TCSANOW,&termios_p); | ||
35 | -return fd; | ||
36 | -} | ||
37 | 26 | ||
38 | 27 | ||
39 | -void close_serial(int fd) //Fermeture du port série | ||
40 | -{ | ||
41 | -tcsetattr(fd,TCSANOW,&termios_p); | ||
42 | -close(fd); | ||
43 | -} | ||
44 | 28 | ||
45 | 29 | ||
46 | -void callback(struct libusb_transfer *transf) //Fonction pour le transfert des instructions à la tourelle | ||
47 | -{ | ||
48 | - libusb_fill_control_setup(transf->buffer, 0xa1, 0x01, 0x300, 0x00, 0); | ||
49 | - libusb_fill_control_transfer(transf, transf->dev_handle, transf->buffer, NULL, NULL, 1000); | ||
50 | - fflush(stdout); | ||
51 | - libusb_free_transfer(transf); //on libere la structure de transfert | ||
52 | -} | ||
53 | 30 | ||
54 | void configuration_periph(libusb_device *device) //Configuration de la tourelle | 31 | void configuration_periph(libusb_device *device) //Configuration de la tourelle |
55 | { | 32 | { |
@@ -59,6 +36,7 @@ void configuration_periph(libusb_device *device) //Configuration de la tourelle | @@ -59,6 +36,7 @@ void configuration_periph(libusb_device *device) //Configuration de la tourelle | ||
59 | { | 36 | { |
60 | perror("libusb_open"); exit(-1); | 37 | perror("libusb_open"); exit(-1); |
61 | } | 38 | } |
39 | + | ||
62 | 40 | ||
63 | //Recuperation de la configuration d'indice 0 du périphérique | 41 | //Recuperation de la configuration d'indice 0 du périphérique |
64 | struct libusb_config_descriptor *config; | 42 | struct libusb_config_descriptor *config; |
@@ -72,31 +50,31 @@ void configuration_periph(libusb_device *device) //Configuration de la tourelle | @@ -72,31 +50,31 @@ void configuration_periph(libusb_device *device) //Configuration de la tourelle | ||
72 | int i; | 50 | int i; |
73 | int interface; | 51 | int interface; |
74 | 52 | ||
75 | - //Probleme noyau | 53 | + //On détache le noyau de notre périphérique |
76 | for(i=0;i<(config->bNumInterfaces);i++) | 54 | for(i=0;i<(config->bNumInterfaces);i++) |
77 | { | 55 | { |
56 | + interface=config->interface[i].altsetting[0].bInterfaceNumber; | ||
78 | if(libusb_kernel_driver_active(handle,interface)) | 57 | if(libusb_kernel_driver_active(handle,interface)) |
79 | - { | ||
80 | - status=libusb_detach_kernel_driver(handle,interface); | ||
81 | - if(status!=0) | ||
82 | - { | ||
83 | - perror("libusb_detach_kernel_driver"); exit(-1); | ||
84 | - } | ||
85 | - } | 58 | + { |
59 | + status=libusb_detach_kernel_driver(handle,interface); | ||
60 | + if(status!=0) | ||
61 | + { | ||
62 | + perror("libusb_detach_kernel_driver"); exit(-1); | ||
63 | + } | ||
64 | + } | ||
86 | } | 65 | } |
87 | 66 | ||
67 | + | ||
88 | //Utilisation d'une configuration du périphérique | 68 | //Utilisation d'une configuration du périphérique |
89 | int configuration=config->bConfigurationValue; | 69 | int configuration=config->bConfigurationValue; |
90 | - printf("%d\n", configuration); | ||
91 | -/* | ||
92 | - status=libusb_set_configuration(handle,configuration); | ||
93 | - | ||
94 | 70 | ||
71 | + status=libusb_set_configuration(handle,configuration); | ||
95 | if(status!=0) | 72 | if(status!=0) |
96 | { | 73 | { |
97 | perror("libusb_set_configuration"); exit(-1); | 74 | perror("libusb_set_configuration"); exit(-1); |
98 | } | 75 | } |
99 | - | 76 | + |
77 | + | ||
100 | //Claim interfaces | 78 | //Claim interfaces |
101 | for(i=0;i<(config->bNumInterfaces);i++) | 79 | for(i=0;i<(config->bNumInterfaces);i++) |
102 | { | 80 | { |
@@ -104,10 +82,10 @@ void configuration_periph(libusb_device *device) //Configuration de la tourelle | @@ -104,10 +82,10 @@ void configuration_periph(libusb_device *device) //Configuration de la tourelle | ||
104 | printf("Numero d'interface : %d\n", interface); | 82 | printf("Numero d'interface : %d\n", interface); |
105 | status=libusb_claim_interface(handle,interface); | 83 | status=libusb_claim_interface(handle,interface); |
106 | if(status!=0) | 84 | if(status!=0) |
107 | - { | ||
108 | - perror("libusb_claim_interface"); exit(-1); | ||
109 | - } | ||
110 | - }*/ | 85 | + { |
86 | + perror("libusb_claim_interface"); exit(-1); | ||
87 | + } | ||
88 | + } | ||
111 | } | 89 | } |
112 | 90 | ||
113 | 91 | ||
@@ -147,6 +125,7 @@ void enumeration(libusb_context *context) //Enumération des périphériques USB | @@ -147,6 +125,7 @@ void enumeration(libusb_context *context) //Enumération des périphériques USB | ||
147 | { | 125 | { |
148 | perror("libusb_get_device_list"); exit(-1); | 126 | perror("libusb_get_device_list"); exit(-1); |
149 | } | 127 | } |
128 | + | ||
150 | ssize_t i=0; | 129 | ssize_t i=0; |
151 | for(i=0;i<count;i++) | 130 | for(i=0;i<count;i++) |
152 | { | 131 | { |
@@ -156,132 +135,60 @@ void enumeration(libusb_context *context) //Enumération des périphériques USB | @@ -156,132 +135,60 @@ void enumeration(libusb_context *context) //Enumération des périphériques USB | ||
156 | if(status!=0) continue; | 135 | if(status!=0) continue; |
157 | uint8_t bus=libusb_get_bus_number(device); | 136 | uint8_t bus=libusb_get_bus_number(device); |
158 | uint8_t address=libusb_get_device_address(device); | 137 | uint8_t address=libusb_get_device_address(device); |
159 | - printf("Device Found @ (Bus:Address) %d:%d\n",bus,address); | ||
160 | - printf("Vendor ID 0x0%x\n",desc.idVendor); | ||
161 | - printf("Product ID 0x0%x\n",desc.idProduct); | ||
162 | - | ||
163 | - if ((desc.idVendor==0x0010) && (desc.idProduct==0x1010)) //si la tourelle est trouvee parmis les peripheriques USB, on lance sa configuration | 138 | + |
139 | + //Lorsque l'on retrouves notre périphérique nous passons à la configuration. | ||
140 | + if ((desc.idVendor==0x0010) && (desc.idProduct==0x1010)) | ||
164 | { | 141 | { |
165 | - printf("Tourelle trouvée !\n"); | 142 | + printf("périphérique trouvée !\n"); |
166 | t=1; | 143 | t=1; |
167 | configuration_periph(device); | 144 | configuration_periph(device); |
168 | } | 145 | } |
169 | } | 146 | } |
170 | - if(t==0) printf("Tourelle non connectée !\n"); | 147 | + if(t==0) printf("périphérique non connectée !\n"); |
171 | } | 148 | } |
149 | + | ||
150 | + | ||
172 | 151 | ||
173 | 152 | ||
174 | -void tir(libusb_device_handle *handle) //On fait appel à cette fonction quand on désire tirer dans la fonction commande | 153 | +void envoie(unsigned char c) |
175 | { | 154 | { |
176 | - unsigned char tab[13]; | ||
177 | - struct libusb_transfer *transf; | ||
178 | - | ||
179 | - //1ère requête | ||
180 | - transf = libusb_alloc_transfer(0); | ||
181 | - libusb_fill_control_setup(tab, 0x21, 0x09, 0x300, 0x00, 13); | ||
182 | - tab[12] = 0x5e; | ||
183 | - tab[11] = 0x00; | ||
184 | - tab[10] = 0x00; | ||
185 | - tab[8] = 0x00; | ||
186 | - tab[9] = 0x00; | ||
187 | - | ||
188 | - //Structure de transfert | ||
189 | - libusb_fill_control_transfer(transf, handle, tab, callback, NULL, 0); | ||
190 | - //Envoi sur le port serie | ||
191 | - libusb_submit_transfer(transf); | ||
192 | - | ||
193 | - //2ème requête | ||
194 | - transf = libusb_alloc_transfer(0); | ||
195 | - libusb_fill_control_setup(tab, 0x21, 0x09, 0x300, 0x00, 13); | ||
196 | - tab[12] = 0x5c; | ||
197 | - tab[11] = 0x00; | ||
198 | - tab[10] = 0x00; | ||
199 | - tab[8] = 0x00; | ||
200 | - tab[9] = 0x00; | ||
201 | - | ||
202 | - //Structure de transfert | ||
203 | - libusb_fill_control_transfer(transf, handle, tab, callback, NULL, 0); | ||
204 | - //Envoi sur le port serie | ||
205 | - libusb_submit_transfer(transf); | ||
206 | - | ||
207 | - //Tir | ||
208 | - transf = libusb_alloc_transfer(0); | ||
209 | - libusb_fill_control_setup(tab, 0x21, 0x09, 0x300, 0x00, 13); | ||
210 | - tab[12] = 0xfe; | ||
211 | - tab[11] = 0xff; | ||
212 | - tab[10] = 0xe0; | ||
213 | - tab[8] = 0x5f; | ||
214 | - tab[9] = 0x10; | ||
215 | - | ||
216 | - //Structure de transfert | ||
217 | - libusb_fill_control_transfer(transf, handle, tab, callback, NULL, 0); | ||
218 | - //Envoi sur le port serie | ||
219 | - libusb_submit_transfer(transf); | 155 | + /* To send a char to the device simply initiate a bulk_transfer to the |
156 | + * Endpoint with address ep_out_addr. | ||
157 | + */ | ||
158 | + int actual_length; | ||
159 | + if (libusb_bulk_transfer(handle, ep_out_addr, &c, 1, | ||
160 | + &actual_length, 0) < 0) { | ||
161 | + fprintf(stderr, "Error while sending char\n"); | ||
162 | + } | ||
220 | } | 163 | } |
221 | 164 | ||
222 | - | ||
223 | -void commande(char action, libusb_device_handle *handle) //Cette fonction permet de commander les déplacements et tirs de la tourelle | 165 | +int reception(unsigned char * data, int size) |
224 | { | 166 | { |
225 | - char cmd; | ||
226 | - | ||
227 | - //Declaration de la structure d'envoi pour les données de la requette | ||
228 | - struct libusb_transfer *transf; | ||
229 | - unsigned char tab[13]; | ||
230 | - transf = libusb_alloc_transfer(0); | ||
231 | - | ||
232 | - //Paramètres des requêtes | ||
233 | - libusb_fill_control_setup(tab, 0x21, 0x09, 0x300, 0x00, 13); | ||
234 | - | ||
235 | - switch(action) | ||
236 | - { | ||
237 | - case 'g': //déplacement à gauche | ||
238 | - cmd=0x04; | ||
239 | - break; | ||
240 | - case 'd': //déplacement à droite | ||
241 | - cmd=0x08; | ||
242 | - break; | ||
243 | - case 'h': //déplacement en haut | ||
244 | - cmd=0x02; | ||
245 | - break; | ||
246 | - case 'b': //déplacement en bas | ||
247 | - cmd=0x01; | ||
248 | - break; | ||
249 | - case 'a': //arrêt | ||
250 | - cmd=0x00; | ||
251 | - break; | ||
252 | - case 't': //tir | ||
253 | - cmd=0x10; | ||
254 | - break; | ||
255 | - default : | ||
256 | - printf("Commande invalide\n"); | ||
257 | - break; | 167 | + /* To receive characters from the device initiate a bulk_transfer to the |
168 | + * Endpoint with address ep_in_addr. | ||
169 | + */ | ||
170 | + int actual_length; | ||
171 | + int status = libusb_bulk_transfer(handle, ep_in_addr, data, size, &actual_length, | ||
172 | + 1000); | ||
173 | + if (status == LIBUSB_ERROR_TIMEOUT) { | ||
174 | + printf("timeout (%d)\n", actual_length); | ||
175 | + return -1; | ||
176 | + } else if (status < 0) { | ||
177 | + fprintf(stderr, "Error while waiting for char\n"); | ||
178 | + return -1; | ||
258 | } | 179 | } |
259 | 180 | ||
260 | - if(cmd==0x10)//Si l'on veut tirer | ||
261 | - { | ||
262 | - tir(handle); //Les requêtes sont différentes pour la commande de tir (voir la fonction dédiée) | ||
263 | - } | ||
264 | - else | ||
265 | - { | ||
266 | - //Données de la requette à envoyer à la tourelle pour les mouvements. tab[9] correspond à l'action à effectuer (gauche, droite, haut, bas ou arrêt) | ||
267 | - tab[12] = 0xfe; | ||
268 | - tab[11] = 0xff; | ||
269 | - tab[10] = 0xe0; | ||
270 | - tab[8] = 0x5f; | ||
271 | - tab[9] = cmd; | ||
272 | - | ||
273 | - //Structure de transfert | ||
274 | - libusb_fill_control_transfer(transf, handle, tab, callback, NULL, 0); | ||
275 | - //Envoi sur le port serie | ||
276 | - libusb_submit_transfer(transf); | ||
277 | - } | 181 | + return actual_length; |
278 | } | 182 | } |
279 | - | ||
280 | - | 183 | + |
184 | + | ||
185 | + | ||
281 | int main() | 186 | int main() |
282 | { | 187 | { |
283 | //Initialisation de la bibliotheque libusb | 188 | //Initialisation de la bibliotheque libusb |
284 | libusb_context *context; | 189 | libusb_context *context; |
190 | + unsigned char * buf; | ||
191 | + int len; | ||
285 | 192 | ||
286 | int status=libusb_init(&context); | 193 | int status=libusb_init(&context); |
287 | if(status!=0) | 194 | if(status!=0) |
@@ -289,78 +196,69 @@ int main() | @@ -289,78 +196,69 @@ int main() | ||
289 | perror("libusb_init"); exit(-1); | 196 | perror("libusb_init"); exit(-1); |
290 | } | 197 | } |
291 | 198 | ||
292 | - enumeration(context); //Enumération des périphériques USB. Si la tourelle est trouvée, cette fonction fait appel à la fonction configuration_periph qui va configurer la tourelle. | 199 | +//Enumération des périphériques USB. Si le périphérique est trouvé, cette fonction fait appel à la fonction configuration_perip. |
200 | + enumeration(context); | ||
293 | 201 | ||
294 | - //Initialisation du port serie | ||
295 | - char *device="/dev/ttyACM0"; | ||
296 | - int fd=init_serial(device,B9600); //Vitesse 9600 bauds | ||
297 | - printf("port init\n"); | 202 | +//configuration du périphérique |
203 | + status = libusb_control_transfer(handle, 0x21, 0x22, ACM_CTRL_DTR | ACM_CTRL_RTS, | ||
204 | + 0, NULL, 0, 0); | ||
205 | + if (status < 0) { | ||
206 | + fprintf(stderr, "Error during control transfer: %s\n", | ||
207 | + libusb_error_name(status)); | ||
208 | +} | ||
298 | 209 | ||
299 | 210 | ||
300 | -//close_serial(fd); | ||
301 | - //Menu de commande | ||
302 | - char action, choix; | ||
303 | - printf("\nPilotage de la tourelle\n"); | ||
304 | - printf("------------------------\n"); | ||
305 | - printf("Taper 0 pour piloter la tourelle au clavier ou 1 pour la piloter avec l'arduino : "); | ||
306 | - scanf("%c",&choix); | 211 | +/* - set line encoding: here 9600 8N1 |
212 | + * 9600 = 0x2580 ~> 0x80, 0x25 in little endian | ||
213 | + */ | ||
214 | + //Configuration du port série. | ||
215 | + unsigned char encoding[] = { 0x80, 0x25, 0x00, 0x00, 0x00, 0x00, 0x08 }; | ||
216 | + status = libusb_control_transfer(handle, 0x21, 0x20, 0, 0, encoding, | ||
217 | + sizeof(encoding), 0); | ||
218 | + if (status < 0) { | ||
219 | + fprintf(stderr, "Error during control transfer: %s\n", | ||
220 | + libusb_error_name(status)); | ||
221 | + } | ||
307 | 222 | ||
308 | - if(choix=='0') | ||
309 | - { | ||
310 | - printf("\nPilotage au clavier\n"); | ||
311 | - printf("Taper d pour droite, g pour gauche, h pour haut, b pour bas, t pour tirer, s pour sortir du programme :\n"); | ||
312 | - } | ||
313 | - if(choix=='1') | ||
314 | - { | ||
315 | - printf("\nPilotage avec l'arduino\n"); | ||
316 | - printf("Pour diriger la tourelle, utiliser le joystick, pour tirer appuyer dessus et pour sortir du programme appuyer sur D3.\n"); | ||
317 | - } | 223 | + |
318 | 224 | ||
319 | - for(;;) //Boucle d'éxécution | 225 | + //Menu de commande |
226 | + char action; | ||
227 | + for(;;) | ||
320 | { | 228 | { |
321 | - if(choix=='0') //Pilotage au clavier | ||
322 | - { | ||
323 | - while(getchar() != '\n'); | ||
324 | - scanf("%c",&action); | ||
325 | - switch (action) | 229 | + |
230 | + printf("s=fermer / d=allumer led / g=eteindre led / h=moteur gauche / b=moteur droit / t=moteur éteint \n"); | ||
231 | + scanf("%c",&action); | ||
232 | + | ||
233 | + switch (action) | ||
326 | { | 234 | { |
327 | case 's': | 235 | case 's': |
328 | fermeture(handle); | 236 | fermeture(handle); |
329 | - close_serial(fd); | ||
330 | libusb_free_device_list(list,1); | 237 | libusb_free_device_list(list,1); |
331 | libusb_exit(context); | 238 | libusb_exit(context); |
332 | return 0; | 239 | return 0; |
333 | break; | 240 | break; |
334 | case 'd': | 241 | case 'd': |
335 | - commande(action, handle); | 242 | + envoie(LED_ON); |
336 | sleep(1); | 243 | sleep(1); |
337 | - commande('a',handle); | 244 | + //len = read_chars(buf, 1); |
245 | + | ||
338 | break; | 246 | break; |
339 | case 'g': | 247 | case 'g': |
340 | - commande(action, handle); | 248 | + envoie(LED_OFF); |
341 | sleep(1); | 249 | sleep(1); |
342 | - commande('a',handle); | ||
343 | break; | 250 | break; |
344 | case 'h': | 251 | case 'h': |
345 | - commande(action, handle); | ||
346 | - sleep(1); | ||
347 | - commande('a',handle); | 252 | + envoie(MOVE_LEFT); |
253 | + sleep(1); | ||
348 | break; | 254 | break; |
349 | case 'b': | 255 | case 'b': |
350 | - commande(action, handle); | ||
351 | - sleep(1); | ||
352 | - commande('a',handle); | 256 | + envoie(MOVE_RIGHT); |
257 | + sleep(1); | ||
353 | break; | 258 | break; |
354 | case 't' : | 259 | case 't' : |
355 | - commande(action, handle); | ||
356 | - sleep(1); | ||
357 | - commande('a',handle); | ||
358 | - commande(action, handle); | ||
359 | - sleep(1); | ||
360 | - commande('a',handle); | ||
361 | - commande(action, handle); | ||
362 | - sleep(1); | ||
363 | - commande('a',handle); | 260 | + envoie(MOVE_STOP); |
261 | + sleep(1); | ||
364 | break; | 262 | break; |
365 | default : | 263 | default : |
366 | printf("Commande invalide ! Retaper :\n"); | 264 | printf("Commande invalide ! Retaper :\n"); |
@@ -368,36 +266,6 @@ int main() | @@ -368,36 +266,6 @@ int main() | ||
368 | } | 266 | } |
369 | } | 267 | } |
370 | 268 | ||
371 | - if(choix=='1') //Pilotage avec l'arduino | ||
372 | - { | ||
373 | - read(fd,&action,1); //On lit sur le port série | ||
374 | - printf("%c\n",action); | ||
375 | - write(fd,"o",1); //On envoie le caractère 'o' sur le port série en réponse | ||
376 | - commande(action,handle); //Permet de déplacer la tourelle ou d'arreter ses mouvements selon le caractère reçu (d,g,b,h ou a) | ||
377 | - if(action=='t') //Si l'on reçoit l'ordre de tirer | ||
378 | - { | ||
379 | - commande(action, handle); | ||
380 | - sleep(1); | ||
381 | - commande('a',handle); | ||
382 | - commande(action, handle); | ||
383 | - sleep(1); | ||
384 | - commande('a',handle); | ||
385 | - commande(action, handle); | ||
386 | - sleep(1); | ||
387 | - commande('a',handle); | ||
388 | - } | ||
389 | - if(action=='s') //Si l'on reçoit le caractère 's' on ferme le programme | ||
390 | - { | ||
391 | - fermeture(handle); | ||
392 | - close_serial(fd); | ||
393 | - libusb_free_device_list(list,1); | ||
394 | - libusb_exit(context); | ||
395 | - return 0; | ||
396 | - } | ||
397 | - | ||
398 | - } | ||
399 | - | ||
400 | - } | ||
401 | 269 | ||
402 | return 0; | 270 | return 0; |
403 | } | 271 | } |
gadget/Descriptors.c
@@ -54,8 +54,8 @@ const USB_Descriptor_Device_t PROGMEM DeviceDescriptor = | @@ -54,8 +54,8 @@ const USB_Descriptor_Device_t PROGMEM DeviceDescriptor = | ||
54 | 54 | ||
55 | .Endpoint0Size = FIXED_CONTROL_ENDPOINT_SIZE, | 55 | .Endpoint0Size = FIXED_CONTROL_ENDPOINT_SIZE, |
56 | 56 | ||
57 | - .VendorID = 0x03EB, | ||
58 | - .ProductID = 0x204B, | 57 | + .VendorID = 0x0010, |
58 | + .ProductID = 0x1010, | ||
59 | .ReleaseNumber = VERSION_BCD(0,0,1), | 59 | .ReleaseNumber = VERSION_BCD(0,0,1), |
60 | 60 | ||
61 | .ManufacturerStrIndex = STRING_ID_Manufacturer, | 61 | .ManufacturerStrIndex = STRING_ID_Manufacturer, |
@@ -191,7 +191,7 @@ const USB_Descriptor_String_t PROGMEM ManufacturerString = USB_STRING_DESCRIPTOR | @@ -191,7 +191,7 @@ const USB_Descriptor_String_t PROGMEM ManufacturerString = USB_STRING_DESCRIPTOR | ||
191 | * and is read out upon request by the host when the appropriate string ID is requested, listed in the Device | 191 | * and is read out upon request by the host when the appropriate string ID is requested, listed in the Device |
192 | * Descriptor. | 192 | * Descriptor. |
193 | */ | 193 | */ |
194 | -const USB_Descriptor_String_t PROGMEM ProductString = USB_STRING_DESCRIPTOR(L"USB Gadget"); | 194 | +const USB_Descriptor_String_t PROGMEM ProductString = USB_STRING_DESCRIPTOR(L"LUFA USB-RS232 Adapter"); |
195 | 195 | ||
196 | /** This function is called by the library when in device mode, and must be overridden (see library "USB Descriptors" | 196 | /** This function is called by the library when in device mode, and must be overridden (see library "USB Descriptors" |
197 | * documentation) by the application code so that the address and size of a requested descriptor can be given | 197 | * documentation) by the application code so that the address and size of a requested descriptor can be given |