From a3fb3597f047645881bc49eeeff402155bf4951a Mon Sep 17 00:00:00 2001 From: h3ndrik Date: Thu, 22 Mar 2012 01:44:34 +0100 Subject: [PATCH] set_led --- hid-example | Bin 0 -> 9426 bytes hid-example.c~ | 182 +++++++++++++++++++++++++++++++++++++++++++++++++ sdljpd | Bin 40623 -> 40623 bytes sdljpd.c~ | 17 ++++- set_led | Bin 0 -> 7825 bytes set_led.c | 67 ++++++++++++++++++ set_led.c~ | 67 ++++++++++++++++++ 7 files changed, 332 insertions(+), 1 deletion(-) create mode 100755 hid-example create mode 100644 hid-example.c~ create mode 100755 set_led create mode 100644 set_led.c create mode 100644 set_led.c~ diff --git a/hid-example b/hid-example new file mode 100755 index 0000000000000000000000000000000000000000..2ee8202df7efc560710e1c64236ce656e7e36fb5 GIT binary patch literal 9426 zcmeHNeQaCR6~D2QG;Px)4TXM?t%fC#GQ~}yt>5PVCfXj_ujc zZGu|0EG^^7gk=&)WvaAj(?lnj=pO3&5H`RJ~X~wLn)mwLsz(qN{b75hc4j!H)M&$iIqEoGXKYjf zp1tJwA<7EjHy?i3<~;aO5ktpW^o6?Ue-8X;UCo6$7SyF52fpT|3iL{6(Y+=M-jxNv zE(>0l1#irP-(P;tPQqdJ!(WJ%JG0 z6%D99w$a_Vp-#Ecd82a;L}Ro3=|~RDCax{I9plRaFx55|1Psfmh3%Z;I-oUxKuX}a zMsRGXOc-!+%W=`90mt<HwsgYBxNNe)451>1)l&`|o!_7ejGD3c%jSX#)K_S@I~kxt9nZ-#-4 zxF%5lB^!*+(7lBcMH;CW1v zvi9zI`6*euq}k-YORHfOL+6 zj^-kNPoux{0F7@MdLHXLpg!W7!cfO66Rs)wVDZuYd1t{<@zK%bYv%U0fpVW~Dksr4 zmEdizJ0AW0(3|LIIf&%`$FZ*%L9WamqzG1nC=q*@g&Irb3mkXvx`jE+25!k2x1kiY7=o?tS1L_GrmD)&Z zH>?0zJD%uAN6G6!uDw1z4RxSd{M>=JaL|TElj~8MnWPF``i_vg&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u++n3#ryo{LlHT!35VFt#@XVfP*3c%+JO`>yxl=K?T=7*_YWQ;4-w%!xeK2*`KmWz+oQZggL~3VIQ$d?NeU33oy(*WKa1lB@z?!{p z%+kKK|NAZWluwTcd&<8UKkgA$`$qx8xTt@$pA6!nfI|J(xy-&oJU$y3?T1BP8y5Eb z*@cvW(*8yCF^fH&dq+e-r-dJKL3YId#9~kTpDZ@WB2pAo49he+2sMnK#(%5WKer0| zZWJ1d)&4NZjP`U+Oy|e=OlT}t`=cN<+Or}_R~Lc5Y&3>C%^$(TP(gdze>3Omx`uVU zto9=odpwE3QX&k$%KmlGHMWnZFjySI(Au7r|0C$)R8#!4f6{sXAUcPF_dgc0r?}n+ z%-BAiTb_c$A1tJ=a~YoSzk>T5v&*7kL+*{^nt)+Wsm+96`vXN^KTL_+(g z8PA3NP%=WiZik)o@T_?L^mDY)$PTNR_9ru5z-Zqw<8vA9CuV#eqkY1R&u5hX&3NJT zdx9BXz$jmv@uKPPk7m4h`u)O;moUnkW_%%hN0W>YuiNnp3FSG1)XuJe#M5p-^r{`+ z9w;vvg?4xgp?qV;uY&J|?M8^#?QHS%cMYS^4!a!P_hx)4qx;#6FJp9{nsKq{4WNF1 z6tP43k^yB5@4H-fZu-5Cg!sIaGs`&K!10;mP{Z+=Cszp80FLv8pS7@P{K}XMa2(IA7C)PW zK0SX5b#|xFw~qgIp^x9ou<)}tpdB3Nkm;gk!5;?PVbau@LtKBByxr*u1`VH*S!Yy@ zsc|^b?u75bb*)WX6nA4wD|}&AlzJ1lsm>tshLs(`aEB+T@b_lL6YpX0P8uo&o4z%=s60vydMSn<2%=PYvMs8LXmAZ$ke}Z&u`A=gkoRRBwjF zr04^L=gd~I<%_;mYzW`-4+VP!Xz literal 0 HcmV?d00001 diff --git a/hid-example.c~ b/hid-example.c~ new file mode 100644 index 0000000..8764a67 --- /dev/null +++ b/hid-example.c~ @@ -0,0 +1,182 @@ +/* + * Hidraw Userspace Example + * + * Copyright (c) 2010 Alan Ott + * Copyright (c) 2010 Signal 11 Software + * + * The code may be used by anyone for any purpose, + * and can serve as a starting point for developing + * applications using hidraw. + */ + +/* Linux */ +#include +#include +#include + +/* + * Ugly hack to work around failing compilation on systems that don't + * yet populate new version of hidraw.h to userspace. + * + * If you need this, please have your distro update the kernel headers. + */ +#ifndef HIDIOCSFEATURE +#define HIDIOCSFEATURE(len) _IOC(_IOC_WRITE|_IOC_READ, 'H', 0x06, len) +#define HIDIOCGFEATURE(len) _IOC(_IOC_WRITE|_IOC_READ, 'H', 0x07, len) +#endif + +/* Unix */ +#include +#include +#include +#include +#include + +/* C */ +#include +#include +#include +#include + +const char *bus_str(int bus); + +int main(int argc, char **argv) +{ + int fd; + int i, res, desc_size = 0; + char buf[256]; + struct hidraw_report_descriptor rpt_desc; + struct hidraw_devinfo info; + + /* Open the Device with non-blocking reads. In real life, + don't use a hard coded path; use libudev instead. */ + fd = open("/dev/hidraw0", O_RDWR|O_NONBLOCK); + + if (fd < 0) { + perror("Unable to open device"); + return 1; + } + + memset(&rpt_desc, 0x0, sizeof(rpt_desc)); + memset(&info, 0x0, sizeof(info)); + memset(buf, 0x0, sizeof(buf)); + + /* Get Report Descriptor Size */ + res = ioctl(fd, HIDIOCGRDESCSIZE, &desc_size); + if (res < 0) + perror("HIDIOCGRDESCSIZE"); + else + printf("Report Descriptor Size: %d\n", desc_size); + + /* Get Report Descriptor */ + rpt_desc.size = desc_size; + res = ioctl(fd, HIDIOCGRDESC, &rpt_desc); + if (res < 0) { + perror("HIDIOCGRDESC"); + } else { + printf("Report Descriptor:\n"); + for (i = 0; i < rpt_desc.size; i++) + printf("%hhx ", rpt_desc.value[i]); + puts("\n"); + } + + /* Get Raw Name */ + res = ioctl(fd, HIDIOCGRAWNAME(256), buf); + if (res < 0) + perror("HIDIOCGRAWNAME"); + else + printf("Raw Name: %s\n", buf); + + /* Get Physical Location */ + res = ioctl(fd, HIDIOCGRAWPHYS(256), buf); + if (res < 0) + perror("HIDIOCGRAWPHYS"); + else + printf("Raw Phys: %s\n", buf); + + /* Get Raw Info */ + res = ioctl(fd, HIDIOCGRAWINFO, &info); + if (res < 0) { + perror("HIDIOCGRAWINFO"); + } else { + printf("Raw Info:\n"); + printf("\tbustype: %d (%s)\n", + info.bustype, bus_str(info.bustype)); + printf("\tvendor: 0x%04hx\n", info.vendor); + printf("\tproduct: 0x%04hx\n", info.product); + } + + /* Set Feature */ +// buf[0] = 0x9; /* Report Number */ +// buf[1] = 0xff; +// buf[2] = 0xff; +// buf[3] = 0xff; +// res = ioctl(fd, HIDIOCSFEATURE(4), buf); +// if (res < 0) +// perror("HIDIOCSFEATURE"); +// else +// printf("ioctl HIDIOCGFEATURE returned: %d\n", res); + + /* Get Feature */ +// buf[0] = 0x9; /* Report Number */ +// res = ioctl(fd, HIDIOCGFEATURE(256), buf); +// if (res < 0) { +// perror("HIDIOCGFEATURE"); +// } else { +// printf("ioctl HIDIOCGFEATURE returned: %d\n", res); +// printf("Report data (not containing the report number):\n\t"); +// for (i = 0; i < res; i++) +// printf("%hhx ", buf[i]); +// puts("\n"); +// } + + /* Send a Report to the Device */ + buf[0] = 0x0; /* Report Number */ + buf[1] = 0x00; + buf[2] = 0x01; + buf[3] = 0x00; + buf[4] = 0x00; + buf[5] = 0x01; + res = write(fd, buf, 6); + if (res < 0) { + printf("Error: %d\n", errno); + perror("write"); + } else { + printf("write() wrote %d bytes\n", res); + } + + /* Get a report from the device */ + res = read(fd, buf, 16); + if (res < 0) { + perror("read"); + } else { + printf("read() read %d bytes:\n\t", res); + for (i = 0; i < res; i++) + printf("%hhx ", buf[i]); + puts("\n"); + } + close(fd); + return 0; +} + +const char * +bus_str(int bus) +{ + switch (bus) { + case BUS_USB: + return "USB"; + break; + case BUS_HIL: + return "HIL"; + break; + case BUS_BLUETOOTH: + return "Bluetooth"; + break; + case BUS_VIRTUAL: + return "Virtual"; + break; + default: + return "Other"; + break; + } +} diff --git a/sdljpd b/sdljpd index 26de27fcd89ea43b3f8948b10fc73b5f68e208f8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?*q+;U9+)>izc1IQKSZoA zjXm~^|IKI5|5sKi`-5z#INLFQ*Jqzr|98^Lp4-W8*pB6C6bR$~A5r#4KBxVMu%-St z;PMjN-|hubR>L{RmjmP2Ue#Z#_@8+}k3GZWkDndJh!3bggvV84Sqp3QwpKQwF}}Qv3)_j1pA>b{1n2@ITqCYF#1!5{c9n- zT=4$nH40%=c;6|;mk8cZit$Rp`$RE*jo|!Wj4z#gFDS;B3C`EWc-7pwbunHoIKLL- zHG=bIF}@tv7J!5Prkld75;r zZXxV){M;Ags|7#L#rPV*&uKAE{|1Z6eLkwh(lWiMf}Xn)ae3}Nk1J`}2NoEITO>Yz z92zA)e;itY2St@=@WrL`*?=gtpP#3P75;6NfA~2aP=3aIeim#0lhV(%qTM(C-;?+X zp;ziC73jw(2E_dKKM$PRKU$#|lu%_m_vQmHk^EkMOpJR*QW5AaO zR|-0O^wQ54(SIFy%>w=UGjPr8K$Y{rmj_pi0ky7JL`^Gz|N zMx95%_f5yI>uHhiJCbR}vMIASnv5kZVYcl +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +int main(int argc, char **argv) +{ + int fd; + int res = 0; + char buf[256]; + + /* Open the Device with non-blocking reads. In real life, + don't use a hard coded path; use libudev instead. */ + fd = open("/dev/hidraw0", O_RDWR|O_NONBLOCK); + + if (fd < 0) { + perror("Unable to open device"); + return 1; + } + + memset(buf, 0x0, sizeof(buf)); + + switch (argv[1][0]) { + case '0': + break; + case '1': + buf[2] = 0xff; + break; + case '2': + buf[3] = 0xff; + break; + case '3': + buf[4] = 0xff; + break; + case '4': + buf[5] = 0xff; + break; + default: + printf("Please specify 0 ... 4 as single argument.\n"); + } + + /* Send a Report to the Device */ + buf[0] = 0x00; /* Report Number */ + buf[1] = 0x00; /* Report ID */ + //buf[2] = 0x01; /* Buzzer 1 */ + //buf[3] = 0x00; /* Buzzer 2 */ + //buf[4] = 0x00; /* Buzzer 3 */ + //buf[5] = 0x01; /* Buzzer 4 */ + res = write(fd, buf, 6); + if (res < 0) { + printf("Error: %d\n", errno); + perror("write"); + } else { + //printf("write() wrote %d bytes\n", res); + } + + close(fd); + return 0; +} diff --git a/set_led.c~ b/set_led.c~ new file mode 100644 index 0000000..37fb741 --- /dev/null +++ b/set_led.c~ @@ -0,0 +1,67 @@ +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +int main(int argc, char **argv) +{ + int fd; + int i, res = 0; + char buf[256]; + + /* Open the Device with non-blocking reads. In real life, + don't use a hard coded path; use libudev instead. */ + fd = open("/dev/hidraw0", O_RDWR|O_NONBLOCK); + + if (fd < 0) { + perror("Unable to open device"); + return 1; + } + + memset(buf, 0x0, sizeof(buf)); + + switch (argv[1][0]) { + case '0': + break; + case '1': + buf[2] = 0xff; + break; + case '2': + buf[3] = 0xff; + break; + case '3': + buf[4] = 0xff; + break; + case '4': + buf[5] = 0xff; + break; + default: + printf("Please specify 0 ... 4 as single argument.\n"); + } + + /* Send a Report to the Device */ + buf[0] = 0x00; /* Report Number */ + buf[1] = 0x00; /* Report ID */ + //buf[2] = 0x01; /* Buzzer 1 */ + //buf[3] = 0x00; /* Buzzer 2 */ + //buf[4] = 0x00; /* Buzzer 3 */ + //buf[5] = 0x01; /* Buzzer 4 */ + res = write(fd, buf, 6); + if (res < 0) { + printf("Error: %d\n", errno); + perror("write"); + } else { + //printf("write() wrote %d bytes\n", res); + } + + close(fd); + return 0; +}