uconsole.c (1262B)
1 /* uconsole.c 2 * 3 * Copyright 2011 Brian Swetland <swetland@frotz.net> 4 * 5 * Licensed under the Apache License, Version 2.0 (the "License"); 6 * you may not use this file except in compliance with the License. 7 * You may obtain a copy of the License at 8 * 9 * http://www.apache.org/licenses/LICENSE-2.0 10 * 11 * Unless required by applicable law or agreed to in writing, software 12 * distributed under the License is distributed on an "AS IS" BASIS, 13 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 * See the License for the specific language governing permissions and 15 * limitations under the License. 16 */ 17 18 #include <stdio.h> 19 #include <stdlib.h> 20 #include <unistd.h> 21 #include <string.h> 22 #include <fcntl.h> 23 #include <stdint.h> 24 25 #include "usb.h" 26 27 int main(int argc, char **argv) { 28 int r, once; 29 usb_handle *usb; 30 char buf[64]; 31 32 once = 1; 33 for (;;) { 34 usb = usb_open(0x18d1, 0xdb05, 0); 35 if (usb == 0) { 36 usb = usb_open(0x18d1, 0xdb04, 1); 37 } 38 if (usb == 0) { 39 if (once) { 40 fprintf(stderr,"waiting for device...\n"); 41 once = 0; 42 } 43 } else { 44 break; 45 } 46 } 47 48 fprintf(stderr,"connected\n"); 49 50 for (;;) { 51 r = usb_read(usb, buf, 64); 52 if (r < 0) 53 break; 54 if (write(1, buf, r)) { /* do nothing */ } 55 } 56 57 return 0; 58 }