Advertisement
Guest User

Untitled

a guest
Sep 18th, 2014
271
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.33 KB | None | 0 0
  1. <?php
  2. ob_implicit_flush(true);
  3. $cmd = "/home/pi/projects/PingPongSet/enroll";
  4.  
  5. $descriptorspec = array(
  6. 0 => array("pipe", "r"), // stdin is a pipe that the child will read from
  7. 1 => array("pipe", "w"), // stdout is a pipe that the child will write to
  8. 2 => array("pipe", "w") // stderr is a pipe that the child will write to
  9. );
  10. flush();
  11. $process = proc_open($cmd, $descriptorspec, $pipes);
  12. echo 'opened'."n";
  13. if (is_resource($process)) {
  14. sleep(1);
  15. echo "blahn";
  16. var_export(fgets($pipes[1]));
  17. echo "blah213n";
  18. while ($s = fgets($pipes[1])) {
  19. print $s;
  20. flush();
  21. }
  22. }
  23.  
  24. struct fp_print_data *enroll(struct fp_dev *dev) {
  25. struct fp_print_data *enrolled_print = NULL;
  26. int r;
  27.  
  28. do {
  29. struct fp_img *img = NULL;
  30.  
  31. sleep(1);
  32. printf("nScan your finger now.n");
  33.  
  34. r = fp_enroll_finger_img(dev, &enrolled_print, &img);
  35. printf("nFinger scanned.n");
  36. if (img) {
  37. fp_img_save_to_file(img, "enrolled.pgm");
  38. printf("Wrote scanned image to enrolled.pgmn");
  39. fp_img_free(img);
  40. }
  41. if (r < 0) {
  42. printf("Enroll failed with error %dn", r);
  43. play_error();
  44. return NULL;
  45. }
  46.  
  47. switch (r) {
  48. case FP_ENROLL_COMPLETE:
  49. printf("Enroll complete!n");
  50. break;
  51. case FP_ENROLL_FAIL:
  52. printf("Enroll failed, something wen't wrong :(n");
  53. play_error();
  54. return NULL;
  55. case FP_ENROLL_PASS:
  56. printf("Enroll stage passed. Yay!n");
  57. play_success();
  58. break;
  59. case FP_ENROLL_RETRY:
  60. printf("Didn't quite catch that. Please try again.n");
  61. play_error();
  62. break;
  63. case FP_ENROLL_RETRY_TOO_SHORT:
  64. printf("Your swipe was too short, please try again.n");
  65. play_error();
  66. break;
  67. case FP_ENROLL_RETRY_CENTER_FINGER:
  68. printf("Didn't catch that, please center your finger on the "
  69. "sensor and try again.n");
  70. play_error();
  71. break;
  72. case FP_ENROLL_RETRY_REMOVE_FINGER:
  73. printf("Scan failed, please remove your finger and then try "
  74. "again.n");
  75. play_error();
  76. break;
  77. }
  78. } while (r != FP_ENROLL_COMPLETE);
  79.  
  80. if (!enrolled_print) {
  81. fprintf(stderr, "Enroll complete but no print?n");
  82. return NULL;
  83. }
  84.  
  85. printf("Enrollment completed!nn");
  86. play_success();
  87. return enrolled_print;
  88. }
  89.  
  90. opened
  91. blah
  92. -----NOTE: THE STUFF BELOW HERE DOESN'T DISPLAY UNTIL AFTER enroll TERMINATES-----
  93. 'Found device claimed by Digital Persona U.are.U 4000/4000B/4500 driver
  94. 'blah213
  95. Opened device. It's now time to enroll your finger.
  96.  
  97.  
  98. Scan your finger now.
  99. uru4000:info [init_run_state] Versions 0040 and 0014
  100.  
  101. Finger scanned.
  102. Wrote scanned image to enrolled.pgm
  103. Enroll stage passed. Yay!
  104.  
  105. Scan your finger now.
  106.  
  107. Finger scanned.
  108. Wrote scanned image to enrolled.pgm
  109. Enroll stage passed. Yay!
  110.  
  111. Scan your finger now.
  112.  
  113. Finger scanned.
  114. Wrote scanned image to enrolled.pgm
  115. Enroll stage passed. Yay!
  116.  
  117. Scan your finger now.
  118.  
  119. Finger scanned.
  120. Wrote scanned image to enrolled.pgm
  121. Enroll stage passed. Yay!
  122.  
  123. Scan your finger now.
  124.  
  125. Finger scanned.
  126. Wrote scanned image to enrolled.pgm
  127. Enroll complete!
  128. Enrollment completed!
  129.  
  130. Closing device
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement