Monitoring du Phytotron
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

t.c 1.1KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051
  1. /*
  2. * Experiments with the serial input
  3. * ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  4. */
  5. #include <stdio.h>
  6. #include <stdlib.h>
  7. #include <strings.h>
  8. #include <ctype.h>
  9. #include <time.h>
  10. #include <unistd.h> //Used for UART
  11. #include <fcntl.h> //Used for UART
  12. #include <errno.h>
  13. #include <termios.h> //Used for UART
  14. #include "serial.h"
  15. int verbosity;
  16. /* ---------------------------------------------------------------- */
  17. /* ---------------------------------------------------------------- */
  18. int main (int argc, char *argv[])
  19. {
  20. int serial_in, foo, count;
  21. char ligne[200];
  22. if (2 != argc) {
  23. fprintf(stderr, "give me a device name, please.\n");
  24. return 2;
  25. }
  26. serial_in = prepare_UART(argv[1], 9600);
  27. fprintf(stderr, "going to listen on %d\n", serial_in);
  28. for (count=0; count<10000; count++) {
  29. foo = getline_to(serial_in, ligne, 100, 0);
  30. fprintf(stderr, "getline #%d -> %d\n", count, foo);
  31. fprintf(stderr, "%s\n", ligne);
  32. foo = parseXvalue(ligne);
  33. fprintf(stderr, "parse -> %d\n", foo);
  34. if (foo>= 0) {
  35. printf("%d %d\n", count, foo);
  36. fflush(stdout);
  37. }
  38. }
  39. return 0;
  40. }
  41. /* ---------------------------------------------------------------- */