chiark / gitweb /
allow stdin; opposite polarity
authorian <ian>
Thu, 12 Aug 2004 18:27:54 +0000 (18:27 +0000)
committerian <ian>
Thu, 12 Aug 2004 18:27:54 +0000 (18:27 +0000)
parport/train-pic-prog-select.c

index c10229a820df2ffcbaa1b123f6706c794b92da7f..f443deb96fa4180ae9f8c91c07706732ffa84aa0 100644 (file)
@@ -79,15 +79,19 @@ int main(int argc, const char *const *argv) {
       if (ep==arg) badusage("syntactically incorrect range");
     }
     if (*ep) badusage("syntactically incorrect picno or range");
-    if (first<0 || last>COLUMNS*ROWS-1 || first<last)
+    if (first<0 || last>COLUMNS*ROWS-1 || first>last)
       badusage("picno or range out of permissible range");
     for (; first<=last; first++) {
       if (yesses.lin[first]) badusage("one pic specified more than once");
       yesses.lin[first]= 1;
     }
   }
-  fd= open(parport, O_RDWR);
-  if (fd<0) { perror(parport); exit(-1); }
+  if (!strcmp(parport,"stdin")) {
+    fd= 0;
+  } else {
+    fd= open(parport, O_RDWR);
+    if (fd<0) { perror(parport); exit(-1); }
+  }
 
   setvbuf(stdout,0,_IONBF,0);
   
@@ -97,7 +101,7 @@ int main(int argc, const char *const *argv) {
   for (row=0; row<ROWS; row++) {
     v= 0;
     for (col=0; col<COLUMNS; col++)
-      v |= yesses.rect[col][row] ? (1<<col) : 0;
+      v |= yesses.rect[col][row] ? 0 : (1<<col);
     wpause(PPWDATA, v | 0x80);
     wpause(PPWDATA, v); /* SEL_CLK  ~|_  shifts */
   }