{"id":1743,"date":"2013-01-28T14:29:51","date_gmt":"2013-01-28T05:29:51","guid":{"rendered":"http:\/\/www.pinewell.jp\/wordpress\/?p=1743"},"modified":"2013-01-28T14:29:51","modified_gmt":"2013-01-28T05:29:51","slug":"raspberrypi%e3%81%ae%e3%83%aa%e3%83%a2%e3%82%b3%e3%83%b3%e5%8c%962","status":"publish","type":"post","link":"http:\/\/www.pinewell.jp\/wordpress\/?p=1743","title":{"rendered":"RaspberryPi\u306e\u30ea\u30e2\u30b3\u30f3\u53162"},"content":{"rendered":"<p>\u524d\u56de\u306fGPIO\u304b\u3089\u306e\u30b9\u30a4\u30c3\u30c1\u5165\u529b\u3067AQUOS\u3092\u30b3\u30f3\u30c8\u30ed\u30fc\u30eb\u3057\u305f\u3002<br \/>\n\u4eca\u56de\u306fKURO-RS\u3092RaspberryPi\u306b\u63a5\u7d9a\u3002<br \/>\n\u601d\u308f\u306c\u3068\u3053\u308d\u3067\u30cf\u30de\u3063\u305f\u306e\u304cftdi_sio\u3002\u3053\u308c\u304c\u306a\u305c\u3060\u304b\u30cf\u30f3\u30b0\u30a2\u30c3\u30d7\u3059\u308b\u3002<br \/>\n\u30b0\u30b0\u3063\u3066\u307f\u308b\u3068\u3069\u3046\u3084\u3089\u305d\u3046\u3044\u3046\u3082\u306e\u3089\u3057\u3044\u3002\u3068\u308a\u3042\u3048\u305a \/boot\/cmdline.txt\u306bdwc_otg.speed=1\u3092\u8ffd\u8a18\u3002<br \/>\n\u3053\u308c\u306fUSB\u3092\u30d5\u30eb\u30b9\u30d4\u30fc\u30c9\u56fa\u5b9a\u306b\u3057\u3066\u3057\u307e\u3046\u3082\u306e\u3089\u3057\u3044\u3002\u30d5\u30eb\u30b9\u30d4\u30fc\u30c9\u3068\u8a00\u3048\u307012Mbps\u3002\u30b7\u30ea\u30a2\u30eb\u901a\u4fe1\u306b\u306f\u5145\u5206\u3067\u306f\u3042\u308b\u3002<br \/>\n\u3055\u3089\u306b\u3001\u96fb\u6e90\u3064\u3051\u3063\u3071\u306a\u3057\u3067\u653e\u7f6e\u3057\u3066\u304a\u304f\u3068\u30cd\u30c3\u30c8\u30ef\u30fc\u30af\u304c\u30d5\u30ea\u30fc\u30ba\u3059\u308b\u3053\u3068\u304c\u5ea6\u3005\u30fb\u30fb\u30fb\u3002<br \/>\n\u3053\u308c\u306f\/boot\/cmdline.txt\u306bsmsc95xx.turbo_mode=N\u3092\u8ffd\u8a18\u3059\u308b\u3053\u3068\u3067\u89e3\u6c7a\u3057\u305f\u3002<br \/>\n\u3053\u308c\u3082\u534a2\u91cd\u306b\u3059\u308b\u610f\u5473\u306e\u3088\u3046\u306a\u306e\u3067\u9045\u304f\u306f\u306a\u308b\u306e\u3060\u308d\u3046\u3002\u30ea\u30e2\u30b3\u30f3\u7528\u9014\u3067\u306f\u5145\u5206\u3002<\/p>\n<p>kuro-rs\u3092\u63a5\u7d9a\u3057\u3066\u3082ftdi_sio\u306f\u81ea\u52d5\u3067\u306f\u8aad\u307f\u8fbc\u307e\u308c\u306a\u3044\u3002\u3053\u308c\u306f<br \/>\n\/sbin\/modprobe ftdi_sio vendor=0x0411 product=0x00b3 \u3068\u3059\u308b\u3002\u3053\u308c\u3067\/dev\/ttyUSB0\u304c\u3067\u304d\u308b\u3002<br \/>\n\u901a\u5e38www-data\u3067\u306f\/dev\/ttyUSB0\u306f\u8aad\u307f\u66f8\u304d\u3067\u304d\u306a\u3044\u306e\u3067\u3053\u308c\u3078\u306e\u5bfe\u51e6\u3002\uff08\u30e6\u30fc\u30b6\u30fc\u3092\u8ffd\u52a0\u3068\u304b\u3001chmod\u3057\u3061\u3083\u3046\u3068\u304b\uff09\u3002<\/p>\n<p>kuro-rs\u3067\u4f7f\u7528\u3059\u308b\u30bd\u30d5\u30c8\u30a6\u30a7\u30a2\u306fkuro-rs\u306b\u4ed8\u5c5e\u3057\u3066\u3044\u305f\u3082\u306e\u306a\u306e\u3067\u30bd\u30fc\u30b9\u306f\u30a2\u30c3\u30d7\u3067\u304d\u306a\u3044\u3002<br \/>\nrs_rec.c\u3092\u30b3\u30f3\u30d1\u30a4\u30eb\u3057\u3066\u3001TVPOW\u3084\u305d\u306e\u4ed6\u30ea\u30e2\u30b3\u30f3\u306e\u30c7\u30fc\u30bf\u3092\u53d6\u5f97\u3002<br \/>\nrs_send.c\u3092\u30b3\u30f3\u30d1\u30a4\u30eb\u3057\u3066sendIr\u3068\u3057\u305f\u3002<\/p>\n<p>lighttpd\u3068php\u3092apt-get\u3057\u3066\u3001lighttpd\u3067PHP\u3092\u4f7f\u3048\u308b\u3088\u3046\u306b\u3059\u308b\u3002<br \/>\nphp\u304b\u3089raspi\u306e\u30b7\u30ea\u30a2\u30eb\uff08\/dev\/ttyAMA0\uff09\u3092\u7d4c\u7531\u3057\u3066AQUOS\u3092\u30b3\u30f3\u30c8\u30ed\u30fc\u30eb\u3059\u308b\u305f\u3081\u306esendrc.c<\/p>\n<pre lang=\"c\" line=\"\">\n#include <stdio.h>\n#include <stdlib.h>\n#include <bcm2835.h>\n#include <signal.h>\n\n#include<string.h>\n#include<strings.h>\n#include<termios.h>\n#include<unistd.h>\n#include<fcntl.h>\n#include<stdarg.h>\n#include<unistd.h>\n#include <syslog.h>\n#include <errno.h>\n\n\/\/\u30b9\u30a4\u30c3\u30c1\u30b3\u30de\u30f3\u30c9\n#define SW1_CMD \"\\rPOWR0000\\r\" \/\/POWER OFF\n#define SW2_CMD \"\\rIAVD1   \\r\" \/\/\u5165\u529b\u5207\u308a\u66ff\u30481\n#define SW3_CMD \"\\rIAVD2   \\r\" \/\/            2\n#define SW4_CMD \"\\rIAVD3   \\r\"\n#define SW5_CMD \"\\rIAVD4   \\r\"\n#define SW6_CMD \"\\rIAVD5   \\r\"\n#define SW7_CMD \"\\rCHUP    \\r\" \/\/\u30c1\u30e3\u30f3\u30cd\u30ebUP\n#define SW8_CMD \"\\rCHDW    \\r\" \/\/\u30c1\u30e3\u30f3\u30cd\u30ebDOWN\n#define SW9_CMD \"\\rCTBD031 \\r\" \/\/\u5730\u30c7\u30b8\n#define SW10_CMD \"\\rCBSD103 \\r\" \/\/BS\n#define SW11_CMD \"\\rCCSD350 \\r\" \/\/CS\n#define SW12_CMD \"\\rVOLM0   \\r\" \/\/\u6d88\u97f3\n#define BAUDRATE B9600           \/* \u901a\u4fe1\u901f\u5ea6\u306e\u8a2d\u5b9a *\/\n#define MODEMDEVICE \"\/dev\/ttyAMA0\" \/* \u30c7\u30d0\u30a4\u30b9\u30d5\u30a1\u30a4\u30eb\u306e\u6307\u5b9a:COM1 *\/\n\n#define FALSE 0\n#define TRUE 1\n#define MC 4 \/* \u8aad\u307f\u8fbc\u3080\u6587\u5b57\u6570 *\/\nvolatile int STOP=FALSE;\n\n\/\/\u30b7\u30ea\u30a2\u30eb\u3078\u306e\u30b3\u30de\u30f3\u30c9\u9001\u4fe1\nvoid main(int argc,char *argv[]) \n{ \n  int cmdno=1;\n  int fd, c, res, i;             \/* fd:\u30d5\u30a1\u30a4\u30eb\u30c7\u30a3\u30b9\u30af\u30ea\u30d7\u30bf res:\u53d7\u3051\u53d6\u3063\u305f\u6587\u5b57\u6570 *\/\n  struct termios oldtio, newtio; \/* \u901a\u4fe1\u30dd\u30fc\u30c8\u3092\u5236\u5fa1\u3059\u308b\u305f\u3081\u306e\u30a4\u30f3\u30bf\u30fc\u30d5\u30a7\u30a4\u30b9 *\/\n  char buf[255];                 \/* \u53d7\u4fe1\u6587\u5b57\u3092\u683c\u7d0d *\/\n\n\n  if (argc == 2) {\n\tcmdno=atoi(argv[1]);\n\tif (cmdno==0) cmdno=1;\n\tif (cmdno > 12) cmdno=1;\n  }\n\n  if((fd=open(MODEMDEVICE, O_RDWR | O_NOCTTY))== -1){\n    \/* O_RDWR:\u8aad\u307f\u66f8\u304d\u4e21\u7528 O_NOCTTY:tty\u5236\u5fa1\u3092\u3057\u306a\u3044 *\/\n\n    perror(MODEMDEVICE);\n    exit(-1);\n  }\n\n  tcgetattr(fd, &oldtio);          \/* \u73fe\u5728\u306e\u30b7\u30ea\u30a2\u30eb\u30dd\u30fc\u30c8\u306e\u8a2d\u5b9a\u3092\u9000\u907f\u3055\u305b\u308b *\/\n  bzero(&newtio, sizeof(newtio));  \/* \u65b0\u3057\u3044\u30dd\u30fc\u30c8\u306e\u8a2d\u5b9a\u306e\u69cb\u9020\u4f53\u3092\u30af\u30ea\u30a2 *\/\n\n  newtio.c_cflag= (BAUDRATE | CS8 | CLOCAL | CREAD);\n   \/* CRTSCTS:\u30d5\u30ed\u30fc\u5236\u5fa1\u6709\u308a CS8:8\u30d3\u30c3\u30c8\u3001\u30ce\u30f3\u30d1\u30ea\u30c6\u30a3\u3001\u30b9\u30c8\u30c3\u30d7\u30d3\u30c3\u30c8\uff11\n *       CLOCAL:\u30e2\u30c7\u30e0\u306e\u72b6\u614b\u4fe1\u53f7\u3092\u7121\u8996 CREAD:\u53d7\u4fe1\u53ef\u80fd\u306b\u3059\u308b *\/\n\n  newtio.c_iflag=IGNPAR;          \/* IGNPAR:\u30d1\u30ea\u30c6\u30a3\u30a8\u30e9\u30fc\u306e\u6587\u5b57\u306f\u7121\u8996 *\/\n\n  newtio.c_oflag=0;               \/* raw\u30e2\u30fc\u30c9 *\/\n  newtio.c_lflag=0;               \/* \u975e\u30ab\u30ce\u30cb\u30ab\u30eb\u5165\u529b *\/\n\n  newtio.c_cc[VTIME]=0;           \/* \u30ad\u30e3\u30e9\u30af\u30bf\u9593\u30bf\u30a4\u30de\u306f\u672a\u4f7f\u7528 *\/\n  newtio.c_cc[VMIN]=MC;            \/* MC\u6587\u5b57\u53d7\u3051\u53d6\u308b\u307e\u3067\u30d6\u30ed\u30c3\u30af\u3059\u308b *\/\n\n  tcflush(fd,TCIFLUSH);           \/* \u30dd\u30fc\u30c8\u306e\u30af\u30ea\u30a2 *\/\n  tcsetattr(fd, TCSANOW, &newtio); \/* \u30dd\u30fc\u30c8\u306e\u8a2d\u5b9a\u3092\u6709\u52b9\u306b\u3059\u308b *\/\n\n\n  char strbuf[20];\n  switch (cmdno){\n\tcase 1:\n  \t\tstrcpy(strbuf,SW1_CMD);\n\t\tbreak;\n\tcase 2:\n  \t\tstrcpy(strbuf,SW2_CMD);\n\t\tbreak;\n\tcase 3:\n  \t\tstrcpy(strbuf,SW3_CMD);\n\t\tbreak;\n\tcase 4:\n  \t\tstrcpy(strbuf,SW4_CMD);\n\t\tbreak;\n\tcase 5:\n  \t\tstrcpy(strbuf,SW5_CMD);\n\t\tbreak;\n\tcase 6:\n  \t\tstrcpy(strbuf,SW6_CMD);\n\t\tbreak;\n\tcase 7:\n  \t\tstrcpy(strbuf,SW7_CMD);\n\t\tbreak;\n\tcase 8:\n  \t\tstrcpy(strbuf,SW8_CMD);\n\t\tbreak;\n\tcase 9:\n  \t\tstrcpy(strbuf,SW9_CMD);\n\t\tbreak;\n\tcase 10:\n  \t\tstrcpy(strbuf,SW10_CMD);\n\t\tbreak;\n\tcase 11:\n  \t\tstrcpy(strbuf,SW11_CMD);\n\t\tbreak;\n\tcase 12:\n  \t\tstrcpy(strbuf,SW12_CMD);\n\t\tbreak;\n\tdefault:\n  \t\tstrcpy(strbuf,\"\\rPOWR0000\\r\");\n  }\n\n  \/\/\u30b3\u30de\u30f3\u30c9\u9001\u4fe1\n  write(fd,strbuf,sizeof(strbuf));\n  tcsetattr(fd, TCSANOW, &oldtio);  \/* \u9000\u907f\u3055\u305b\u305f\u8a2d\u5b9a\u306b\u623b\u3059 *\/\n  close(fd);                       \/* COM1\u306e\u30b7\u30ea\u30a2\u30eb\u30dd\u30fc\u30c8\u3092\u9589\u3058\u308b *\/\n  printf(\"cmdno: %d\",cmdno);\n  exit(0);\n }\n<\/pre>\n<p>\u4f7f\u3044\u65b9\u306f.\/sendrs 1 \u3068\u304b\u30021~12\u306b\u9001\u4fe1\u3059\u308b\u30b3\u30de\u30f3\u30c9\u3092\u30cf\u30fc\u30c9\u30b3\u30fc\u30c7\u30a3\u30f3\u30b0\u3057\u3066\u3044\u308b\u3002<br \/>\n\u672c\u6765\u306a\u3089usage\u3084\u3089\u8a2d\u5b9a\u30d5\u30a1\u30a4\u30eb\u3084\u3089\u3067\u5909\u3048\u3089\u308c\u308b\u306e\u304c\u671b\u307e\u3057\u3044\u306e\u3060\u304c\u3001\u3081\u3093\u3069\u3044\u3002<\/p>\n","protected":false},"excerpt":{"rendered":"<p>\u524d\u56de\u306fGPIO\u304b\u3089\u306e\u30b9\u30a4\u30c3\u30c1\u5165\u529b\u3067AQUOS\u3092\u30b3\u30f3\u30c8\u30ed\u30fc\u30eb\u3057\u305f\u3002 \u4eca\u56de\u306fKURO-RS\u3092RaspberryPi\u306b\u63a5\u7d9a\u3002 \u601d\u308f\u306c\u3068\u3053\u308d\u3067\u30cf\u30de\u3063\u305f\u306e\u304cftdi_sio\u3002\u3053\u308c\u304c\u306a\u305c\u3060\u304b\u30cf\u30f3\u30b0\u30a2\u30c3\u30d7\u3059\u308b\u3002 \u30b0\u30b0\u3063\u3066\u307f\u308b\u3068\u3069\u3046\u3084\u3089 [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[1],"tags":[],"class_list":["post-1743","post","type-post","status-publish","format-standard","hentry","category-1"],"views":4131,"_links":{"self":[{"href":"http:\/\/www.pinewell.jp\/wordpress\/index.php?rest_route=\/wp\/v2\/posts\/1743","targetHints":{"allow":["GET"]}}],"collection":[{"href":"http:\/\/www.pinewell.jp\/wordpress\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"http:\/\/www.pinewell.jp\/wordpress\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"http:\/\/www.pinewell.jp\/wordpress\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"http:\/\/www.pinewell.jp\/wordpress\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=1743"}],"version-history":[{"count":0,"href":"http:\/\/www.pinewell.jp\/wordpress\/index.php?rest_route=\/wp\/v2\/posts\/1743\/revisions"}],"wp:attachment":[{"href":"http:\/\/www.pinewell.jp\/wordpress\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=1743"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"http:\/\/www.pinewell.jp\/wordpress\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=1743"},{"taxonomy":"post_tag","embeddable":true,"href":"http:\/\/www.pinewell.jp\/wordpress\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=1743"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}