Skip to content
Extraits de code Groupes Projets
Valider 389fbea2 rédigé par Diego de Bernard de Fauconval's avatar Diego de Bernard de Fauconval
Parcourir les fichiers

can ok

parent 661aee76
Aucune branche associée trouvée
Aucune étiquette associée trouvée
Aucune requête de fusion associée trouvée
spi 0 → 100755
Fichier ajouté
......@@ -2,6 +2,7 @@
#include <stdio.h>
#include <string.h>
#include <unistd.h>
#include <time.h>
#include <net/if.h>
#include <sys/socket.h>
......@@ -38,33 +39,25 @@ int main(int argc, char const *argv[])
}
frame.can_id = 0x708;
frame.can_dlc = 2;
frame.data[0] = 0xff;
frame.data[1] = 0xff; // 0b0100 0000
frame.can_dlc = 3;
frame.data[0] = 0x1c + 0x02;
frame.data[1] = 0x40; // 0b0100 0000
frame.data[2] = 0x40;
if (write(fd, &frame, sizeof(struct can_frame)) != sizeof(struct can_frame)) {
perror("error write");
exit(EXIT_FAILURE);
}
// int nbytes;
// struct can_frame readframe;
/* Laisse la LED allumée pendant 5 s avant de l'éteindre */
sleep(5);
// readframe.can_id = 0x700;
// nbytes = read(fd, &readframe, sizeof(struct can_frame));
// if (nbytes < 0) {
// perror("reading");
// exit(EXIT_FAILURE);
// }
frame.data[2] = 0x00;
if (write(fd, &frame, sizeof(struct can_frame)) != sizeof(struct can_frame)) {
perror("error write");
exit(EXIT_FAILURE);
}
// printf("0x%x [%d]\n", readframe.can_id, readframe.can_dlc);
// for (int i = 0; i < frame.can_dlc; i++)
// {
// printf("0x\n", readframe.data[i]);
// }
return 0;
......
0% Chargement en cours ou .
You are about to add 0 people to the discussion. Proceed with caution.
Terminez d'abord l'édition de ce message.
Veuillez vous inscrire ou vous pour commenter