failomaton
Différences
Ci-dessous, les différences entre deux révisions de la page.
Les deux révisions précédentesRévision précédenteProchaine révision | Révision précédente | ||
failomaton [2024/04/05 19:36] – [Reconnaissance de la clef] Mushussu | failomaton [2024/05/18 13:09] (Version actuelle) – [Caméra] Mushussu | ||
---|---|---|---|
Ligne 306: | Ligne 306: | ||
==== Code C pour la Raspberry Pi ==== | ==== Code C pour la Raspberry Pi ==== | ||
<code c> | <code c> | ||
- | // gcc -Wall -o test test.c -lwiringPi | + | // g++ -Wall -o test `cups-config --cflags` |
#include < | #include < | ||
Ligne 318: | Ligne 318: | ||
#include < | #include < | ||
#include < | #include < | ||
+ | #include < | ||
+ | |||
+ | #include < | ||
+ | #include < | ||
+ | |||
+ | #define boutonPhoto 26 // Fil rouge | ||
+ | #define vibrationArduino 27 // Fil vert | ||
+ | #define declenchementArduino 28 // Fil jaune | ||
+ | #define monnayeur 29 // Fil blanc | ||
- | #define declenchementArduino 16 | ||
- | #define vibrationArduino 7 | ||
int nbPhotos = 0; | int nbPhotos = 0; | ||
time_t compteurTemps; | time_t compteurTemps; | ||
Ligne 326: | Ligne 333: | ||
static pid_t pidProcedure = 0; | static pid_t pidProcedure = 0; | ||
static pid_t pidPhoto = 0; | static pid_t pidPhoto = 0; | ||
+ | static pid_t pidAssistance = 0; | ||
+ | |||
int attente = 0; | int attente = 0; | ||
int procedure = 0; | int procedure = 0; | ||
Ligne 339: | Ligne 348: | ||
s[j] = c; | s[j] = c; | ||
} | } | ||
- | } | + | } |
void itoa(int n, char s[]) | void itoa(int n, char s[]) | ||
{ | { | ||
Ligne 354: | Ligne 364: | ||
s[i] = ' | s[i] = ' | ||
| | ||
- | } | + | } |
void photo() { | void photo() { | ||
Ligne 367: | Ligne 377: | ||
if((pidProcedure = fork()) == 0) | if((pidProcedure = fork()) == 0) | ||
{ | { | ||
- | execl("/ | + | execl("/ |
- | "/ | + | "/ |
- | " | + | " |
- | " | + | " |
- | "/home/pi/ | + | "/media/usb/ |
- | NULL); | + | NULL); |
} | } | ||
sleep(13); | sleep(13); | ||
Ligne 383: | Ligne 393: | ||
if((pidPhoto = fork()) == 0) | if((pidPhoto = fork()) == 0) | ||
{ | { | ||
- | execl("/ | + | execl("/ |
- | "/ | + | "/ |
- | " | + | " |
- | " | + | " |
- | "/home/pi/ | + | "/media/usb/ |
- | NULL); | + | NULL); |
} | } | ||
sleep(5); | sleep(5); | ||
char buffer [6]; | char buffer [6]; | ||
itoa(nbPhotos, | itoa(nbPhotos, | ||
- | char src[40] = "/home/pi/ | + | char src[40] = "/media/usb/ |
strcat(src, buffer); | strcat(src, buffer); | ||
strcat(src, " | strcat(src, " | ||
Ligne 401: | Ligne 411: | ||
static pid_t pid = 0; | static pid_t pid = 0; | ||
if ((pid = fork()) == 0) | if ((pid = fork()) == 0) | ||
- | { | + | { |
// libcamera-jpeg -o photo_0.jpg -c config.txt | // libcamera-jpeg -o photo_0.jpg -c config.txt | ||
- | execl("/ | + | execl("/ |
- | "", | + | "", |
- | " | + | " |
- | " | + | " |
+ | " | ||
NULL); | NULL); | ||
} | } | ||
Ligne 419: | Ligne 430: | ||
static pid_t pid1 = 0; | static pid_t pid1 = 0; | ||
if ((pid1 = fork()) == 0) | if ((pid1 = fork()) == 0) | ||
- | { | + | { |
// convert -crop 3836x2592+386+0 -rotate -90 Photos/ | // convert -crop 3836x2592+386+0 -rotate -90 Photos/ | ||
execl( | execl( | ||
- | "/ | + | "/ |
- | "", | + | "", |
- | " | + | " |
- | " | + | " |
- | " | + | " |
- | src, src, | + | src, src, |
NULL); | NULL); | ||
} | } | ||
sleep(2); | sleep(2); | ||
+ | //const char *filename = " | ||
- | | + | |
- | | + | http_t *http; |
- | { | + | |
- | | + | |
- | | + | static const char * const requested_attributes[] |
- | "", | + | { |
- | "-d", | + | |
- | "Canon_SELPHY_CP1300", | + | "job-template", |
- | src, | + | |
- | NULL); | + | }; |
- | | + | http = httpConnect2("localhost", |
- | + | ||
- | sleep(12); | + | request = ippNewRequest(IPP_OP_PRINT_JOB); |
+ | ippAddString(request, | ||
+ | | ||
+ | | ||
+ | | ||
+ | | ||
+ | sleep(17); | ||
kill(pidPhoto, | kill(pidPhoto, | ||
+ | |||
+ | // Test si il manque du papier | ||
+ | ipp_attribute_t *attr; | ||
+ | char value[2048]; | ||
+ | // Procedure | ||
+ | uint8_t erreur; | ||
+ | uint8_t assistance = 0; | ||
+ | do { | ||
+ | erreur = 0; | ||
+ | request = ippNewRequest(IPP_OP_GET_PRINTER_ATTRIBUTES); | ||
+ | ippAddString(request, | ||
+ | ippAddString(request, | ||
+ | ippAddStrings(request, | ||
+ | |||
+ | response = cupsDoRequest(http, | ||
+ | for (attr = ippFirstAttribute(response); | ||
+ | { | ||
+ | if (strcmp(ippGetName(attr), | ||
+ | { | ||
+ | ippAttributeString(attr, | ||
+ | std::string valeur(value); | ||
+ | std::size_t erreurCartouche = valeur.find(" | ||
+ | std::size_t erreurPapier = valeur.find(" | ||
+ | if (erreurCartouche <= 2048) | ||
+ | { | ||
+ | // Plus d' | ||
+ | erreur = 1; | ||
+ | if (assistance == 0) { | ||
+ | printf(" | ||
+ | |||
+ | assistance = 1; | ||
+ | if((pidAssistance = fork()) == 0) | ||
+ | { | ||
+ | execl("/ | ||
+ | "/ | ||
+ | " | ||
+ | " | ||
+ | "/ | ||
+ | NULL); | ||
+ | } | ||
+ | } | ||
+ | } | ||
+ | if (erreurPapier <= 2048) | ||
+ | { | ||
+ | // Plus de papier | ||
+ | erreur = 2; | ||
+ | if (assistance == 0) { | ||
+ | printf(" | ||
+ | |||
+ | assistance = 1; | ||
+ | |||
+ | if((pidAssistance = fork()) == 0) | ||
+ | { | ||
+ | execl("/ | ||
+ | "/ | ||
+ | " | ||
+ | " | ||
+ | "/ | ||
+ | NULL); | ||
+ | } | ||
+ | } | ||
+ | } | ||
+ | } | ||
+ | } | ||
+ | sleep(3); | ||
+ | } while (erreur != 0); | ||
+ | |||
+ | if (assistance != 0) { | ||
+ | kill(pidAssistance, | ||
+ | } | ||
printf(" | printf(" | ||
procedure = 0; | procedure = 0; | ||
Ligne 456: | Ligne 544: | ||
{ | { | ||
wiringPiSetup(); | wiringPiSetup(); | ||
- | pinMode (15, INPUT); // Pin de l' | + | pinMode (boutonPhoto, INPUT); // Pin de l' |
- | pullUpDnControl(15, PUD_UP); | + | pullUpDnControl(boutonPhoto, PUD_UP); |
- | // wiringPiISR (15, INT_EDGE_FALLING, | + | pinMode (monnayeur, INPUT); // Pin du monnayeur |
- | // | + | pullUpDnControl(monnayeur, PUD_UP); |
- | // | + | |
- | // | + | // |
- | // | + | |
pinMode (declenchementArduino, | pinMode (declenchementArduino, | ||
pinMode (vibrationArduino, | pinMode (vibrationArduino, | ||
compteurTemps = time(NULL); | compteurTemps = time(NULL); | ||
+ | |||
// Comptage des fichiers | // Comptage des fichiers | ||
struct dirent *dir; | struct dirent *dir; | ||
- | DIR *d = opendir("/ | + | DIR *d = opendir("/ |
if (d) | if (d) | ||
{ | { | ||
- | while ((dir = readdir(d)) != NULL) | + | while ((dir = readdir(d)) != NULL) |
{ | { | ||
if (dir-> | if (dir-> | ||
Ligne 482: | Ligne 570: | ||
} | } | ||
// Efface tous les travaux d' | // Efface tous les travaux d' | ||
- | system(" | + | system(" |
- | ; | + | |
while(1) { | while(1) { | ||
if (attente == 0) | if (attente == 0) | ||
Ligne 489: | Ligne 576: | ||
attente = 1; | attente = 1; | ||
printf(" | printf(" | ||
+ | // Message d' | ||
if ((pidAttente = fork()) == 0) | if ((pidAttente = fork()) == 0) | ||
{ | { | ||
- | execl("/ | + | execl("/ |
- | "/ | + | "/ |
- | " | + | " |
- | " | + | " |
- | "/home/pi/ | + | "/media/usb/ |
- | NULL); | + | NULL); |
} | } | ||
} | } | ||
- | if ((digitalRead(15) == 0) && (attente == 1)) { | + | if ((digitalRead(monnayeur) == 0) && (attente |
+ | | ||
+ | } | ||
+ | if ((digitalRead(boutonPhoto) == 0) && (attente == 1) && | ||
| | ||
} | } | ||
Ligne 617: | Ligne 708: | ||
[[https:// | [[https:// | ||
+ | |||
+ | [[https:// | ||
+ | |||
+ | [[https:// | ||
+ | |||
+ | [[https:// | ||
+ | |||
+ | [[https:// | ||
==== Synthèse vocale en ligne ==== | ==== Synthèse vocale en ligne ==== | ||
[[https:// | [[https:// |
failomaton.1712345818.txt.gz · Dernière modification : 2024/04/05 19:36 de Mushussu