1
0
Fork 0
mirror of https://github.com/RobotechLille/cdf2018-principal synced 2024-05-21 14:16:22 +02:00
cdf2018-principal/chef/src/testpin.c
2018-02-07 17:57:01 +01:00

33 lines
614 B
C

/* Teste si une broche est connecté à une autre */
#include <stdlib.h>
#include <stdio.h>
#include <wiringPi.h>
char testPin(char input, char output) {
pinMode(output, OUTPUT);
pinMode(input, INPUT);
digitalWrite(output, 1);
delay(0);
return digitalRead(input);
}
int main(int argc, char *argv[]) {
if (argc != 3) {
printf("Usage: %s INPUT_PIN OUTPUT_PIN\n", argv[0]);
return 2;
}
if (wiringPiSetup() == -1) {
return 3;
}
char input = atoi(argv[1]);
char output = atoi(argv[2]);
char rep = testPin(input, output);
return rep;
}