changeset 6:cd846ca24ca4

more cleanup
author Yoshiki Yazawa <yaz@honeyplanet.jp>
date Wed, 05 Jan 2011 22:32:50 +0900
parents 37e662c427a1
children d2b8d45019d9
files rcctl.c
diffstat 1 files changed, 14 insertions(+), 31 deletions(-) [+]
line wrap: on
line diff
--- a/rcctl.c	Wed Jan 05 22:32:12 2011 +0900
+++ b/rcctl.c	Wed Jan 05 22:32:50 2011 +0900
@@ -14,28 +14,10 @@
    v0.50  11.01.06  linux専用に書き直し (yaz)
    【cdcnv.c の履歴も参照のこと】
    ------------------------------------------------------*/
-#define __LINUX__
-#include <fcntl.h>
+
 #include <stdio.h>
-//#include <termios.h>
-//#include <unistd.h>
-//#include <sys/ioctl.h>
-
-#define HID_MAX_USAGES 16
-typedef unsigned int __u32;
-typedef unsigned int kernel_ulong_t;
-
 #include <hid.h>
 #include <libusb.h>
-
-#include <linux/types.h>
-
-#define BITS_PER_LONG 32
-
-#include <asm/types.h>
-#include <errno.h>
-#include <string.h>
-
 #include "debug.h"
 
 #ifndef S_VERS
@@ -44,7 +26,6 @@
 
 /* globals */
 HIDInterface *hidif;
-extern int errno;
 int debug = 0;
 
 /* prototypes */
@@ -66,7 +47,7 @@
 
     ret = hid_init();
     if (ret != HID_RET_SUCCESS) {
-        fprintf(stderr, "hid_init failed with return code %d\n", ret);
+        message(0, "hid_init failed with return code %d\n", ret);
         return 1;
     }
 
@@ -78,7 +59,7 @@
 
     ret = hid_force_open(hidif, 0, &matcher, 3);
     if (ret != HID_RET_SUCCESS) {
-        fprintf(stderr, "hid_force_open failed with return code %d\n", ret);
+        message(0, "hid_force_open failed with return code %d\n", ret);
         return 1;
     }
 
@@ -92,7 +73,7 @@
 
     ret = hid_close(hidif);
     if (ret != HID_RET_SUCCESS) {
-        fprintf(stderr, "hid_close failed with return code %d\n", ret);
+        message(0, "hid_close failed with return code %d\n", ret);
         return 1;
     }
 
@@ -100,7 +81,7 @@
 
     ret = hid_cleanup();
     if (ret != HID_RET_SUCCESS) {
-        fprintf(stderr, "hid_cleanup failed with return code %d\n", ret);
+        message(0, "hid_cleanup failed with return code %d\n", ret);
         return 1;
     }
 
@@ -153,28 +134,30 @@
     if (init_usb())
         return 255;
 
-    debug(1, " done.\n");
+    debug(1, "done.\n");
 
+    debug(1, "");
     for(i=0; i<u; i++ ) {
-        debug(1, "%02x ", buf[i]);
+        message(1, "%02x ", buf[i]);
     }
-    debug(1, "\n");
+    message(1, "\n");
 
 	const int PATH_IN[1] = { 0xffa10004 };
 
     /* u is the total length of the packet to send */
+    debug(1,"");
     for(i=1; i<u; i++ ) {
         sbuf[(i-1)%8] = buf[i] & 0x00ff;
-        debug(1, "%02x ", sbuf[(i-1)%8]);
+        message(1, "%02x ", sbuf[(i-1)%8]);
         if ((i == 8)||(i == (u-1))) {
             ret = hid_set_output_report(hidif, PATH_IN, 2, (char *)sbuf, 8);
-            fprintf(stderr, "**WRITE**\n");
+            message(1, "**WRITE** ");
             if (ret != HID_RET_SUCCESS) {
-                fprintf(stderr, "hid_set_output_report failed with return code %d\n", ret);
+                message(0, "hid_set_output_report failed with return code %d\n", ret);
             }
         }
     }
-    debug(1, "\n");
+    message(1, "\n");
 
     if(fin_usb())
         return 255;