<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
		xmlns:xhtml="http://www.w3.org/1999/xhtml"
>

<channel>
	<title>望遠鏡ドットコム &#187; 自宅サーバ</title>
	<atom:link href="http://www.boenkyo.com/archives/category/jitakuserver/feed" rel="self" type="application/rss+xml" />
	<link>http://www.boenkyo.com</link>
	<description>「望遠鏡」って言葉の響きがね。</description>
	<lastBuildDate>Sun, 29 Jan 2012 02:30:50 +0000</lastBuildDate>
	<language>ja</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.3.1</generator>
<xhtml:link rel="alternate" media="handheld" type="text/html" href="http://www.boenkyo.com/archives/category/jitakuserver/feed" />
		<item>
		<title>mediatomb再設定</title>
		<link>http://www.boenkyo.com/archives/1521</link>
		<comments>http://www.boenkyo.com/archives/1521#comments</comments>
		<pubDate>Mon, 07 Nov 2011 08:59:26 +0000</pubDate>
		<dc:creator>masaki</dc:creator>
				<category><![CDATA[自宅サーバ]]></category>

		<guid isPermaLink="false">http://www.boenkyo.com/?p=1521</guid>
		<description><![CDATA[我が家のPS3はもっぱらDLNA再生マシンです。 先日yum updateしたところ、mediatombも新しく(?)されてしまいました。設定は/etc/sysconfig/に移動してるけれども、設定は/etc/medi [...]]]></description>
			<content:encoded><![CDATA[<div class="social4i" style="height:29px;">
<div class="social4in" style="height:29px;float: left;">
<div class="socialicons s4twitter" style="float:left;margin-right: 10px;background:url(&quot;http://goo.gl/zjqd1&quot;) no-repeat;"><a href="http://twitter.com/share" data-url="http://www.boenkyo.com/archives/1521" data-counturl="http://www.boenkyo.com/archives/1521" data-text="mediatomb再設定" class="twitter-share-button" data-count="horizontal" data-via=""></a></div>
<div class="socialicons s4fblike" style="float:left;margin-right: 10px;">
<div id="fb-root"></div>
<p><fb:like href="http%3A%2F%2Fwww.boenkyo.com%2Farchives%2F1521" send="false" layout="button_count" width="100" height="21" show_faces="false" font=""></fb:like></div>
<div class="socialicons s4plusone" style="float:left;margin-right: 10px;"><g:plusone size="medium" href="http://www.boenkyo.com/archives/1521" count="true"></g:plusone></div>
<div class="socialicons s4fbshare" style="position: relative;float:left;margin-right: 10px;">
<div class="s4ifbshare" ><a name="fb_share" type="button_count" share_url="http%3A%2F%2Fwww.boenkyo.com%2Farchives%2F1521" href="http://www.facebook.com/sharer.php"></a></div>
</div>
</div>
<div style="clear:both"></div>
</div>
<p>我が家のPS3はもっぱらDLNA再生マシンです。</p>
<p>先日yum updateしたところ、mediatombも新しく(?)されてしまいました。設定は/etc/sysconfig/に移動してるけれども、設定は/etc/mediatomb/config.xmlを読んでいる模様。いったんsqliteで動作確認とれましたが、この際、MySQLを使うことにしようと思い、ハマりました。</p>
<p>結局、config.xmlで
<password>hoge</password>という項目を追記していなかったのが原因でした。</p>
]]></content:encoded>
			<wfw:commentRss>http://www.boenkyo.com/archives/1521/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
	<xhtml:link rel="alternate" media="handheld" type="text/html" href="http://www.boenkyo.com/archives/1521" />
	</item>
		<item>
		<title>CentOSにNetatalk2.2.1を入れてTime Machine化</title>
		<link>http://www.boenkyo.com/archives/1484</link>
		<comments>http://www.boenkyo.com/archives/1484#comments</comments>
		<pubDate>Sat, 01 Oct 2011 08:33:55 +0000</pubDate>
		<dc:creator>masaki</dc:creator>
				<category><![CDATA[MacBook Pro]]></category>
		<category><![CDATA[自宅サーバ]]></category>

		<guid isPermaLink="false">http://www.boenkyo.com/?p=1484</guid>
		<description><![CDATA[OSXのTime Machine機能は便利で助けられることしばしなのですが、Time Capsuleはちょっと手を出すのに躊躇する価格だし、もともとsambaサーバーが動いているので、Netatalkで実現できると知って [...]]]></description>
			<content:encoded><![CDATA[<div class="social4i" style="height:29px;">
<div class="social4in" style="height:29px;float: left;">
<div class="socialicons s4twitter" style="float:left;margin-right: 10px;background:url(&quot;http://goo.gl/zjqd1&quot;) no-repeat;"><a href="http://twitter.com/share" data-url="http://www.boenkyo.com/archives/1484" data-counturl="http://www.boenkyo.com/archives/1484" data-text="CentOSにNetatalk2.2.1を入れてTime Machine化" class="twitter-share-button" data-count="horizontal" data-via=""></a></div>
<div class="socialicons s4fblike" style="float:left;margin-right: 10px;">
<div id="fb-root"></div>
<p><fb:like href="http%3A%2F%2Fwww.boenkyo.com%2Farchives%2F1484" send="false" layout="button_count" width="100" height="21" show_faces="false" font=""></fb:like></div>
<div class="socialicons s4plusone" style="float:left;margin-right: 10px;"><g:plusone size="medium" href="http://www.boenkyo.com/archives/1484" count="true"></g:plusone></div>
<div class="socialicons s4fbshare" style="position: relative;float:left;margin-right: 10px;">
<div class="s4ifbshare" ><a name="fb_share" type="button_count" share_url="http%3A%2F%2Fwww.boenkyo.com%2Farchives%2F1484" href="http://www.facebook.com/sharer.php"></a></div>
</div>
</div>
<div style="clear:both"></div>
</div>
<p>OSXのTime Machine機能は便利で助けられることしばしなのですが、Time Capsuleはちょっと手を出すのに躊躇する価格だし、もともとsambaサーバーが動いているので、Netatalkで実現できると知って勉強がてらやってみました。</p>
<h4>参考になったページ</h4>
<ul>
<li><a href="http://hatx.blog.so-net.ne.jp/netatalk_status">netatalk 2.2.1 リリース：HAT blog</a>
</li>
<li><a href="http://www003.upp.so-net.ne.jp/hat/netatalk/andsamba.html">Netatalk and Samba</a></li>
<li><a href="http://d.hatena.ne.jp/paraches/20110912">CentOS 5.6に netatalk 2.2.1を入れるのが大変だった… &#8211; Debian GNU/Linux 3.1 on PowerMac G4</a></li>
<li><a href="http://rewse.jp/blog/p/3569">Mac OS X Lion 対応 Time Machine サーバー構築 | 複眼中心</a></li>
<li><a href="http://weboo-returns.com/blog/os-x-lion-linux-time-machine/">OS X Lion から Linuxサーバに Time Machine バックアップ | Weboo! Returns.</a></li>
<li><a href="http://www.hattory.com/doc/manual/user_guide/user_guide/netatalkshare.html">共有ディレクトリの設定</a></li>
</ul>
<h4>インストール</h4>
<p>BarkleyDBの最新版をインストール(オラクルのユーザ登録が必要でwgetできない)。Netatalk2.2.1をもってきてconfigureしてmake、make installまではスムーズでした。なお、かっこつけてgitでNetatalk開発版をもってきましたが、makeでエラーのためあっさり断念。</p>
<h4>設定</h4>
<p>参考ページをみて設定を済ませると、サーバがFinderにはあがってくるのだけど接続できなくて苦闘。iptablesで548を開けていなかったのが原因でした。<a href="http://penguin-web.dyndns.org/mountain/blogs/312">Lion対応のNetatalk 2.2 で Time Machine サーバーを作る &#8211; MacBook Pro &#8211; やっぱし山へ行く</a> でハッと気づきました。ありがとうございます(僕も山好きです)。</p>
<p>iptablesは理解不能なので<a href="http://sakidroid.blog38.fc2.com/blog-entry-17.html">　 CentOSでポートの開放-歌って踊れる開発者になりたい</a>を参考に簡単に対応。</p>
<p>さて、これでパスワード入力画面までこぎつけましたが、またまた苦戦しましたが、パスワードを間違えていただけでした。</p>
<p>以下、設定ファイルを備忘録的に。</p>
<p>netatalk.conf</p>
<pre>
#### server (unix) and legacy client (<= Mac OS 9) charsets
#ATALK_UNIX_CHARSET='LOCALE'
ATALK_UNIX_CHARSET='UTF8'
#ATALK_MAC_CHARSET='MAC_ROMAN'
ATALK_MAC_CHARSET='MAC_JAPANESE'
.......
#### config for cnid_metad. Default log config:
#CNID_CONFIG="-l log_note"
CNID_CONFIG="-l log_note -f /var/log/netatalk.log"
</pre>
<p>afpd.conf(sambaもあるのでサーバ名を明記)</p>
<pre>
"hoge_afp" -uamlist uams_dhx2.so -setuplog "default LOG_INFO /var/log/netatalk.log"
</pre>
<p>AppleVolumes.default(よそのをそのまま戴き)</p>
<pre>
:DEFAULT: options:upriv,usedots dperm:0700 fperm:0600 maccharset:MAC_JAPANESE ea:sys
#~
</pre>
<p>AppleVolumes.system(ディレクトリの設定はsystemに)</p>
<pre>
/hoge/TimeMachine/hoge/ "Time Machine Hoge" allow:hoge options:tm
/hoge/rec/ "rec"
</pre>
<p>configureのsummaryも記録。</p>
<pre>
Configure summary:
    Install style:
         redhat-sysv
    AFP:
         Large file support (>2GB) for AFP3: yes
         Extended Attributes: ad | sys
    CNID:
         backends:  dbd last tdb
    UAMS:
         DHX     (PAM SHADOW)
         DHX2    (PAM SHADOW)
         RANDNUM (PAM SHADOW)
         passwd  (PAM SHADOW)
         guest
    Options:
         DDP (AppleTalk) support: no
         SLP support:             no
         Zeroconf support:        yes
         tcp wrapper support:     yes
         quota support:           yes
         admin group support:     yes
         valid shell check:       yes
         cracklib support:        no
         dropbox kludge:          no
         force volume uid/gid:    no
         ACL support:             yes
         LDAP support:            yes
</pre>
]]></content:encoded>
			<wfw:commentRss>http://www.boenkyo.com/archives/1484/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
	<xhtml:link rel="alternate" media="handheld" type="text/html" href="http://www.boenkyo.com/archives/1484" />
	</item>
		<item>
		<title>関連投稿を表示するプラグイン Yet Another Related Posts Plugin</title>
		<link>http://www.boenkyo.com/archives/1479</link>
		<comments>http://www.boenkyo.com/archives/1479#comments</comments>
		<pubDate>Sat, 24 Sep 2011 08:09:29 +0000</pubDate>
		<dc:creator>masaki</dc:creator>
				<category><![CDATA[WordPress]]></category>
		<category><![CDATA[自宅サーバ]]></category>

		<guid isPermaLink="false">http://www.boenkyo.com/?p=1479</guid>
		<description><![CDATA[長らく愛用させていただいていたWordPress Related Post for Japanese (関連投稿表示プラグイン)がどうもうまく動作しないため、格闘していましたが、断念し、Yet Another Relat [...]]]></description>
			<content:encoded><![CDATA[<div class="social4i" style="height:29px;">
<div class="social4in" style="height:29px;float: left;">
<div class="socialicons s4twitter" style="float:left;margin-right: 10px;background:url(&quot;http://goo.gl/zjqd1&quot;) no-repeat;"><a href="http://twitter.com/share" data-url="http://www.boenkyo.com/archives/1479" data-counturl="http://www.boenkyo.com/archives/1479" data-text="関連投稿を表示するプラグイン Yet Another Related Posts Plugin" class="twitter-share-button" data-count="horizontal" data-via=""></a></div>
<div class="socialicons s4fblike" style="float:left;margin-right: 10px;">
<div id="fb-root"></div>
<p><fb:like href="http%3A%2F%2Fwww.boenkyo.com%2Farchives%2F1479" send="false" layout="button_count" width="100" height="21" show_faces="false" font=""></fb:like></div>
<div class="socialicons s4plusone" style="float:left;margin-right: 10px;"><g:plusone size="medium" href="http://www.boenkyo.com/archives/1479" count="true"></g:plusone></div>
<div class="socialicons s4fbshare" style="position: relative;float:left;margin-right: 10px;">
<div class="s4ifbshare" ><a name="fb_share" type="button_count" share_url="http%3A%2F%2Fwww.boenkyo.com%2Farchives%2F1479" href="http://www.facebook.com/sharer.php"></a></div>
</div>
</div>
<div style="clear:both"></div>
</div>
<p>長らく愛用させていただいていた<a href="http://wppluginsj.sourceforge.jp/wp-jrelated/">WordPress Related Post for Japanese (関連投稿表示プラグイン)</a>がどうもうまく動作しないため、格闘していましたが、断念し、<a href="http://wordpress.org/extend/plugins/yet-another-related-posts-plugin/">Yet Another Related Posts Plugin</a>を試しているところです。</p>
<p>あちこちのサイトでは細かい設定ページが表示されているのに、私の設定画面にはでてこないなーと調べていたら、<a href="http://wordpress.org/support/topic/plugin-yet-another-related-posts-plugin-where-are-these-settings">WordPress › Support » [Plugin: Yet Another Related Posts Plugin] where are these settings??</a>という記事を発見しました。「表示オプション」でデフォルトで表示しない設定になっていました。</p>
<p>しかしやっぱり日本語には<a href="http://wppluginsj.sourceforge.jp/wp-jrelated/">WordPress Related Post for Japanese (関連投稿表示プラグイン)</a>のほうがよさそうなので再度チャレンジしてみます。</p>
<h4>追記</h4>
<p><a href="http://wppluginsj.sourceforge.jp/wp-jrelated/">WordPress Related Post for Japanese (関連投稿表示プラグイン)</a>ですが、<a href="http://www.aspenmesa.com/blog/3261">WordPressのプラグイン，JRelatedがうまく動かない | Life in Los Alamos</a>を読んで実践してみたところ、見事復活しました。</p>
<p>テーブルは勇み足でdropしてしまっていたのですが、再度テーブルを作ってくれないので手作業で復旧。やっぱりJRelatedは精度がよいです。<a href="http://www.aspenmesa.com/blog/3261">WordPressのプラグイン，JRelatedがうまく動かない | Life in Los Alamos</a>の記事に大感謝です。</p>
]]></content:encoded>
			<wfw:commentRss>http://www.boenkyo.com/archives/1479/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
	<xhtml:link rel="alternate" media="handheld" type="text/html" href="http://www.boenkyo.com/archives/1479" />
	</item>
		<item>
		<title>SCP1000+Arduino+Pachube+cacti</title>
		<link>http://www.boenkyo.com/archives/1438</link>
		<comments>http://www.boenkyo.com/archives/1438#comments</comments>
		<pubDate>Wed, 21 Sep 2011 07:49:51 +0000</pubDate>
		<dc:creator>masaki</dc:creator>
				<category><![CDATA[プログラミング]]></category>
		<category><![CDATA[自宅サーバ]]></category>

		<guid isPermaLink="false">http://www.boenkyo.com/?p=1438</guid>
		<description><![CDATA[気圧をグラフにして残す SCP1000+ArduinoをCentOS機(NEC 110ge)にUSB接続してデータを保管、Pachubeとcactiにてグラフ表示させてみました。 当初、cactiでひっそりこっそりデータ [...]]]></description>
			<content:encoded><![CDATA[<div class="social4i" style="height:29px;">
<div class="social4in" style="height:29px;float: left;">
<div class="socialicons s4twitter" style="float:left;margin-right: 10px;background:url(&quot;http://goo.gl/zjqd1&quot;) no-repeat;"><a href="http://twitter.com/share" data-url="http://www.boenkyo.com/archives/1438" data-counturl="http://www.boenkyo.com/archives/1438" data-text="SCP1000+Arduino+Pachube+cacti" class="twitter-share-button" data-count="horizontal" data-via=""></a></div>
<div class="socialicons s4fblike" style="float:left;margin-right: 10px;">
<div id="fb-root"></div>
<p><fb:like href="http%3A%2F%2Fwww.boenkyo.com%2Farchives%2F1438" send="false" layout="button_count" width="100" height="21" show_faces="false" font=""></fb:like></div>
<div class="socialicons s4plusone" style="float:left;margin-right: 10px;"><g:plusone size="medium" href="http://www.boenkyo.com/archives/1438" count="true"></g:plusone></div>
<div class="socialicons s4fbshare" style="position: relative;float:left;margin-right: 10px;">
<div class="s4ifbshare" ><a name="fb_share" type="button_count" share_url="http%3A%2F%2Fwww.boenkyo.com%2Farchives%2F1438" href="http://www.facebook.com/sharer.php"></a></div>
</div>
</div>
<div style="clear:both"></div>
</div>
<h4>気圧をグラフにして残す</h4>
<p>SCP1000+ArduinoをCentOS機(NEC 110ge)にUSB接続してデータを保管、<a href="http://pachube.com/">Pachube</a>とcactiにてグラフ表示させてみました。</p>
<p>当初、cactiでひっそりこっそりデータを確認してたのですが、Pachubeが思ったより簡単だったので、同時にデータを投げるようにしました。今回もいきあたりばったりでDBは使用せず、テキストファイルを使っています。</p>
<h4>USBデバイスからのデータを読み込む</h4>
<p><a href="http://www.boenkyo.com/archives/1414" title="PHP + PachubeAPIでPachubeにデータを投げる">ガイガーカウンターのときと同じような感じで</a>、データ生成ツール(今回はPerlスクリプト)をcronで回して、テキストで追記。これをPHPで読み取り、cacti用にprintfした後、Pachubeに投げます。</p>
<p>Perlスクリプトは「<a href="http://nekohigeweb.dyndns.org/memo/weather/usbweather.php">ねこひげめも｜Linux(CentOS)でUSBウェザーボードを使って遊ぶ</a>」を参考にさせて頂きました。参考というか、まるごとパクリです。</p>
<p><strong>追記</strong><br />
どうもSCP1000が返す数字を拾うのに失敗することが多いようで、グラフが歯抜けになってしまうので、ifを2回繰り返して、それでもダメなら空白を返すようにしました。0じゃなく、空白ならグラフも途切れるだけかな。3回待ってまで拾う意味のある数字でもないのでとりあえずこれで。</p>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
</pre></td><td class="code"><pre class="perl" style="font-family:monospace;"><span style="color: #666666; font-style: italic;">#!/usr/bin/perl</span>
&nbsp;
<span style="color: #000000; font-weight: bold;">use</span> strict<span style="color: #339933;">;</span>
<span style="color: #000066;">open</span><span style="color: #009900;">&#40;</span>PORT<span style="color: #339933;">,</span><span style="color: #ff0000;">&quot;/dev/ttyUSB0&quot;</span><span style="color: #009900;">&#41;</span> <span style="color: #339933;">||</span> <span style="color: #000066;">die</span> <span style="color: #ff0000;">&quot;NG!&quot;</span><span style="color: #339933;">;</span>
&nbsp;
<span style="color: #b1b100;">my</span> <span style="color: #0000ff;">$times</span> <span style="color: #339933;">=</span> <span style="color: #000066;">time</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #009900;">&#40;</span><span style="color: #b1b100;">my</span> <span style="color: #0000ff;">$sec</span><span style="color: #339933;">,</span><span style="color: #b1b100;">my</span> <span style="color: #0000ff;">$min</span><span style="color: #339933;">,</span><span style="color: #b1b100;">my</span> <span style="color: #0000ff;">$hour</span><span style="color: #339933;">,</span><span style="color: #b1b100;">my</span> <span style="color: #0000ff;">$mday</span><span style="color: #339933;">,</span><span style="color: #b1b100;">my</span> <span style="color: #0000ff;">$mon</span><span style="color: #339933;">,</span><span style="color: #b1b100;">my</span> <span style="color: #0000ff;">$year</span><span style="color: #339933;">,</span><span style="color: #b1b100;">my</span> <span style="color: #0000ff;">$wday</span><span style="color: #339933;">,</span><span style="color: #b1b100;">my</span> <span style="color: #0000ff;">$stime</span><span style="color: #009900;">&#41;</span> <span style="color: #339933;">=</span> <span style="color: #000066;">localtime</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">$times</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #0000ff;">$year</span> <span style="color: #339933;">=</span> <span style="color: #0000ff;">$year</span> <span style="color: #339933;">+</span><span style="color: #cc66cc;">1900</span><span style="color: #339933;">;</span>
<span style="color: #0000ff;">$mon</span><span style="color: #339933;">++;</span>
<span style="color: #b1b100;">my</span> <span style="color: #0000ff;">$datetime</span><span style="color: #339933;">=</span><span style="color: #000066;">sprintf</span><span style="color: #009900;">&#40;</span><span style="color: #ff0000;">&quot;%04d-%02d-%02dT%02d:%02d:%02d+09:00&quot;</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">$year</span><span style="color: #339933;">,</span><span style="color: #0000ff;">$mon</span><span style="color: #339933;">,</span><span style="color: #0000ff;">$mday</span><span style="color: #339933;">,</span><span style="color: #0000ff;">$hour</span><span style="color: #339933;">,</span><span style="color: #0000ff;">$min</span><span style="color: #339933;">,</span><span style="color: #0000ff;">$sec</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
<span style="color: #b1b100;">my</span> <span style="color: #0000ff;">$serial</span> <span style="color: #339933;">=</span> <span style="color: #009999;">&lt;PORT&gt;</span><span style="color: #339933;">;</span>
<span style="color: #000066;">chomp</span> <span style="color: #0000ff;">$serial</span><span style="color: #339933;">;</span>
<span style="color: #b1b100;">my</span> <span style="color: #0000ff;">@val</span> <span style="color: #339933;">=</span> <span style="color: #000066;">split</span> <span style="color: #009966; font-style: italic;">/,/</span><span style="color: #339933;">,</span><span style="color: #0000ff;">$serial</span><span style="color: #339933;">;</span>
&nbsp;
<span style="color: #b1b100;">if</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">$val</span><span style="color: #009900;">&#91;</span><span style="color: #cc66cc;">1</span><span style="color: #009900;">&#93;</span><span style="color: #339933;">&lt;</span><span style="color: #cc66cc;">1</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#123;</span>
    <span style="color: #000066;">sleep</span><span style="color: #009900;">&#40;</span><span style="color: #cc66cc;">5</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
    <span style="color: #b1b100;">my</span> <span style="color: #0000ff;">$serial</span> <span style="color: #339933;">=</span> <span style="color: #009999;">&lt;PORT&gt;</span><span style="color: #339933;">;</span>
    <span style="color: #000066;">chomp</span> <span style="color: #0000ff;">$serial</span><span style="color: #339933;">;</span>
    <span style="color: #b1b100;">my</span> <span style="color: #0000ff;">@val</span> <span style="color: #339933;">=</span> <span style="color: #000066;">split</span> <span style="color: #009966; font-style: italic;">/,/</span><span style="color: #339933;">,</span><span style="color: #0000ff;">$serial</span><span style="color: #339933;">;</span>
<span style="color: #009900;">&#125;</span>
&nbsp;
<span style="color: #b1b100;">my</span> <span style="color: #0000ff;">$temp</span> <span style="color: #339933;">=</span> <span style="color: #0000ff;">$val</span><span style="color: #009900;">&#91;</span><span style="color: #cc66cc;">0</span><span style="color: #009900;">&#93;</span><span style="color: #339933;">;</span>
<span style="color: #b1b100;">my</span> <span style="color: #0000ff;">$press</span> <span style="color: #339933;">=</span> <span style="color: #0000ff;">$val</span><span style="color: #009900;">&#91;</span><span style="color: #cc66cc;">1</span><span style="color: #009900;">&#93;</span><span style="color: #339933;">;</span>
<span style="color: #000066;">chomp</span> <span style="color: #0000ff;">$temp</span><span style="color: #339933;">;</span>
<span style="color: #000066;">chomp</span> <span style="color: #0000ff;">$press</span><span style="color: #339933;">;</span>
&nbsp;
<span style="color: #000066;">printf</span><span style="color: #009900;">&#40;</span><span style="color: #ff0000;">&quot;%s,%0.2f,%2.2f<span style="color: #000099; font-weight: bold;">\n</span>&quot;</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">$datetime</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">$press</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">$temp</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
<span style="color: #000066;">close</span><span style="color: #009900;">&#40;</span>PORT<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span></pre></td></tr></table></div>

<h4>定期実行させる</h4>
<p>crontabはこんな感じで。</p>
<pre>
*/5 * * * * /hoge/scp1000.pl >> /hoge/scp1000tmp.txt
</pre>
<pre>
scp1000tmp.txt

2011-09-21T16:00:03+09:00,986.60,28.03
2011-09-21T16:05:03+09:00,986.90,28.03
2011-09-21T16:10:03+09:00,987.05,28.07
2011-09-21T16:15:02+09:00,987.32,28.03
</pre>
<p><strong>追記2</strong><br />
cronで5分ごとにガイガーカウンターの数値もとっているためか、USBより数値を拾い損ねることが多発し、グラフが歯抜けすぎるので、1分ずらしてみました。</p>
<pre>
1,6,11,16,21,26,31,36,41,46,51,56 * * * * /hoge/scp1000.pl >> /hoge/scp1000tmp.txt
</pre>
<p>なお、SCP1000が日光の影響を受けるという動画がありました。気温と連動してるのかと思ってたら陽射しと連動していたのか・・・。これは急いで対策しなければ。</p>
<p><iframe width="420" height="315" src="http://www.youtube.com/embed/0FNeIHFbaxw" frameborder="0" allowfullscreen></iframe></p>
<h4>cactiとPachubeへ送信</h4>
<p>PHPスクリプトはcactiデータ取得用とPachube送信と兼用なのは<a href="http://www.boenkyo.com/archives/1414" title="PHP + PachubeAPIでPachubeにデータを投げる">ガイガーカウンターのときと同様です</a>。</p>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
</pre></td><td class="code"><pre class="php" style="font-family:monospace;"><span style="color: #000000; font-weight: bold;">&lt;?php</span>
<span style="color: #b1b100;">require_once</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'/PachubeAPI.php'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #990000;">mb_internal_encoding</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;UTF-8&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
<span style="color: #000088;">$datafile</span> <span style="color: #339933;">=</span> <span style="color: #0000ff;">&quot;/hoge/scp1000tmp.txt&quot;</span><span style="color: #339933;">;</span>
<span style="color: #000088;">$t_file</span> <span style="color: #339933;">=</span> <span style="color: #990000;">file_get_contents</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$datafile</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
<span style="color: #666666; font-style: italic;">//Pachube</span>
<span style="color: #000088;">$api_key</span> <span style="color: #339933;">=</span> <span style="color: #0000ff;">&quot;your_api_key_here&quot;</span><span style="color: #339933;">;</span>
<span style="color: #000088;">$feed</span> <span style="color: #339933;">=</span> <span style="color: #0000ff;">'5digit_feed_number'</span><span style="color: #339933;">;</span>
&nbsp;
<span style="color: #666666; font-style: italic;">//put all data into array</span>
<span style="color: #000088;">$rows</span> <span style="color: #339933;">=</span> <span style="color: #990000;">explode</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;<span style="color: #000099; font-weight: bold;">\n</span>&quot;</span><span style="color: #339933;">,</span> <span style="color: #000088;">$t_file</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #000088;">$cols</span> <span style="color: #339933;">=</span> <span style="color: #990000;">explode</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;,&quot;</span><span style="color: #339933;">,</span> <span style="color: #000088;">$t_file</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #000088;">$csv_arr</span> <span style="color: #339933;">=</span> <span style="color: #990000;">array_map</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;str_getcsv&quot;</span><span style="color: #339933;">,</span> <span style="color: #000088;">$rows</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #000088;">$row_c</span> <span style="color: #339933;">=</span> <span style="color: #990000;">count</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$csv_arr</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
<span style="color: #666666; font-style: italic;">//read the last line</span>
<span style="color: #000088;">$last_1time</span> <span style="color: #339933;">=</span> <span style="color: #000088;">$csv_arr</span><span style="color: #009900;">&#91;</span><span style="color: #000088;">$row_c</span><span style="color: #339933;">-</span><span style="color: #cc66cc;">2</span><span style="color: #009900;">&#93;</span><span style="color: #009900;">&#91;</span><span style="color: #cc66cc;">0</span><span style="color: #009900;">&#93;</span><span style="color: #339933;">;</span>
<span style="color: #000088;">$last_1pres</span> <span style="color: #339933;">=</span> <span style="color: #000088;">$csv_arr</span><span style="color: #009900;">&#91;</span><span style="color: #000088;">$row_c</span><span style="color: #339933;">-</span><span style="color: #cc66cc;">2</span><span style="color: #009900;">&#93;</span><span style="color: #009900;">&#91;</span><span style="color: #cc66cc;">1</span><span style="color: #009900;">&#93;</span><span style="color: #339933;">;</span>
<span style="color: #000088;">$last_1temp</span> <span style="color: #339933;">=</span> <span style="color: #000088;">$csv_arr</span><span style="color: #009900;">&#91;</span><span style="color: #000088;">$row_c</span><span style="color: #339933;">-</span><span style="color: #cc66cc;">2</span><span style="color: #009900;">&#93;</span><span style="color: #009900;">&#91;</span><span style="color: #cc66cc;">2</span><span style="color: #009900;">&#93;</span><span style="color: #339933;">;</span>
&nbsp;
<span style="color: #000088;">$datetime</span> <span style="color: #339933;">=</span> <span style="color: #000088;">$last_1time</span><span style="color: #339933;">;</span>
<span style="color: #000088;">$pressure</span> <span style="color: #339933;">=</span> <span style="color: #000088;">$last_1pres</span><span style="color: #339933;">;</span>
<span style="color: #000088;">$temp</span> <span style="color: #339933;">=</span> <span style="color: #000088;">$last_1temp</span><span style="color: #339933;">;</span>
&nbsp;
<span style="color: #666666; font-style: italic;">//print for cacti</span>
<span style="color: #990000;">printf</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;scppres:<span style="color: #009933; font-weight: bold;">%0.2f</span> scptemp:<span style="color: #009933; font-weight: bold;">%2.2f</span>&quot;</span><span style="color: #339933;">,</span> <span style="color: #000088;">$pressure</span><span style="color: #339933;">,</span><span style="color: #000088;">$temp</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
<span style="color: #666666; font-style: italic;">//max and min data for Pachube</span>
<span style="color: #000088;">$press_min</span> <span style="color: #339933;">=</span> <span style="color: #0000ff;">'800'</span><span style="color: #339933;">;</span>
<span style="color: #000088;">$press_max</span> <span style="color: #339933;">=</span> <span style="color: #0000ff;">'1050'</span><span style="color: #339933;">;</span>
<span style="color: #000088;">$temp_min</span> <span style="color: #339933;">=</span> <span style="color: #0000ff;">'-10'</span><span style="color: #339933;">;</span>
<span style="color: #000088;">$temp_max</span> <span style="color: #339933;">=</span> <span style="color: #0000ff;">'50'</span><span style="color: #339933;">;</span>
&nbsp;
<span style="color: #666666; font-style: italic;">//Pachube</span>
<span style="color: #666666; font-style: italic;">//id1:Press id2:Temp</span>
<span style="color: #000088;">$json_arr</span> <span style="color: #339933;">=</span> <span style="color: #990000;">array</span><span style="color: #009900;">&#40;</span>
                  <span style="color: #0000ff;">'version'</span> <span style="color: #339933;">=&gt;</span> <span style="color: #0000ff;">'1.0.0'</span><span style="color: #339933;">,</span>
                  <span style="color: #0000ff;">'datastreams'</span> <span style="color: #339933;">=&gt;</span> <span style="color: #990000;">array</span><span style="color: #009900;">&#40;</span><span style="color: #990000;">array</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'id'</span> <span style="color: #339933;">=&gt;</span> <span style="color: #0000ff;">'1'</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">'at'</span> <span style="color: #339933;">=&gt;</span> <span style="color: #000088;">$datetime</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">'max_value'</span> <span style="color: #339933;">=&gt;</span> <span style="color: #000088;">$press_max</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">'min_value'</span> <span style="color: #339933;">=&gt;</span> <span style="color: #000088;">$press_min</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">'current_value'</span> <span style="color: #339933;">=&gt;</span> <span style="color: #000088;">$pressure</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">,</span>
                                         <span style="color: #990000;">array</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'id'</span> <span style="color: #339933;">=&gt;</span> <span style="color: #0000ff;">'2'</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">'at'</span> <span style="color: #339933;">=&gt;</span> <span style="color: #000088;">$datetime</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">'max_value'</span> <span style="color: #339933;">=&gt;</span> <span style="color: #000088;">$temp_max</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">'min_value'</span> <span style="color: #339933;">=&gt;</span> <span style="color: #000088;">$temp_min</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">'current_value'</span> <span style="color: #339933;">=&gt;</span> <span style="color: #000088;">$temp</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span>
                  <span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #000088;">$update_data</span> <span style="color: #339933;">=</span> <span style="color: #990000;">json_encode</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$json_arr</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
<span style="color: #000088;">$obj</span> <span style="color: #339933;">=</span> <span style="color: #000000; font-weight: bold;">new</span> PachubeAPI<span style="color: #009900;">&#40;</span><span style="color: #000088;">$api_key</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #000088;">$obj</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">updateFeed</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'json'</span><span style="color: #339933;">,</span> <span style="color: #000088;">$feed</span><span style="color: #339933;">,</span> <span style="color: #000088;">$update_data</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
<span style="color: #000000; font-weight: bold;">?&gt;</span></pre></td></tr></table></div>

]]></content:encoded>
			<wfw:commentRss>http://www.boenkyo.com/archives/1438/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
	<xhtml:link rel="alternate" media="handheld" type="text/html" href="http://www.boenkyo.com/archives/1438" />
	</item>
		<item>
		<title>PHP + PachubeAPIでPachubeにデータを投げる</title>
		<link>http://www.boenkyo.com/archives/1414</link>
		<comments>http://www.boenkyo.com/archives/1414#comments</comments>
		<pubDate>Fri, 16 Sep 2011 15:18:23 +0000</pubDate>
		<dc:creator>masaki</dc:creator>
				<category><![CDATA[プログラミング]]></category>
		<category><![CDATA[自宅サーバ]]></category>

		<guid isPermaLink="false">http://www.boenkyo.com/?p=1414</guid>
		<description><![CDATA[Pachube(パッチベイ)に挑戦 データを引っ張れるようになったストロベリーリナックス社のUSBガイガーカウンタキットをより活用すべく、cactiと同時にPachubeにデータをアップロードするようにしました。 PHP [...]]]></description>
			<content:encoded><![CDATA[<div class="social4i" style="height:29px;">
<div class="social4in" style="height:29px;float: left;">
<div class="socialicons s4twitter" style="float:left;margin-right: 10px;background:url(&quot;http://goo.gl/zjqd1&quot;) no-repeat;"><a href="http://twitter.com/share" data-url="http://www.boenkyo.com/archives/1414" data-counturl="http://www.boenkyo.com/archives/1414" data-text="PHP + PachubeAPIでPachubeにデータを投げる" class="twitter-share-button" data-count="horizontal" data-via=""></a></div>
<div class="socialicons s4fblike" style="float:left;margin-right: 10px;">
<div id="fb-root"></div>
<p><fb:like href="http%3A%2F%2Fwww.boenkyo.com%2Farchives%2F1414" send="false" layout="button_count" width="100" height="21" show_faces="false" font=""></fb:like></div>
<div class="socialicons s4plusone" style="float:left;margin-right: 10px;"><g:plusone size="medium" href="http://www.boenkyo.com/archives/1414" count="true"></g:plusone></div>
<div class="socialicons s4fbshare" style="position: relative;float:left;margin-right: 10px;">
<div class="s4ifbshare" ><a name="fb_share" type="button_count" share_url="http%3A%2F%2Fwww.boenkyo.com%2Farchives%2F1414" href="http://www.facebook.com/sharer.php"></a></div>
</div>
</div>
<div style="clear:both"></div>
</div>
<h4>Pachube(パッチベイ)に挑戦</h4>
<p><a title="CentOSでストロベリーリナックスUSBガイガーカウンタキット" href="http://www.boenkyo.com/archives/1353">データを引っ張れるようになった</a><a href="http://strawberry-linux.com/catalog/items?code=53001" target="_blank">ストロベリーリナックス社のUSBガイガーカウンタキット</a>をより活用すべく、cactiと同時に<a href="https://pachube.com/">Pachube</a>にデータをアップロードするようにしました。</p>
<h4>PHPでデータを送信する</h4>
<p><a href="http://api.pachube.com/v2/">Pachube v2 API Documentation</a>を流し読みしましたが、結局、PHP用のクラス<a href="https://github.com/MunGell/PachubeAPI">PachubeAPI</a>をみつけ、活用いたしました。ありがとうございます。</p>
<h4>前回のに追加するコード</h4>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
</pre></td><td class="code"><pre class="php" style="font-family:monospace;">&nbsp;
<span style="color: #666666; font-style: italic;">//頭に追加</span>
<span style="color: #b1b100;">require_once</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'PachubeAPI.php'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><span style="color: #666666; font-style: italic;">//上記本文参照</span>
&nbsp;
<span style="color: #339933;">.....</span>
&nbsp;
<span style="color: #666666; font-style: italic;">//Pachube</span>
<span style="color: #000088;">$api_key</span> <span style="color: #339933;">=</span> <span style="color: #0000ff;">'your_api_key_here'</span><span style="color: #339933;">;</span><span style="color: #666666; font-style: italic;">//APIキー</span>
<span style="color: #000088;">$feed</span> <span style="color: #339933;">=</span> <span style="color: #0000ff;">'5_digit_feed_number'</span><span style="color: #339933;">;</span> <span style="color: #666666; font-style: italic;">//作成したfeedのURLの末尾の数字</span>
&nbsp;
<span style="color: #339933;">.....</span>
&nbsp;
<span style="color: #666666; font-style: italic;">//(略)前の記事参照のこと</span>
&nbsp;
<span style="color: #339933;">.....</span>
&nbsp;
<span style="color: #666666; font-style: italic;">//最後に追加</span>
&nbsp;
<span style="color: #666666; font-style: italic;">//Pachube用データ作成と投稿</span>
&nbsp;
<span style="color: #666666; font-style: italic;">//先に取得済みのcpmとusvを四捨五入。</span>
<span style="color: #666666; font-style: italic;">//JSON化するために数値-&gt;文字列に</span>
<span style="color: #000088;">$cpm_round</span> <span style="color: #339933;">=</span> <span style="color: #990000;">strval</span><span style="color: #009900;">&#40;</span><span style="color: #990000;">round</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$cpm</span><span style="color: #339933;">,</span> <span style="color: #cc66cc;">0</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #000088;">$usv_round</span> <span style="color: #339933;">=</span> <span style="color: #990000;">strval</span><span style="color: #009900;">&#40;</span><span style="color: #990000;">round</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$usv</span><span style="color: #339933;">,</span> <span style="color: #cc66cc;">4</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
<span style="color: #666666; font-style: italic;">//json_encode用に配列を作成。idとcurrent_valueを代入。</span>
<span style="color: #000088;">$json_arr</span> <span style="color: #339933;">=</span> <span style="color: #990000;">array</span><span style="color: #009900;">&#40;</span>
                  <span style="color: #0000ff;">'version'</span> <span style="color: #339933;">=&gt;</span> <span style="color: #0000ff;">'1.0.0'</span><span style="color: #339933;">,</span>
                  <span style="color: #0000ff;">'datastreams'</span> <span style="color: #339933;">=&gt;</span> <span style="color: #990000;">array</span><span style="color: #009900;">&#40;</span><span style="color: #990000;">array</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'id'</span> <span style="color: #339933;">=&gt;</span> <span style="color: #0000ff;">'1'</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">'current_value'</span> <span style="color: #339933;">=&gt;</span> <span style="color: #000088;">$cpm_round</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">,</span>
                                         <span style="color: #990000;">array</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'id'</span> <span style="color: #339933;">=&gt;</span> <span style="color: #0000ff;">'2'</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">'current_value'</span> <span style="color: #339933;">=&gt;</span> <span style="color: #000088;">$usv_round</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span>
                  <span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #666666; font-style: italic;">//JSON化</span>
<span style="color: #000088;">$update_data</span> <span style="color: #339933;">=</span> <span style="color: #990000;">json_encode</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$json_arr</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
<span style="color: #666666; font-style: italic;">//データを投稿</span>
<span style="color: #000088;">$obj</span> <span style="color: #339933;">=</span> <span style="color: #000000; font-weight: bold;">new</span> PachubeAPI<span style="color: #009900;">&#40;</span><span style="color: #000088;">$api_key</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #000088;">$obj</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">updateFeed</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'json'</span><span style="color: #339933;">,</span> <span style="color: #000088;">$feed</span><span style="color: #339933;">,</span> <span style="color: #000088;">$update_data</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span></pre></td></tr></table></div>

<h4>まとめ</h4>
<p>Pachubeはなんとなく難しそうで敬遠していたのですが、<a href="https://github.com/MunGell/PachubeAPI">PachubeAPI</a>のおかげで特に新しい勉強をしなくても運用開始できました。改めて感謝です。</p>
<h4>Pachubeから動的画像出力</h4>
<p><img alt="" src="http://api.pachube.com/v2/feeds/35771/datastreams/2.png?width=730&#038;height=250&#038;colour=%23243cf1&#038;duration=1week&#038;legend=uSv/h(=cpm/120@LND712)&#038;title=Radiation@Himeji, Hyogo(w/ Strawberry Linux USB Geiger Counter)&#038;stroke_size=4&#038;show_axis_labels=true&#038;detailed_grid=true&#038;scale=manual&#038;min=0.08&#038;timezone=Osaka" class="alignnone" width="730" height="250" /></p>
]]></content:encoded>
			<wfw:commentRss>http://www.boenkyo.com/archives/1414/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
	<xhtml:link rel="alternate" media="handheld" type="text/html" href="http://www.boenkyo.com/archives/1414" />
	</item>
		<item>
		<title>CentOSでストロベリーリナックスUSBガイガーカウンタキット</title>
		<link>http://www.boenkyo.com/archives/1353</link>
		<comments>http://www.boenkyo.com/archives/1353#comments</comments>
		<pubDate>Tue, 13 Sep 2011 04:58:37 +0000</pubDate>
		<dc:creator>masaki</dc:creator>
				<category><![CDATA[プログラミング]]></category>
		<category><![CDATA[自宅サーバ]]></category>

		<guid isPermaLink="false">http://www.boenkyo.com/?p=1353</guid>
		<description><![CDATA[ストロベリーリナックス社のUSBガイガーカウンタキット(以下文中ではUSBガイガー)をCentOSで利用できるようにしてみたので記録。なお、プログラミングは初心者です。よろしければ間違い、よりスマートな方法をご教示下さい [...]]]></description>
			<content:encoded><![CDATA[<div class="social4i" style="height:29px;">
<div class="social4in" style="height:29px;float: left;">
<div class="socialicons s4twitter" style="float:left;margin-right: 10px;background:url(&quot;http://goo.gl/zjqd1&quot;) no-repeat;"><a href="http://twitter.com/share" data-url="http://www.boenkyo.com/archives/1353" data-counturl="http://www.boenkyo.com/archives/1353" data-text="CentOSでストロベリーリナックスUSBガイガーカウンタキット" class="twitter-share-button" data-count="horizontal" data-via=""></a></div>
<div class="socialicons s4fblike" style="float:left;margin-right: 10px;">
<div id="fb-root"></div>
<p><fb:like href="http%3A%2F%2Fwww.boenkyo.com%2Farchives%2F1353" send="false" layout="button_count" width="100" height="21" show_faces="false" font=""></fb:like></div>
<div class="socialicons s4plusone" style="float:left;margin-right: 10px;"><g:plusone size="medium" href="http://www.boenkyo.com/archives/1353" count="true"></g:plusone></div>
<div class="socialicons s4fbshare" style="position: relative;float:left;margin-right: 10px;">
<div class="s4ifbshare" ><a name="fb_share" type="button_count" share_url="http%3A%2F%2Fwww.boenkyo.com%2Farchives%2F1353" href="http://www.facebook.com/sharer.php"></a></div>
</div>
</div>
<div style="clear:both"></div>
</div>
<p><a href="http://strawberry-linux.com/catalog/items?code=53001" target="_blank">ストロベリーリナックス社のUSBガイガーカウンタキット</a>(以下文中ではUSBガイガー)をCentOSで利用できるようにしてみたので記録。なお、プログラミングは初心者です。よろしければ間違い、よりスマートな方法をご教示下さい。</p>
<p><a href="http://www.boenkyo.com/wp-content/uploads/graph_image.png"><img src="http://www.boenkyo.com/wp-content/uploads/graph_image-300x116.png" alt="" title="USBガイガーをグラフ化" width="300" height="116" class="alignnone size-medium wp-image-1408" /></a></p>
<h4>概要</h4>
<p>単品でサーバ機に接続すべきか、Arduinoを挟むか(少し)検討しました。</p>
<p>直結するメリット:</p>
<ol>
<li>GM管のパルスをカウントするアルゴリズムが他のユーザと共通であるため全国のユーザと比較することが可能。</li>
<li>追加投資が不要。</li>
</ol>
<p>直結するデメリット:</p>
<ol>
<li><a href="http://or2.to/2011/05/usb-geiger3.html">USB-GEIGERでモニタリングポストを作ろう3</a>で解析されているように「連続稼動は「約194日」で、放射線カウントは同様に、最大「約43万」まで計測可能」という制限を受けてしまう。</li>
<li>既存のドライバ類がないので自力でなんとかしなくてはいけない。</li>
</ol>
<p>下記のリンクを参考にしたところ、ドライバじゃなくてもアクセス可能であり、また、同類のボード用のツール・ドライバは存在することがわかりました。そこで、そのソースを勝手にいじくってUSBガイガーを利用しようと思い立ちました。</p>
<p>秋月Arduinoをいくつももってるのでメリット2)は無関係。といっても、電源が2つ必要なのは面倒だなーと思ってましたが、Arduinoからパルス・電源・GNDと3本引っ張ればよいのでありました(<a href="http://d.hatena.ne.jp/ksh0ji/20101014/128703279">参考リンク9</a>)。デメリット1は大きいのですが、メリット1のことも考えると・・・。そんなわけで、とりあえずソースいじくって数字をとれるところまでできましたので記録しておきます。でも今後Arduino経由に移行するかも。</p>
<h4>参考</h4>
<p>詳細な情報提供に感謝です。</p>
<ol>
<li><a href="http://or2.to/2011/05/usb-geiger3.html" target="_blank">USB-GEIGERでモニタリングポストを作ろう3 &#8211; ITのある生活</a></li>
<li><a href="http://d.hatena.ne.jp/dayflower/20090721/1248159253" target="_blank">USB-RH で遊ぶ &#8211; daily dayflower</a></li>
<li><a href="http://www.dd.iij4u.or.jp/~briareos/soft/usbrh.html" target="_blank">USBRH on Linux</a></li>
<li><a href="http://green-rabbit.sakura.ne.jp/usbrh/" target="_blank">USBRH driver for Linux</a></li>
<li><a href="http://www.nk-home.net/~aoyama/usbrh/" target="_blank">Using USBRH on *BSD</a></li>
<li><a href="http://d.hatena.ne.jp/stereocat/20100712/1278937930" target="_blank">USBRH+Cactiで室温モニタリング(1) &#8211; # cat /var/log/stereocat | tail -n3</a></li>
<li><a href="http://penguin.tantin.jp/hard/libusb%E3%81%AB%E3%81%A4%E3%81%84%E3%81%A6.html" target="_blank">libusbについて &#8211; Linux工作室</a></li>
<li><a href="http://nekohigeweb.dyndns.org/memo/weather/usbweather.php" target="_blank">ねこひげめも｜Linux(CentOS)でUSBウェザーボードを使って遊ぶ</a></li>
<li><a href="http://d.hatena.ne.jp/ksh0ji/20101014/128703279" target="_blank">ガイガーカウンターのカウント数をTwitterに投稿するアプリを作る &#8211; なんか作る</a></li>
</ol>
<h4>接続</h4>
<p>まず、キットを組み立てます。GM管の扱いに注意すれば、半田付けするだけです。圧電ブザー音のオンオフはUSBガイガーの再起動で初期化されるごとにオンになるため、ブザーにはセロハンテープかなんかでフタをしておくとよいかもしれません。</p>
<p>USBガイガーをサーバに接続してlsusbするとずらずらっとUSB機器が表示されますが、「Bus 007 Device 002: ID 1774:1002」とID 1774:1002と出る行が当USBガイガー機です。BusとDeviceは環境によって異なります。</p>
<p>上記のBusとDeviceの数字を用いてlsusb -D /proc/bus/usb/007/002とすると、詳細情報が表示されます。<a href="http://www.nk-home.net/~aoyama/usbrh/" target="_blank">Using USBRH on *BSD</a>の一番下の資料のデータと突き合わせてみたところ、USBガイガーとUSBRHは接続に関しては同一と判断し、USBRH用ツールを改造することにしました。なお、ドライバーのソースも拝見しましたが、自分の実力では改造は到底無理と判断。</p>
<p>ソースいじりにとりかかる前にＵＳＢデバイス接続後の振る舞いを予め設定しておきます。<a href="http://d.hatena.ne.jp/dayflower/20090721/1248159253" target="_blank">USB-RH で遊ぶ &#8211; daily dayflower</a>より、udevルールを設定。</p>
<h4>ソースの改変</h4>
<p><a href="http://www.dd.iij4u.or.jp/~briareos/soft/usbrh.html">USBRH on Linux</a>よりUSBRHのソースを頂きます。これならなんとなく自分でも分かりそうです(USB絡みの難しいところは定番記述として無視するとして)。</p>
<p>最初に<a href="http://d.hatena.ne.jp/dayflower/20090721/1248159253" target="_blank">USB-RH で遊ぶ &#8211; daily dayflower</a>のパッチを当てました。</p>
<p>いよいよ、USBガイガー用にソースを修正します。</p>
<p>計算にべき乗を使うのでmath.hをincludeしないといけないようです。VENDER IDとPRODUCT IDは上記、lsusbより得た「Bus 007 Device 002: ID 1774:1002」を使用。PRODUCT IDがひとつ違うだけです。</p>

<div class="wp_syntax"><div class="code"><pre class="c" style="font-family:monospace;"><span style="color: #339933;">#include</span>
&nbsp;
<span style="color: #339933;">#define USBGEIGER_VENDOR 0x1774</span>
<span style="color: #339933;">#define USBGEIGER_PRODUCT 0x1002</span></pre></div></div>

<p>その他、USBRHとなっているところはUSBGEIGERに一括置換。カウントとタイマーをカンマ区切りで出力するオプションCを追加しました。</p>
<p>さて、USBデバイスから返された数値は変数buffの中に<a href="http://or2.to/2011/05/usb-geiger3.html">USB-GEIGERでモニタリングポストを作ろう3 &#8211; ITのある生活</a>での解析にあるように「91cc0100f34c07」と7バイトで入っています。</p>
<p>buffから数字を取り出すために以下のとおり、関数を作成。</p>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
</pre></td><td class="code"><pre class="c" style="font-family:monospace;"><span style="color: #993333;">int</span> calccount<span style="color: #009900;">&#40;</span><span style="color: #993333;">unsigned</span> <span style="color: #993333;">char</span> <span style="color: #339933;">*</span>in<span style="color: #339933;">,</span> <span style="color: #993333;">int</span> length<span style="color: #009900;">&#41;</span>
<span style="color: #009900;">&#123;</span>
<span style="color: #993333;">int</span> i<span style="color: #339933;">,</span> d<span style="color: #339933;">,</span> s<span style="color: #339933;">;</span>
d <span style="color: #339933;">=</span> s <span style="color: #339933;">=</span> <span style="color: #0000dd;">0</span><span style="color: #339933;">;</span>
&nbsp;
    <span style="color: #b1b100;">for</span><span style="color: #009900;">&#40;</span>i<span style="color: #339933;">=</span>length<span style="color: #339933;">;</span>i<span style="color: #339933;">&gt;</span><span style="color: #0000dd;">0</span><span style="color: #339933;">;</span>i<span style="color: #339933;">--</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#123;</span>
      <span style="color: #b1b100;">if</span><span style="color: #009900;">&#40;</span>i<span style="color: #339933;">&lt;</span><span style="color: #0000dd;">5</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#123;</span>
        d <span style="color: #339933;">=</span> in<span style="color: #009900;">&#91;</span>i<span style="color: #339933;">-</span><span style="color: #0000dd;">1</span><span style="color: #009900;">&#93;</span> <span style="color: #339933;">*</span> pow<span style="color: #009900;">&#40;</span><span style="color: #0000dd;">16</span><span style="color: #339933;">,</span><span style="color: #009900;">&#40;</span>i<span style="color: #339933;">-</span><span style="color: #0000dd;">1</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">*</span><span style="color: #0000dd;">2</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
        <span style="color: #666666; font-style: italic;">//printf(&quot;%02x %d\n&quot;, in[i-1], d);</span>
        s <span style="color: #339933;">=</span> s <span style="color: #339933;">+</span> d<span style="color: #339933;">;</span>
        <span style="color: #009900;">&#125;</span>
    <span style="color: #009900;">&#125;</span>
    <span style="color: #b1b100;">return</span> s<span style="color: #339933;">;</span>
<span style="color: #009900;">&#125;</span>
&nbsp;
&nbsp;
<span style="color: #993333;">int</span> calctimer<span style="color: #009900;">&#40;</span><span style="color: #993333;">unsigned</span> <span style="color: #993333;">char</span> <span style="color: #339933;">*</span>in<span style="color: #339933;">,</span> <span style="color: #993333;">int</span> length<span style="color: #009900;">&#41;</span>
<span style="color: #009900;">&#123;</span>
<span style="color: #993333;">int</span> i<span style="color: #339933;">,</span> d<span style="color: #339933;">,</span> s<span style="color: #339933;">;</span>
d <span style="color: #339933;">=</span> s <span style="color: #339933;">=</span> <span style="color: #0000dd;">0</span><span style="color: #339933;">;</span>
&nbsp;
    <span style="color: #b1b100;">for</span><span style="color: #009900;">&#40;</span>i<span style="color: #339933;">=</span>length<span style="color: #339933;">;</span>i<span style="color: #339933;">&gt;</span><span style="color: #0000dd;">0</span><span style="color: #339933;">;</span>i<span style="color: #339933;">--</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#123;</span>
      <span style="color: #b1b100;">if</span><span style="color: #009900;">&#40;</span>i<span style="color: #339933;">&gt;</span><span style="color: #0000dd;">4</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#123;</span>
        d <span style="color: #339933;">=</span> in<span style="color: #009900;">&#91;</span>i<span style="color: #339933;">-</span><span style="color: #0000dd;">1</span><span style="color: #009900;">&#93;</span> <span style="color: #339933;">*</span> pow<span style="color: #009900;">&#40;</span><span style="color: #0000dd;">16</span><span style="color: #339933;">,</span><span style="color: #009900;">&#40;</span>i<span style="color: #339933;">-</span><span style="color: #0000dd;">5</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">*</span><span style="color: #0000dd;">2</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
        <span style="color: #666666; font-style: italic;">//printf(&quot;%02x %d\n&quot;, in[i-1], d);</span>
        s <span style="color: #339933;">=</span> s <span style="color: #339933;">+</span> d<span style="color: #339933;">;</span>
        <span style="color: #009900;">&#125;</span>
    <span style="color: #009900;">&#125;</span>
    <span style="color: #b1b100;">return</span> s<span style="color: #339933;">;</span>
<span style="color: #009900;">&#125;</span></pre></td></tr></table></div>

<p>あとは、出力内容を上記関数にいれかえ、printfで整形。</p>
<p>math.hを使うとコンパイルでエラーが出るのでMakefileの記述-lmオプション追加。無事コンパイル完了。</p>
<p>usbgeiger -cとすると「118037,479109」のように返すことができるようになりました。crontabで/usr/local/bin/usbgeiger -c &gt;&gt;/var/www/html/data/count.txtとして、5分ごとのログを残しています(このサーバではないです)。</p>
<p>これをcactiでグラフ化しました。PHPでログファイルを開き、5分間で増加したカウントから導いたCPMと変換係数を120とした参考uSvを表示するようにしました。</p>
<p>カウント、タイマー、それぞれ最終行とその前の行との差をもって算出していますが、再起動後は最終行とその前の行の数字のつながりがおかしくなると思うのでそこだけ条件分岐させています。</p>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
</pre></td><td class="code"><pre class="php" style="font-family:monospace;"><span style="color: #000000; font-weight: bold;">&lt;?php</span>
<span style="color: #990000;">mb_internal_encoding</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;UTF-8&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
<span style="color: #666666; font-style: italic;">//ログファイル指定</span>
<span style="color: #000088;">$datafile</span> <span style="color: #339933;">=</span> <span style="color: #0000ff;">&quot;/var/www/html/hoge/counter.txt&quot;</span><span style="color: #339933;">;</span>
<span style="color: #000088;">$t_file</span> <span style="color: #339933;">=</span> <span style="color: #990000;">file_get_contents</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$datafile</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
<span style="color: #666666; font-style: italic;">//係数</span>
<span style="color: #000088;">$lnd712</span> <span style="color: #339933;">=</span> <span style="color: #cc66cc;">120</span><span style="color: #339933;">;</span>
&nbsp;
<span style="color: #000088;">$rows</span> <span style="color: #339933;">=</span> <span style="color: #990000;">explode</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;<span style="color: #000099; font-weight: bold;">\n</span>&quot;</span><span style="color: #339933;">,</span> <span style="color: #000088;">$t_file</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #000088;">$cols</span> <span style="color: #339933;">=</span> <span style="color: #990000;">explode</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;,&quot;</span><span style="color: #339933;">,</span> <span style="color: #000088;">$t_file</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #000088;">$csv_arr</span> <span style="color: #339933;">=</span> <span style="color: #990000;">array_map</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;str_getcsv&quot;</span><span style="color: #339933;">,</span> <span style="color: #000088;">$rows</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #000088;">$row_c</span> <span style="color: #339933;">=</span> <span style="color: #990000;">count</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$csv_arr</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
<span style="color: #666666; font-style: italic;">//最終行</span>
<span style="color: #000088;">$last_1c</span> <span style="color: #339933;">=</span> <span style="color: #000088;">$csv_arr</span><span style="color: #009900;">&#91;</span><span style="color: #000088;">$row_c</span><span style="color: #339933;">-</span><span style="color: #cc66cc;">2</span><span style="color: #009900;">&#93;</span><span style="color: #009900;">&#91;</span><span style="color: #cc66cc;">0</span><span style="color: #009900;">&#93;</span><span style="color: #339933;">;</span>
<span style="color: #000088;">$last_1t</span> <span style="color: #339933;">=</span> <span style="color: #000088;">$csv_arr</span><span style="color: #009900;">&#91;</span><span style="color: #000088;">$row_c</span><span style="color: #339933;">-</span><span style="color: #cc66cc;">2</span><span style="color: #009900;">&#93;</span><span style="color: #009900;">&#91;</span><span style="color: #cc66cc;">1</span><span style="color: #009900;">&#93;</span><span style="color: #339933;">;</span>
&nbsp;
<span style="color: #666666; font-style: italic;">//最終行の前の行</span>
<span style="color: #000088;">$last_2c</span> <span style="color: #339933;">=</span> <span style="color: #000088;">$csv_arr</span><span style="color: #009900;">&#91;</span><span style="color: #000088;">$row_c</span><span style="color: #339933;">-</span><span style="color: #cc66cc;">3</span><span style="color: #009900;">&#93;</span><span style="color: #009900;">&#91;</span><span style="color: #cc66cc;">0</span><span style="color: #009900;">&#93;</span><span style="color: #339933;">;</span>
<span style="color: #000088;">$last_2t</span> <span style="color: #339933;">=</span> <span style="color: #000088;">$csv_arr</span><span style="color: #009900;">&#91;</span><span style="color: #000088;">$row_c</span><span style="color: #339933;">-</span><span style="color: #cc66cc;">3</span><span style="color: #009900;">&#93;</span><span style="color: #009900;">&#91;</span><span style="color: #cc66cc;">1</span><span style="color: #009900;">&#93;</span><span style="color: #339933;">;</span>
&nbsp;
<span style="color: #666666; font-style: italic;">//最終行の前の前の行</span>
<span style="color: #000088;">$last_3c</span> <span style="color: #339933;">=</span> <span style="color: #000088;">$csv_arr</span><span style="color: #009900;">&#91;</span><span style="color: #000088;">$row_c</span><span style="color: #339933;">-</span><span style="color: #cc66cc;">4</span><span style="color: #009900;">&#93;</span><span style="color: #009900;">&#91;</span><span style="color: #cc66cc;">0</span><span style="color: #009900;">&#93;</span><span style="color: #339933;">;</span>
<span style="color: #000088;">$last_3t</span> <span style="color: #339933;">=</span> <span style="color: #000088;">$csv_arr</span><span style="color: #009900;">&#91;</span><span style="color: #000088;">$row_c</span><span style="color: #339933;">-</span><span style="color: #cc66cc;">4</span><span style="color: #009900;">&#93;</span><span style="color: #009900;">&#91;</span><span style="color: #cc66cc;">1</span><span style="color: #009900;">&#93;</span><span style="color: #339933;">;</span>
&nbsp;
<span style="color: #666666; font-style: italic;">//最終行の前の行と最終行との差</span>
<span style="color: #000088;">$count_1_2</span> <span style="color: #339933;">=</span> <span style="color: #000088;">$last_1c</span> <span style="color: #339933;">-</span> <span style="color: #000088;">$last_2c</span><span style="color: #339933;">;</span>
<span style="color: #000088;">$timer_1_2</span> <span style="color: #339933;">=</span> <span style="color: #000088;">$last_1t</span> <span style="color: #339933;">-</span> <span style="color: #000088;">$last_2t</span><span style="color: #339933;">;</span>
&nbsp;
<span style="color: #666666; font-style: italic;">//最終行は無視し、その一つ前の組み合わせ。</span>
<span style="color: #000088;">$count_2_3</span> <span style="color: #339933;">=</span> <span style="color: #000088;">$last_2c</span> <span style="color: #339933;">-</span> <span style="color: #000088;">$last_3c</span><span style="color: #339933;">;</span>
<span style="color: #000088;">$timer_2_3</span> <span style="color: #339933;">=</span> <span style="color: #000088;">$last_2t</span> <span style="color: #339933;">-</span> <span style="color: #000088;">$last_3t</span><span style="color: #339933;">;</span>
&nbsp;
<span style="color: #666666; font-style: italic;">//CPMとuSvを計算。</span>
<span style="color: #666666; font-style: italic;">//最起動直後のデータは無視する</span>
<span style="color: #b1b100;">if</span> <span style="color: #009900;">&#40;</span><span style="color: #000088;">$count_1_2</span><span style="color: #339933;">&gt;</span><span style="color: #cc66cc;">0</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
  <span style="color: #000088;">$counter</span> <span style="color: #339933;">=</span> <span style="color: #000088;">$last_1c</span><span style="color: #339933;">;</span>
  <span style="color: #000088;">$timer</span> <span style="color: #339933;">=</span> <span style="color: #000088;">$last_1t</span><span style="color: #339933;">;</span>
  <span style="color: #000088;">$cpm</span> <span style="color: #339933;">=</span> <span style="color: #000088;">$count_1_2</span> <span style="color: #339933;">/</span> <span style="color: #000088;">$timer_1_2</span> <span style="color: #339933;">*</span> <span style="color: #cc66cc;">60</span><span style="color: #339933;">;</span>
  <span style="color: #000088;">$usv</span> <span style="color: #339933;">=</span> <span style="color: #000088;">$cpm</span> <span style="color: #339933;">/</span> <span style="color: #000088;">$lnd712</span><span style="color: #339933;">;</span>
 <span style="color: #009900;">&#125;</span> <span style="color: #b1b100;">else</span> <span style="color: #009900;">&#123;</span>
  <span style="color: #000088;">$counter</span> <span style="color: #339933;">=</span> <span style="color: #000088;">$last_2c</span><span style="color: #339933;">;</span>
  <span style="color: #000088;">$timer</span> <span style="color: #339933;">=</span> <span style="color: #000088;">$last_2t</span><span style="color: #339933;">;</span>
  <span style="color: #000088;">$cpm</span> <span style="color: #339933;">=</span> <span style="color: #000088;">$count_2_3</span> <span style="color: #339933;">/</span> <span style="color: #000088;">$timer_2_3</span> <span style="color: #339933;">*</span> <span style="color: #cc66cc;">60</span><span style="color: #339933;">;</span>
  <span style="color: #000088;">$usv</span> <span style="color: #339933;">=</span> <span style="color: #000088;">$cpm</span> <span style="color: #339933;">/</span> <span style="color: #000088;">$lnd712</span><span style="color: #339933;">;</span>
 <span style="color: #009900;">&#125;</span>
&nbsp;
<span style="color: #990000;">printf</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;counter:<span style="color: #009933; font-weight: bold;">%d</span> timer:<span style="color: #009933; font-weight: bold;">%d</span> cpm:<span style="color: #009933; font-weight: bold;">%d</span> usv:%.3g&quot;</span><span style="color: #339933;">,</span> <span style="color: #000088;">$counter</span><span style="color: #339933;">,</span> <span style="color: #000088;">$timer</span><span style="color: #339933;">,</span> <span style="color: #000088;">$cpm</span><span style="color: #339933;">,</span> <span style="color: #000088;">$usv</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
<span style="color: #000000; font-weight: bold;">?&gt;</span></pre></td></tr></table></div>

<p>最後にusbrh-0.05.tar.gz[25-Mar-2008]との差分も載せておきます。<br />
ベタベタコードですいません。</p>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
</pre></td><td class="code"><pre class="diff" style="font-family:monospace;"><span style="color: #440088;">@@ -24,45 +24,10 @@</span>
 #include &lt;usb.h&gt;
 #include &lt;unistd.h&gt;
 #include &lt;string.h&gt;
<span style="color: #00b000;">+#include &lt;math.h&gt;</span>
&nbsp;
<span style="color: #991111;">-#define USBRH_VENDOR  0x1774</span>
<span style="color: #991111;">-#define USBRH_PRODUCT 0x1001</span>
<span style="color: #991111;">-</span>
<span style="color: #991111;">-// parameter</span>
<span style="color: #991111;">-// http://www.sensirion.com/en/pdf/product_information/Data_Sheet_humidity_sensor_SHT1x_SHT7x_E.pdf</span>
<span style="color: #991111;">-// http://www.syscom-inc.co.jp/pdf/sht_datasheet_j.pdf</span>
<span style="color: #991111;">-#define d1 -40.00</span>
<span style="color: #991111;">-#define d2 0.01</span>
<span style="color: #991111;">-#define c1 -4</span>
<span style="color: #991111;">-#define c2 0.0405</span>
<span style="color: #991111;">-#define c3 -0.0000028</span>
<span style="color: #991111;">-#define t1 0.01</span>
<span style="color: #991111;">-#define t2 0.00008</span>
<span style="color: #991111;">-</span>
<span style="color: #991111;">-// Temperature = d1+d2*SOt</span>
<span style="color: #991111;">-// d1  -40.00</span>
<span style="color: #991111;">-// d2  0.04</span>
<span style="color: #991111;">-double convert_temp<span style="">&#40;</span>int in<span style="">&#41;</span></span>
<span style="color: #991111;">-<span style="">&#123;</span></span>
<span style="color: #991111;">-double tmp;</span>
<span style="color: #991111;">-</span>
<span style="color: #991111;">-    tmp = <span style="">0</span>;</span>
<span style="color: #991111;">-</span>
<span style="color: #991111;">-    tmp = d1+d2*in;</span>
<span style="color: #991111;">-</span>
<span style="color: #991111;">-    return<span style="">&#40;</span>tmp<span style="">&#41;</span>;</span>
<span style="color: #991111;">-<span style="">&#125;</span></span>
<span style="color: #991111;">-</span>
<span style="color: #991111;">-double convert_humidity<span style="">&#40;</span>int in<span style="">&#41;</span></span>
<span style="color: #991111;">-<span style="">&#123;</span></span>
<span style="color: #991111;">-double tmp;</span>
<span style="color: #991111;">-</span>
<span style="color: #991111;">-    tmp = <span style="">0</span>;</span>
<span style="color: #991111;">-</span>
<span style="color: #991111;">-    tmp = c1+c2*in+c3*<span style="">&#40;</span>in*in<span style="">&#41;</span>;</span>
<span style="color: #991111;">-</span>
<span style="color: #991111;">-    return<span style="">&#40;</span><span style="">&#40;</span>t1-<span style="">25</span><span style="">&#41;</span>*<span style="">&#40;</span>t1+t2*in<span style="">&#41;</span>+tmp<span style="">&#41;</span>;</span>
<span style="color: #991111;">-<span style="">&#125;</span></span>
<span style="color: #00b000;">+#define USBGEIGER_VENDOR  0x1774</span>
<span style="color: #00b000;">+#define USBGEIGER_PRODUCT 0x1002</span>
&nbsp;
 void dump<span style="">&#40;</span>unsigned char *in, int length<span style="">&#41;</span>
 <span style="">&#123;</span>
<span style="color: #440088;">@@ -82,6 +47,34 @@</span>
&nbsp;
 <span style="">&#125;</span>
&nbsp;
<span style="color: #00b000;">+int calccount<span style="">&#40;</span>unsigned char *in, int length<span style="">&#41;</span></span>
<span style="color: #00b000;">+<span style="">&#123;</span></span>
<span style="color: #00b000;">+int i, d, s;</span>
<span style="color: #00b000;">+d = s = <span style="">0</span>;</span>
<span style="color: #00b000;">+</span>
<span style="color: #00b000;">+    for<span style="">&#40;</span>i=length;i&gt;<span style="">0</span>;i--<span style="">&#41;</span><span style="">&#123;</span></span>
<span style="color: #00b000;">+      if<span style="">&#40;</span>i&lt;5<span style="">&#41;</span><span style="">&#123;</span></span>
<span style="color: #00b000;">+       d = in<span style="">&#91;</span>i-<span style="">1</span><span style="">&#93;</span> * pow<span style="">&#40;</span><span style="">16</span>,<span style="">&#40;</span>i-<span style="">1</span><span style="">&#41;</span>*<span style="">2</span><span style="">&#41;</span>;</span>
<span style="color: #00b000;">+       s = s + d;</span>
<span style="color: #00b000;">+        <span style="">&#125;</span></span>
<span style="color: #00b000;">+    <span style="">&#125;</span></span>
<span style="color: #00b000;">+    return s;</span>
<span style="color: #00b000;">+<span style="">&#125;</span></span>
<span style="color: #00b000;">+</span>
<span style="color: #00b000;">+int calctimer<span style="">&#40;</span>unsigned char *in, int length<span style="">&#41;</span></span>
<span style="color: #00b000;">+<span style="">&#123;</span></span>
<span style="color: #00b000;">+int i, d, s;</span>
<span style="color: #00b000;">+d = s = <span style="">0</span>;</span>
<span style="color: #00b000;">+</span>
<span style="color: #00b000;">+    for<span style="">&#40;</span>i=length;i&gt;<span style="">0</span>;i--<span style="">&#41;</span><span style="">&#123;</span></span>
<span style="color: #00b000;">+      if<span style="">&#40;</span>i&gt;4<span style="">&#41;</span><span style="">&#123;</span></span>
<span style="color: #00b000;">+       d = in<span style="">&#91;</span>i-<span style="">1</span><span style="">&#93;</span> * pow<span style="">&#40;</span><span style="">16</span>,<span style="">&#40;</span>i-<span style="">5</span><span style="">&#41;</span>*<span style="">2</span><span style="">&#41;</span>;</span>
<span style="color: #00b000;">+       s = s + d;</span>
<span style="color: #00b000;">+        <span style="">&#125;</span></span>
<span style="color: #00b000;">+    <span style="">&#125;</span></span>
<span style="color: #00b000;">+    return s;</span>
<span style="color: #00b000;">+<span style="">&#125;</span></span>
<span style="color: #00b000;">+</span>
 struct usb_device *searchdevice<span style="">&#40;</span>unsigned int vendor, unsigned int product, int num<span style="">&#41;</span>
 <span style="">&#123;</span>
 struct usb_bus *bus;
<span style="color: #440088;">@@ -113,7 +106,7 @@</span>
&nbsp;
     count=<span style="">0</span>;
&nbsp;
<span style="color: #991111;">-    puts<span style="">&#40;</span>&quot;listing:USBRH&quot;<span style="">&#41;</span>;</span>
<span style="color: #00b000;">+    puts<span style="">&#40;</span>&quot;listing:USBGEIGER&quot;<span style="">&#41;</span>;</span>
&nbsp;
     for <span style="">&#40;</span>bus = usb_get_busses<span style="">&#40;</span><span style="">&#41;</span>; bus; bus = bus-&gt;next<span style="">&#41;</span><span style="">&#123;</span>
         for <span style="">&#40;</span>dev = bus-&gt;devices; dev; dev = dev-&gt;next<span style="">&#41;</span><span style="">&#123;</span>
<span style="color: #440088;">@@ -132,14 +125,16 @@</span>
&nbsp;
 void usage<span style="">&#40;</span><span style="">&#41;</span>
 <span style="">&#123;</span>
<span style="color: #991111;">-    puts<span style="">&#40;</span>&quot;USBRH on Linux 0.05 by Briareos\nusage: usbrh <span style="">&#91;</span>-vthm1fl<span style="">&#93;</span>\n&quot;</span>
<span style="color: #00b000;">+    puts<span style="">&#40;</span>&quot;USBGEIGER on Linux 0.00 by Masaki Kamimura\n<span style="">&#40;</span>originally published as USBRH on Linux by Mr. Briareos<span style="">&#41;</span>\n\nusage: usbgeiger <span style="">&#91;</span>-vthm1cfls<span style="">&#93;</span>\n&quot;</span>
          &quot;       -v : verbose\n&quot;
<span style="color: #991111;">-         &quot;       -t : temperature <span style="">&#40;</span>for MRTG2<span style="">&#41;</span>\n&quot;</span>
<span style="color: #991111;">-         &quot;       -h : humidity <span style="">&#40;</span>for MRTG2<span style="">&#41;</span>\n&quot;</span>
<span style="color: #991111;">-         &quot;       -m : temperature/humidity output<span style="">&#40;</span>for MRTG2<span style="">&#41;</span>\n&quot;</span>
<span style="color: #00b000;">+         &quot;       -t : counter <span style="">&#40;</span>for MRTG2<span style="">&#41;</span>\n&quot;</span>
<span style="color: #00b000;">+         &quot;       -h : timer <span style="">&#40;</span>for MRTG2<span style="">&#41;</span>\n&quot;</span>
<span style="color: #00b000;">+         &quot;       -m : counter/timer output<span style="">&#40;</span>for MRTG2<span style="">&#41;</span>\n&quot;</span>
          &quot;       -<span style="">1</span> : <span style="">1</span>-line output\n&quot;
<span style="color: #00b000;">+         &quot;       -c : csv\n&quot;</span>
          &quot;       -fn: set device number<span style="">&#40;</span>n&gt;<span style="">0</span><span style="">&#41;</span>\n&quot;
<span style="color: #991111;">-         &quot;       -l : Device list\n&quot; <span style="">&#41;</span>;</span>
<span style="color: #00b000;">+         &quot;       -l : Device list\n&quot;</span>
<span style="color: #00b000;">+         &quot;       -sn: set sleep duration in n msec <span style="">&#40;</span>default: 100ms<span style="">&#41;</span>\n&quot; <span style="">&#41;</span>;</span>
 <span style="">&#125;</span>
&nbsp;
 int main<span style="">&#40;</span>int argc, char *argv<span style="">&#91;</span><span style="">&#93;</span><span style="">&#41;</span>
<span style="color: #440088;">@@ -148,24 +143,26 @@</span>
 usb_dev_handle *dh;
 char buff<span style="">&#91;</span><span style="">512</span><span style="">&#93;</span>;
 int rc;
<span style="color: #991111;">-int iTemperature, iHumidity, opt;</span>
<span style="color: #991111;">-double temperature, humidity;</span>
<span style="color: #00b000;">+int opt;</span>
<span style="color: #00b000;">+int iCounter, iTimer;</span>
 unsigned char data<span style="">&#91;</span><span style="">8</span><span style="">&#93;</span>;
<span style="color: #991111;">-char flag_v, flag_t, flag_h, flag_d, flag_f, flag_1line, flag_mrtg, flag_l;</span>
<span style="color: #00b000;">+char flag_v, flag_t, flag_h, flag_d, flag_f, flag_1line, flag_mrtg, flag_l, flag_c;</span>
 char tmpDevice<span style="">&#91;</span><span style="">8</span><span style="">&#93;</span>;
 int  DeviceNum;
<span style="color: #00b000;">+unsigned long sleep_usec;</span>
&nbsp;
     dev = NULL;
     dh = NULL;
     rc = <span style="">0</span>;
     DeviceNum = <span style="">1</span>;
<span style="color: #991111;">-    flag_f = flag_v = flag_t = flag_h = flag_d = flag_1line = flag_mrtg = flag_l = <span style="">0</span>;</span>
<span style="color: #991111;">-    temperature = humidity = <span style="">0</span>;</span>
<span style="color: #00b000;">+    flag_f = flag_v = flag_t = flag_h = flag_d = flag_1line = flag_mrtg = flag_l = flag_c = <span style="">0</span>;</span>
<span style="color: #00b000;">+    counter = timer = <span style="">0</span>;</span>
<span style="color: #00b000;">+    sleep_usec = <span style="">1000</span> * <span style="">1000</span>;</span>
     memset<span style="">&#40;</span>buff, <span style="">0</span>, sizeof<span style="">&#40;</span>buff<span style="">&#41;</span><span style="">&#41;</span>;
     memset<span style="">&#40;</span>data, <span style="">0</span>, sizeof<span style="">&#40;</span>data<span style="">&#41;</span><span style="">&#41;</span>;
     memset<span style="">&#40;</span>tmpDevice, <span style="">0</span>, sizeof<span style="">&#40;</span>tmpDevice<span style="">&#41;</span><span style="">&#41;</span>;
&nbsp;
<span style="color: #991111;">-    while<span style="">&#40;</span><span style="">&#40;</span>opt = getopt<span style="">&#40;</span>argc, argv,&quot;lvth1dmf:?&quot;<span style="">&#41;</span><span style="">&#41;</span> != -1<span style="">&#41;</span><span style="">&#123;</span></span>
<span style="color: #00b000;">+    while<span style="">&#40;</span><span style="">&#40;</span>opt = getopt<span style="">&#40;</span>argc, argv,&quot;lcvth1dmf:s:?&quot;<span style="">&#41;</span><span style="">&#41;</span> != -1<span style="">&#41;</span><span style="">&#123;</span></span>
         switch<span style="">&#40;</span>opt<span style="">&#41;</span><span style="">&#123;</span>
             case 'v':
                 flag_v = <span style="">1</span>;
<span style="color: #440088;">@@ -196,6 +193,12 @@</span>
             case 'l':
                 flag_l = <span style="">1</span>;
                 break;
<span style="color: #00b000;">+           case 's':</span>
<span style="color: #00b000;">+               sleep_usec = atoi<span style="">&#40;</span>optarg<span style="">&#41;</span> * <span style="">1000</span>;</span>
<span style="color: #00b000;">+               break;</span>
<span style="color: #00b000;">+           case 'c':</span>
<span style="color: #00b000;">+               flag_c = <span style="">1</span>;</span>
<span style="color: #00b000;">+               break;</span>
             default:
                 usage<span style="">&#40;</span><span style="">&#41;</span>;
                 exit<span style="">&#40;</span><span style="">0</span><span style="">&#41;</span>;
<span style="color: #440088;">@@ -208,20 +211,20 @@</span>
     usb_find_devices<span style="">&#40;</span><span style="">&#41;</span>;
&nbsp;
     if<span style="">&#40;</span>flag_l<span style="">&#41;</span><span style="">&#123;</span>
<span style="color: #991111;">-        listdevice<span style="">&#40;</span>USBRH_VENDOR, USBRH_PRODUCT<span style="">&#41;</span>;</span>
<span style="color: #00b000;">+        listdevice<span style="">&#40;</span>USBGEIGER_VENDOR, USBGEIGER_PRODUCT<span style="">&#41;</span>;</span>
         exit<span style="">&#40;</span><span style="">0</span><span style="">&#41;</span>;
     <span style="">&#125;</span>
&nbsp;
     if<span style="">&#40;</span>flag_d<span style="">&#41;</span>
         usb_set_debug<span style="">&#40;</span><span style="">5</span><span style="">&#41;</span>;
&nbsp;
<span style="color: #991111;">-    if<span style="">&#40;</span><span style="">&#40;</span>dev = searchdevice<span style="">&#40;</span>USBRH_VENDOR, USBRH_PRODUCT, DeviceNum<span style="">&#41;</span><span style="">&#41;</span> == <span style="">&#40;</span>struct usb_device *<span style="">&#41;</span>NULL<span style="">&#41;</span><span style="">&#123;</span></span>
<span style="color: #991111;">-        puts<span style="">&#40;</span>&quot;USBRH not found&quot;<span style="">&#41;</span>;</span>
<span style="color: #00b000;">+    if<span style="">&#40;</span><span style="">&#40;</span>dev = searchdevice<span style="">&#40;</span>USBGEIGER_VENDOR, USBGEIGER_PRODUCT, DeviceNum<span style="">&#41;</span><span style="">&#41;</span> == <span style="">&#40;</span>struct usb_device *<span style="">&#41;</span>NULL<span style="">&#41;</span><span style="">&#123;</span></span>
<span style="color: #00b000;">+        puts<span style="">&#40;</span>&quot;USBGEIGER not found&quot;<span style="">&#41;</span>;</span>
         exit<span style="">&#40;</span><span style="">1</span><span style="">&#41;</span>;
     <span style="">&#125;</span>
&nbsp;
     if<span style="">&#40;</span>flag_d<span style="">&#41;</span><span style="">&#123;</span>
<span style="color: #991111;">-        puts<span style="">&#40;</span>&quot;USBRH is found&quot;<span style="">&#41;</span>;</span>
<span style="color: #00b000;">+        puts<span style="">&#40;</span>&quot;USBGEIGER is found&quot;<span style="">&#41;</span>;</span>
     <span style="">&#125;</span>
     dh = usb_open<span style="">&#40;</span>dev<span style="">&#41;</span>;
     if<span style="">&#40;</span>dh == NULL<span style="">&#41;</span><span style="">&#123;</span>
<span style="color: #440088;">@@ -230,15 +233,21 @@</span>
     <span style="">&#125;</span>
&nbsp;
     if<span style="">&#40;</span><span style="">&#40;</span>rc = usb_set_configuration<span style="">&#40;</span>dh, dev-&gt;config-&gt;bConfigurationValue<span style="">&#41;</span><span style="">&#41;</span>&lt;<span style="">0</span><span style="">&#41;</span><span style="">&#123;</span>
<span style="color: #991111;">-        puts<span style="">&#40;</span>&quot;usb_set_configuration error&quot;<span style="">&#41;</span>;</span>
<span style="color: #991111;">-        usb_close<span style="">&#40;</span>dh<span style="">&#41;</span>;</span>
<span style="color: #991111;">-        exit<span style="">&#40;</span><span style="">3</span><span style="">&#41;</span>;</span>
<span style="color: #991111;">-    <span style="">&#125;</span></span>
<span style="color: #991111;">-</span>
<span style="color: #00b000;">+      if<span style="">&#40;</span><span style="">&#40;</span>rc = usb_detach_kernel_driver_np<span style="">&#40;</span>dh, dev-&gt;config-&gt;interface-&gt;altsetting-&gt;bInterfaceNumber<span style="">&#41;</span><span style="">&#41;</span>&lt;0<span style="">&#41;</span><span style="">&#123;</span></span>
<span style="color: #00b000;">+       printf<span style="">&#40;</span>&quot;usb_detach_kernel_driver_np error: %s\n&quot;, usb_strerror<span style="">&#40;</span><span style="">&#41;</span><span style="">&#41;</span>;</span>
<span style="color: #00b000;">+       usb_close<span style="">&#40;</span>dh<span style="">&#41;</span>;</span>
<span style="color: #00b000;">+       exit<span style="">&#40;</span><span style="">3</span><span style="">&#41;</span>;</span>
<span style="color: #00b000;">+      <span style="">&#125;</span>else<span style="">&#123;</span></span>
<span style="color: #00b000;">+       if<span style="">&#40;</span><span style="">&#40;</span>rc =usb_set_configuration<span style="">&#40;</span>dh, dev-&gt;config-&gt;bConfigurationValue<span style="">&#41;</span><span style="">&#41;</span>&lt;0<span style="">&#41;</span><span style="">&#123;</span></span>
<span style="color: #00b000;">+         printf<span style="">&#40;</span>&quot;usb_set_configuration error: %s\n&quot;, usb_strerror<span style="">&#40;</span><span style="">&#41;</span><span style="">&#41;</span>;</span>
<span style="color: #00b000;">+         usb_close<span style="">&#40;</span>dh<span style="">&#41;</span>;</span>
<span style="color: #00b000;">+         exit<span style="">&#40;</span><span style="">3</span><span style="">&#41;</span>;</span>
<span style="color: #00b000;">+       <span style="">&#125;</span></span>
<span style="color: #00b000;">+      <span style="">&#125;</span></span>
<span style="color: #00b000;">+   <span style="">&#125;</span></span>
     if<span style="">&#40;</span><span style="">&#40;</span>rc =usb_claim_interface<span style="">&#40;</span>dh, dev-&gt;config-&gt;interface-&gt;altsetting-&gt;bInterfaceNumber<span style="">&#41;</span><span style="">&#41;</span>&lt;<span style="">0</span><span style="">&#41;</span><span style="">&#123;</span>
<span style="color: #991111;">-        //puts<span style="">&#40;</span>&quot;usb_claim_interface error&quot;<span style="">&#41;</span>;</span>
         if<span style="">&#40;</span><span style="">&#40;</span>rc = usb_detach_kernel_driver_np<span style="">&#40;</span>dh, dev-&gt;config-&gt;interface-&gt;altsetting-&gt;bInterfaceNumber<span style="">&#41;</span><span style="">&#41;</span>&lt;<span style="">0</span><span style="">&#41;</span><span style="">&#123;</span>
<span style="color: #991111;">-            puts<span style="">&#40;</span>&quot;usb_detach_kernel_driver_np error&quot;<span style="">&#41;</span>;</span>
<span style="color: #00b000;">+           printf<span style="">&#40;</span>&quot;usb_detach_kernel_driver_np error: %s\n&quot;, usb_strerror<span style="">&#40;</span><span style="">&#41;</span><span style="">&#41;</span>;</span>
             usb_close<span style="">&#40;</span>dh<span style="">&#41;</span>;
             exit<span style="">&#40;</span><span style="">4</span><span style="">&#41;</span>;
         <span style="">&#125;</span>else<span style="">&#123;</span>
<span style="color: #440088;">@@ -266,47 +275,50 @@</span>
&nbsp;
     // usb_control_msg<span style="">&#40;</span><span style="">&#41;</span> is successed
     if<span style="">&#40;</span>rc&gt;=<span style="">0</span><span style="">&#41;</span><span style="">&#123;</span>
<span style="color: #991111;">-        sleep<span style="">&#40;</span><span style="">1</span><span style="">&#41;</span>;</span>
<span style="color: #00b000;">+        usleep<span style="">&#40;</span>sleep_usec<span style="">&#41;</span>;</span>
&nbsp;
         // Read data from device
<span style="color: #991111;">-        rc = usb_bulk_read<span style="">&#40;</span>dh, <span style="">1</span>, buff, <span style="">7</span>, <span style="">5000</span><span style="">&#41;</span>;</span>
<span style="color: #00b000;">+       rc = usb_bulk_read<span style="">&#40;</span>dh, <span style="">1</span>, buff, <span style="">7</span>, <span style="">5000</span><span style="">&#41;</span>;</span>
         if<span style="">&#40;</span>flag_d<span style="">&#41;</span><span style="">&#123;</span>
             if<span style="">&#40;</span>rc&lt;<span style="">0</span><span style="">&#41;</span><span style="">&#123;</span>
                 puts<span style="">&#40;</span>&quot;usb_bulk_read error&quot;<span style="">&#41;</span>;
             <span style="">&#125;</span> else <span style="">&#123;</span>
<span style="color: #991111;">-                printf<span style="">&#40;</span>&quot;usb_bulk_read:<span style="">&#91;</span>%d<span style="">&#93;</span> bytes readed.\n&quot;, rc<span style="">&#41;</span>;</span>
<span style="color: #00b000;">+                printf<span style="">&#40;</span>&quot;usb_bulk_read:<span style="">&#91;</span>%d<span style="">&#93;</span> bytes read.\n&quot;, rc<span style="">&#41;</span>;</span>
                 dump<span style="">&#40;</span>buff, rc<span style="">&#41;</span>;
             <span style="">&#125;</span>
         <span style="">&#125;</span>
<span style="color: #00b000;">+</span>
<span style="color: #00b000;">+       iCounter = calccount<span style="">&#40;</span>buff, rc<span style="">&#41;</span>;</span>
<span style="color: #00b000;">+       iTimer = calctimer<span style="">&#40;</span>buff,rc<span style="">&#41;</span>;</span>
&nbsp;
<span style="color: #991111;">-        iTemperature = buff<span style="">&#91;</span><span style="">2</span><span style="">&#93;</span>&lt;&lt;<span style="">8</span>|<span style="">&#40;</span>buff<span style="">&#91;</span><span style="">3</span><span style="">&#93;</span>&amp;0xff<span style="">&#41;</span>;</span>
<span style="color: #991111;">-        iHumidity = buff<span style="">&#91;</span><span style="">0</span><span style="">&#93;</span>&lt;&lt;<span style="">8</span>|<span style="">&#40;</span>buff<span style="">&#91;</span><span style="">1</span><span style="">&#93;</span>&amp;0xff<span style="">&#41;</span>;</span>
         if<span style="">&#40;</span>flag_d<span style="">&#41;</span><span style="">&#123;</span>
<span style="color: #991111;">-            printf<span style="">&#40;</span>&quot;convert to integer<span style="">&#40;</span>temperature<span style="">&#41;</span>:<span style="">&#91;</span>%02x %02x<span style="">&#93;</span> -&gt; <span style="">&#91;</span>%04x<span style="">&#93;</span>\n&quot;, buff<span style="">&#91;</span><span style="">2</span><span style="">&#93;</span>, buff<span style="">&#91;</span><span style="">3</span><span style="">&#93;</span>, iTemperature<span style="">&#41;</span>;</span>
<span style="color: #991111;">-            printf<span style="">&#40;</span>&quot;convert to integer<span style="">&#40;</span>humidity<span style="">&#41;</span>:<span style="">&#91;</span>%02x %02x<span style="">&#93;</span> -&gt; <span style="">&#91;</span>%04x<span style="">&#93;</span>\n&quot;, buff<span style="">&#91;</span><span style="">0</span><span style="">&#93;</span>, buff<span style="">&#91;</span><span style="">1</span><span style="">&#93;</span>, iHumidity<span style="">&#41;</span>;</span>
<span style="color: #00b000;">+</span>
<span style="color: #00b000;">+          printf<span style="">&#40;</span>&quot;Counter: %d\n&quot;, iCounter<span style="">&#41;</span>;</span>
<span style="color: #00b000;">+         printf<span style="">&#40;</span>&quot;Timer: %d\n&quot;, iTimer<span style="">&#41;</span>;</span>
         <span style="">&#125;</span>
<span style="color: #991111;">-        temperature = convert_temp<span style="">&#40;</span>iTemperature<span style="">&#41;</span>;</span>
<span style="color: #991111;">-        humidity    = convert_humidity<span style="">&#40;</span>iHumidity<span style="">&#41;</span>;</span>
     <span style="">&#125;</span>
&nbsp;
     // Display Result
     if<span style="">&#40;</span>flag_v<span style="">&#41;</span><span style="">&#123;</span>
<span style="color: #991111;">-        printf<span style="">&#40;</span>&quot;Temperature: %.2f C\n&quot;, temperature<span style="">&#41;</span>;</span>
<span style="color: #991111;">-        printf<span style="">&#40;</span>&quot;Humidity: %.2f %\n&quot;, humidity<span style="">&#41;</span>;</span>
<span style="color: #00b000;">+        printf<span style="">&#40;</span>&quot;Counter: %d \n&quot;, iCounter<span style="">&#41;</span>;</span>
<span style="color: #00b000;">+        printf<span style="">&#40;</span>&quot;Timer: %d \n&quot;, iTimer<span style="">&#41;</span>;</span>
     <span style="">&#125;</span>else
     if<span style="">&#40;</span>flag_t<span style="">&#41;</span><span style="">&#123;</span>
<span style="color: #991111;">-        printf<span style="">&#40;</span>&quot;%.2f\n%.2f\n\nTemperature\n&quot;, temperature, temperature<span style="">&#41;</span>;</span>
<span style="color: #00b000;">+        printf<span style="">&#40;</span>&quot;%d\n%d\n\nCounter\n&quot;, iCounter, iCounter<span style="">&#41;</span>;</span>
     <span style="">&#125;</span>else
     if<span style="">&#40;</span>flag_h<span style="">&#41;</span><span style="">&#123;</span>
<span style="color: #991111;">-        printf<span style="">&#40;</span>&quot;%.2f\n%.2f\n\nHumidity\n&quot;, humidity, humidity<span style="">&#41;</span>;</span>
<span style="color: #00b000;">+        printf<span style="">&#40;</span>&quot;%d\n%d\n\nTimer\n&quot;, iTimer, iTimer<span style="">&#41;</span>;</span>
     <span style="">&#125;</span>else
     if<span style="">&#40;</span>flag_mrtg<span style="">&#41;</span><span style="">&#123;</span>
<span style="color: #991111;">-        printf<span style="">&#40;</span>&quot;%.2f\n%.2f\n\nTemperature/Humidity\n&quot;, temperature, humidity<span style="">&#41;</span>;</span>
<span style="color: #00b000;">+        printf<span style="">&#40;</span>&quot;%d\n%d\n\nCounter/Timer\n&quot;, iCounter, iTimer<span style="">&#41;</span>;</span>
<span style="color: #00b000;">+    <span style="">&#125;</span>else</span>
<span style="color: #00b000;">+    if<span style="">&#40;</span>flag_c<span style="">&#41;</span><span style="">&#123;</span></span>
<span style="color: #00b000;">+        printf<span style="">&#40;</span>&quot;%d,%d\n&quot;, iCounter, iTimer<span style="">&#41;</span>;</span>
     <span style="">&#125;</span>else
     if<span style="">&#40;</span>flag_1line<span style="">&#41;</span><span style="">&#123;</span>
<span style="color: #991111;">-        printf<span style="">&#40;</span>&quot;Temperature: %.2f C Humidity: %.2f %%\n&quot;, temperature, humidity<span style="">&#41;</span>;</span>
<span style="color: #00b000;">+        printf<span style="">&#40;</span>&quot;Counter:%d Timer:%d \n&quot;, iCounter, iTimer<span style="">&#41;</span>;</span>
     <span style="">&#125;</span>else
<span style="color: #991111;">-        printf<span style="">&#40;</span>&quot;%.2f %.2f\n&quot;, temperature, humidity<span style="">&#41;</span>;</span>
<span style="color: #00b000;">+        printf<span style="">&#40;</span>&quot;%d %d\n&quot;, iCounter, iTimer<span style="">&#41;</span>;</span>
&nbsp;
     if<span style="">&#40;</span><span style="">&#40;</span>rc = usb_release_interface<span style="">&#40;</span>dh, dev-&gt;config-&gt;interface-&gt;altsetting-&gt;bInterfaceNumber<span style="">&#41;</span><span style="">&#41;</span>&lt;<span style="">0</span><span style="">&#41;</span><span style="">&#123;</span>
         puts<span style="">&#40;</span>&quot;usb_release_interface error&quot;<span style="">&#41;</span>;</pre></td></tr></table></div>

]]></content:encoded>
			<wfw:commentRss>http://www.boenkyo.com/archives/1353/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
	<xhtml:link rel="alternate" media="handheld" type="text/html" href="http://www.boenkyo.com/archives/1353" />
	</item>
		<item>
		<title>CentOS5.2でPT1を録画予約(Express 5800/110Ge)</title>
		<link>http://www.boenkyo.com/archives/1065</link>
		<comments>http://www.boenkyo.com/archives/1065#comments</comments>
		<pubDate>Sat, 21 Mar 2009 01:09:54 +0000</pubDate>
		<dc:creator>masaki</dc:creator>
				<category><![CDATA[自宅サーバ]]></category>
		<category><![CDATA[5800/110Ge]]></category>
		<category><![CDATA[CentOS5.2]]></category>
		<category><![CDATA[friio]]></category>
		<category><![CDATA[PT1]]></category>
		<category><![CDATA[recfriio]]></category>
		<category><![CDATA[recpt1]]></category>

		<guid isPermaLink="false">http://www.boenkyo.com/archives/1065</guid>
		<description><![CDATA[追記 下記の状態のままずっと稼働させてきたのですが、WOWOWのチャンネル再編成につき、PT1のドライバとrecpt1を再コンパイルしました。現在は情報が非常に豊富でとても簡単に作業できました。下記は一応、記録として残し [...]]]></description>
			<content:encoded><![CDATA[<div class="social4i" style="height:29px;">
<div class="social4in" style="height:29px;float: left;">
<div class="socialicons s4twitter" style="float:left;margin-right: 10px;background:url(&quot;http://goo.gl/zjqd1&quot;) no-repeat;"><a href="http://twitter.com/share" data-url="http://www.boenkyo.com/archives/1065" data-counturl="http://www.boenkyo.com/archives/1065" data-text="CentOS5.2でPT1を録画予約(Express 5800/110Ge)" class="twitter-share-button" data-count="horizontal" data-via=""></a></div>
<div class="socialicons s4fblike" style="float:left;margin-right: 10px;">
<div id="fb-root"></div>
<p><fb:like href="http%3A%2F%2Fwww.boenkyo.com%2Farchives%2F1065" send="false" layout="button_count" width="100" height="21" show_faces="false" font=""></fb:like></div>
<div class="socialicons s4plusone" style="float:left;margin-right: 10px;"><g:plusone size="medium" href="http://www.boenkyo.com/archives/1065" count="true"></g:plusone></div>
<div class="socialicons s4fbshare" style="position: relative;float:left;margin-right: 10px;">
<div class="s4ifbshare" ><a name="fb_share" type="button_count" share_url="http%3A%2F%2Fwww.boenkyo.com%2Farchives%2F1065" href="http://www.facebook.com/sharer.php"></a></div>
</div>
</div>
<div style="clear:both"></div>
</div>
<h4>追記</h4>
<p>下記の状態のままずっと稼働させてきたのですが、WOWOWのチャンネル再編成につき、PT1のドライバとrecpt1を再コンパイルしました。現在は情報が非常に豊富でとても簡単に作業できました。下記は一応、記録として残しておきますが、現状では役に立たないと思います。</p>
<p>なお、<a href="http://d.hatena.ne.jp/sona-zip/20110201/p1">コピペでできる録画サーバー on Linux with PT2 (recpt1　録画編) &#8211; GeekなNooblog</a>が大変参考になりました。なお、最新チャンネル関連のファイルは<a href="http://sourceforge.jp/projects/epgrec/">epgrec プロジェクト日本語トップページ &#8211; SourceForge.JP</a>の<a href="http://sourceforge.jp/projects/epgrec/releases/?package_id=12517">2011年10月1日からのBS新チャンネル対応ファイル群</a>よりダウンロードさせて頂きました。ありがとうございました。</p>
<p>追記ここまで。</p>
<hr /></hr>
<p>とりあえず、<a href="http://www.boenkyo.com/archives/1027">Friioでは録画予約できるようになった</a>のですが、PT1が放置状態でしたので、この休み中になんとかすべく格闘してました。<a href="http://pc11.2ch.net/test/read.cgi/linux/1231189481/">【視聴・録画】Linuxでテレビ総合【ﾃﾞｼﾞﾀﾙ/ｱﾅﾛｸﾞ】</a>スレの252さんが作ってくださったPT1用ドライバ・ツールを持ってきて、makeします。252さん版にはREADMEがないので、tomyさんのほうを参考にしました。</p>
<p>252さん版は&#8211;b25オプションを付加できるようにしてあるので、まずarib25をmakeします。/usr/local/libだと(自分の能力では)うまく作れなかったので、すっきりしないですが、/arib25v023/arib25/srcのMakefileのPREFIX =/usr/local/を/usr/に変更して、/usr/lib/にインストールすることにしました。で、まずこちらをmake allでmake installしてから、次はドライバをmakeこちらは簡単。tomyさんのREADME</p>
<blockquote><p>モジュール、ツールのビルド、デバイスファイル作成手順は以下の通りです。</p>
<p>1. モジュールの作成<br />
$ make -C /lib/modules/`uname -r`/build M=`pwd` V=1<br />
2. 作成したモジュールのコピー<br />
#cp pt1_drv.ko /lib/modules/`uname -r`/kernel/drivers/video/pt1_drv.ko<br />
#depmod -a<br />
3. モジュールのロード<br />
#modprobe pt1_drv</p>
<p>4.udev設定<br />
Ubuntuなら/etc/udev/rules.d/40-permissions.rulesに、Debian lennyなら/etc/udev/rules.d/91-permissions.rulesに、</p>
<p>SUBSYSTEM==&#8221;pt1video&#8221;, MODE=&#8221;0644&#8243;,GROUP=&#8221;video&#8221;</p>
<p>を追加ればOK。</p>
<p>KERNEL==&#8221;pt[0-9]*&#8221;, GROUP=&#8221;tape&#8221;</p>
<p>より後ろに追加すること。</p></blockquote>
<p>を参考にしました。私はfriioのときと同様に自作の/etc/udev/rules.d/98-local.rulesに</p>
<blockquote><p>#PT1<br />
SUBSYSTEM==&#8221;pt1video&#8221;,<br />
MODE=&#8221;0664&#8243;, GROUP=&#8221;video&#8221;</p></blockquote>
<p>と追記。</p>
<p>それからrecpt1をmake allしてmake install。</p>
<blockquote><p>ls -al /dev/*pt1*<br />
crw-rw-r&#8211; 1 root video 253, 0 3月 3 20:29 pt1video0<br />
crw-rw-r&#8211; 1 root video 253, 1 3月 3 20:29 pt1video1<br />
crw-rw-r&#8211; 1 root video 253, 2 3月 3 20:29 pt1video2<br />
crw-rw-r&#8211; 1 root video 253, 3 3月 3 20:29 pt1video3</p></blockquote>
<p>となっています。録画はrecpt1 &#8211;b25 22 10 ./test.tsでOKですが、BS/CSのチャンネル指定方法がrecfriioと異なりますので、recfriio serverのチャンネル設定は</p>
<blockquote><p>$CHANNEL = array(<br />
&#8220;22&#8243; =&gt; &#8220;ＮＨＫ総合・神戸&#8221;,<br />
&#8220;13&#8243; =&gt; &#8220;ＮＨＫ教育１・大阪&#8221;,<br />
&#8220;26&#8243; =&gt; &#8220;サンテレビ&#8221;,<br />
&#8220;16&#8243; =&gt; &#8220;ＭＢＳ毎日放送&#8221;,<br />
&#8220;15&#8243; =&gt; &#8220;ＡＢＣテレビ&#8221;,<br />
&#8220;17&#8243; =&gt; &#8220;関西テレビ&#8221;,<br />
&#8220;14&#8243; =&gt; &#8220;よみうりテレビ&#8221;,<br />
&#8220;151&#8243; =&gt; &#8220;BS-Asahi&#8221;,<br />
&#8220;161&#8243; =&gt; &#8220;BS-i&#8221;,<br />
&#8220;191&#8243; =&gt; &#8220;WOWOW&#8221;,<br />
&#8220;171&#8243; =&gt; &#8220;BS-Japan&#8221;,<br />
&#8220;211&#8243; =&gt; &#8220;BS11&#8243;,<br />
&#8220;200&#8243; =&gt; &#8220;Star Channel&#8221;,<br />
&#8220;222&#8243; =&gt; &#8220;TwellV&#8221;,<br />
&#8220;141&#8243; =&gt; &#8220;BS-NTV&#8221;,<br />
&#8220;181&#8243; =&gt; &#8220;BS-Fuji&#8221;,<br />
&#8220;101&#8243; =&gt; &#8220;NHK BS1&#8243;,<br />
&#8220;102&#8243; =&gt; &#8220;NHK BS2&#8243;,<br />
&#8220;103&#8243; =&gt; &#8220;NHK hi&#8221;<br />
);</p></blockquote>
<p>としました。それから、config.phpでrecpt1のパスを記述。</p>
<blockquote><p>// recfriio までのフルパス<br />
//define( &#8216;RECFRIIO&#8217;, &#8216;/usr/local/bin/recfriio&#8217; );<br />
define( &#8216;RECFRIIO&#8217;, &#8216;/usr/local/bin/recpt1&#8242; );</p>
<p>define( &#8216;FRIIOOPT&#8217;, &#8216;&#8211;b25&#8242; );</p></blockquote>
<p>以上で動作するようになりました。さらにBS/CS録画時にLNB給電するために、driver/pt1_pci.cを</p>
<blockquote><p>static int lnb = LNB_15V;</p></blockquote>
<p>として、モジュールを再度コンパイルして、インストールしました。これでRD-XS57はスカパー専用機になってしまいました。</p>
<p>自分のようなタコ野郎でもLinuxでPT1を使えるのはひとえに作者の皆様方のおかげです。ありがとうございます。地デジ・BS/CSには録画したいものはないのですけど。。。</p>
<p><strong>追記(2009.5.10)</strong></p>
<p>BSでの録画は完璧なのですが、地上波でいつも失敗する（ファイルが1GB程度までしか生成されない。もしくは0KBになってしまう）ので、driver/pt1_pci.cを二ちゃん参考に書き換えました。</p>
<blockquote><p>#define DMA_RING_SIZE 14 // RINGサイズ</p></blockquote>
<p>としてみました。地上波はほとんど録画することもないので、放置でもよかったのですが、清志郎特番を録っておきたくて。とりあえず今のところは大丈夫っぽいのですが。。。</p>
<p><strong>追記(2009.5.10)</strong></p>
<p>どうやら上記変更は関係ないみたいで、相変わらず1GB付近で録画停止になってしまう。原点に立ち返り、配線周りを見直し、アンテナ側からの分波・分配器の順序を変えてみたところ、シグナルも上がってうまくいったっぽいかなというところです。</p>
<p><strong>追記(2009.5.24)</strong></p>
<p>上記5/10付けの追記以降、非常に快調に録画できています。清志郎特番でフジテレビ『This Time忌野清志郎』が関西では録画できなかったのが残念ですが、他は問題なく録画できてほっとしております。次はパケット飛ばしでのリアルタイム視聴に挑戦してみたいと思います。</p>
]]></content:encoded>
			<wfw:commentRss>http://www.boenkyo.com/archives/1065/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
	<xhtml:link rel="alternate" media="handheld" type="text/html" href="http://www.boenkyo.com/archives/1065" />
	</item>
		<item>
		<title>5800/110Ge設定覚え書き(2)</title>
		<link>http://www.boenkyo.com/archives/1027</link>
		<comments>http://www.boenkyo.com/archives/1027#comments</comments>
		<pubDate>Sat, 21 Feb 2009 01:41:06 +0000</pubDate>
		<dc:creator>masaki</dc:creator>
				<category><![CDATA[自宅サーバ]]></category>
		<category><![CDATA[5800/110Ge]]></category>
		<category><![CDATA[CentOS5.2]]></category>
		<category><![CDATA[friio]]></category>
		<category><![CDATA[名称未設定]]></category>

		<guid isPermaLink="false">http://www.boenkyo.com/archives/1027</guid>
		<description><![CDATA[前回のつづき。今のところ、白Friioと黒Friioの二台体制です。Express5800/110geにはCentOS5.2。白黒Friio(カードリーダ:SCR−3110NTTCom)を使ってrecfriio serv [...]]]></description>
			<content:encoded><![CDATA[<div class="social4i" style="height:29px;">
<div class="social4in" style="height:29px;float: left;">
<div class="socialicons s4twitter" style="float:left;margin-right: 10px;background:url(&quot;http://goo.gl/zjqd1&quot;) no-repeat;"><a href="http://twitter.com/share" data-url="http://www.boenkyo.com/archives/1027" data-counturl="http://www.boenkyo.com/archives/1027" data-text="5800/110Ge設定覚え書き(2)" class="twitter-share-button" data-count="horizontal" data-via=""></a></div>
<div class="socialicons s4fblike" style="float:left;margin-right: 10px;">
<div id="fb-root"></div>
<p><fb:like href="http%3A%2F%2Fwww.boenkyo.com%2Farchives%2F1027" send="false" layout="button_count" width="100" height="21" show_faces="false" font=""></fb:like></div>
<div class="socialicons s4plusone" style="float:left;margin-right: 10px;"><g:plusone size="medium" href="http://www.boenkyo.com/archives/1027" count="true"></g:plusone></div>
<div class="socialicons s4fbshare" style="position: relative;float:left;margin-right: 10px;">
<div class="s4ifbshare" ><a name="fb_share" type="button_count" share_url="http%3A%2F%2Fwww.boenkyo.com%2Farchives%2F1027" href="http://www.facebook.com/sharer.php"></a></div>
</div>
</div>
<div style="clear:both"></div>
</div>
<p><a href="http://www.boenkyo.com/archives/1022">前回</a>のつづき。今のところ、白Friioと黒Friioの二台体制です。Express5800/110geにはCentOS5.2。白黒Friio(カードリーダ:SCR−3110NTTCom)を使ってrecfriio serverで録画、RAID1を組んだ1TBx2のsambaドライブに保存。マックでマウントして見るか、mediatombでDLNA、PS3経由で三菱HC-1100もしくは25インチブラウン管で見てます。</p>
<ol>
<li>recfriio serverの設定はドキュメントを読んで、思いのほか簡単にできました。とはいえ、udevについてぐぐってもイマイチわからず、なんとなく頭の数字順に処理されるんだろうとアタリをつけて、とりあえず、/etc/udev/rules.d/98-local.rulesというのを作りました。下記のとおり。これでroot:videoとなりました。ロックファイル/var/lock/friiodetectのグループも変えておく。recfriio serverに関してはあとはconfig.phpをいじるだけのシンプル設定。作者様に感謝です。<br />
<blockquote>
<pre>
# friio
SUBSYSTEM=="usb",ENV{DEVTYPE}=="usb_device",
ATTRS{idVendor}=="7a69", ATTRS{idProduct}=="0001",
MODE="0664", GROUP="video"
</pre>
<pre>
crw-rw-r-- 1 root video 189, 134  2月 20 20:54 /dev/bus/usb/002/007
crw-rw-r-- 1 root video 189, 136  2月 20 09:40 /dev/bus/usb/002/009
</pre>
<pre>
-rwxrwxr-x 1 root apache 0  2月 20 19:59 /var/lock/friiodetect
</pre>
</blockquote>
</li>
<li>/var/www/html/recfriio/config-channelmap.phpについてはfriioのwikiにあったチャンネルマップを流用。しかし現状、番組表からチャンネルをうまく引っ張って来れてないのだけど、まぁ、とりあえずいっか、というところ。</li>
<li>TsSplitter.exe をLinuxで使う。WINEをインストール。DAGのレポジトリよりyum。WOWOWを分離。WINEのインストールはDAGのレポジトリを追加(<strong>参考:</strong> <a href="http://centos.oss.sc/fundamentals/yum_rpmforge/">CentOS で構築する自宅サーバ : yum に RPMforge リポジトリを追加する</a>)。<br />
<blockquote>
<pre>
/usr/bin/wine /usr/local/bin/win/TsSplitter.exe -EIT -ECM -EMM -HD -SD1 -SD2 -1SEG -LOGFILE hogehoge.ts
</pre>
</blockquote>
</li>
</ol>
<p>とりあえずここまで</p>
]]></content:encoded>
			<wfw:commentRss>http://www.boenkyo.com/archives/1027/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
	<xhtml:link rel="alternate" media="handheld" type="text/html" href="http://www.boenkyo.com/archives/1027" />
	</item>
		<item>
		<title>5800/110Ge設定覚え書き(1)</title>
		<link>http://www.boenkyo.com/archives/1022</link>
		<comments>http://www.boenkyo.com/archives/1022#comments</comments>
		<pubDate>Tue, 10 Feb 2009 15:11:45 +0000</pubDate>
		<dc:creator>masaki</dc:creator>
				<category><![CDATA[自宅サーバ]]></category>
		<category><![CDATA[CentOS5.2]]></category>
		<category><![CDATA[friio]]></category>

		<guid isPermaLink="false">http://www.boenkyo.com/archives/1022</guid>
		<description><![CDATA[Express 5800/110GeにCentOS5.2をインストールした覚え書き自分用。 インストール　sdb/sdcでRAID1。BIOSのRAIDの使用は挫折。 インストール時に不具合出る場合、boot: linu [...]]]></description>
			<content:encoded><![CDATA[<div class="social4i" style="height:29px;">
<div class="social4in" style="height:29px;float: left;">
<div class="socialicons s4twitter" style="float:left;margin-right: 10px;background:url(&quot;http://goo.gl/zjqd1&quot;) no-repeat;"><a href="http://twitter.com/share" data-url="http://www.boenkyo.com/archives/1022" data-counturl="http://www.boenkyo.com/archives/1022" data-text="5800/110Ge設定覚え書き(1)" class="twitter-share-button" data-count="horizontal" data-via=""></a></div>
<div class="socialicons s4fblike" style="float:left;margin-right: 10px;">
<div id="fb-root"></div>
<p><fb:like href="http%3A%2F%2Fwww.boenkyo.com%2Farchives%2F1022" send="false" layout="button_count" width="100" height="21" show_faces="false" font=""></fb:like></div>
<div class="socialicons s4plusone" style="float:left;margin-right: 10px;"><g:plusone size="medium" href="http://www.boenkyo.com/archives/1022" count="true"></g:plusone></div>
<div class="socialicons s4fbshare" style="position: relative;float:left;margin-right: 10px;">
<div class="s4ifbshare" ><a name="fb_share" type="button_count" share_url="http%3A%2F%2Fwww.boenkyo.com%2Farchives%2F1022" href="http://www.facebook.com/sharer.php"></a></div>
</div>
</div>
<div style="clear:both"></div>
</div>
<p>Express 5800/110GeにCentOS5.2をインストールした覚え書き自分用。</p>
<ol>
<li>インストール　sdb/sdcでRAID1。BIOSのRAIDの使用は挫折。</li>
<li>インストール時に不具合出る場合、boot: linux nodmraidにてインストールを試みる(<strong>参考:</strong> <a href="http://d.hatena.ne.jp/tboffice/20080922/1222102265">CentOSのインストールが止まる -&amp;gt; 解決した &#8211; はぴねす・りなっくす</a>)</li>
<li>authorized_keysを~/.ssh/にコピー ./sshは700　authorized_keysは600</li>
<li>同一IPで再インストールしているような場合、ローカルマシンの~/.ssh/known_hostsを編集・削除</li>
<li>rootになれるユーザを限定(<strong>参考:</strong> <a href="http://centossrv.com/centos5-init.shtml">CentOS5初期設定 &#8211; CentOSで自宅サーバー構築</a>)</li>
<li>yum夜間アップデート(<strong>参考:</strong> <a href="http://centossrv.com/centos5-init.shtml">CentOS5初期設定 &#8211; CentOSで自宅サーバー構築</a>)</li>
<li>NTPサーバの設定(<strong>参考:</strong> <a href="http://centossrv.com/ntp.shtml">NTPサーバー構築(ntpd) &#8211; CentOSで自宅サーバー構築</a>および<a href="http://wiki.nothing.sh/page/NTP/%A5%D7%A5%ED%A5%D0%A5%A4%A5%C0%A1%A6%B5%A1%B4%D8%CA%CC#content_1_0">NTP/プロバイダ・機関別 &#8211; wiki@nothing</a>)</li>
<li>sshd_configでrootログイン及びパスワードログインの禁止(<strong>参考:</strong> <a href="http://centossrv.com/openssh.shtml">SSHサーバー構築(OpenSSH) &#8211; CentOSで自宅サーバー構築</a>)</li>
<li>DiCEインストール(<strong>参考:</strong> <a href="http://www.aconus.com/~oyaji/ddns/ddns_linux.htm">DiCE(Linux版）</a>)</li>
<li>cpuspeed インストール cpufreq-utilsインストール(<strong>参考:</strong> <a href="http://j.tedia.jp/?p=254">純喫茶 三番町 » えころじぃ。</a></li>
<li>しかしcpuspeedはよくわからないので保留</li>
<li>mysqlインストール mysql_secure_installでルートパス等設定</li>
<li>mediatombをインストール。tgzとspecを移動。specを編集。必要なrpmはwget。start/restartでconfig.xmlを作成。uuidgenでIDを作成。config.xml編集。ファイアウォールで50500を開ける。</li>
<li>samba/swatインストール</li>
<li>Friioを使えるように。friiorecを入れてみた。pcscライブラリで悩んだ気がするが忘れてしまった。カードリーダは日立もダメ。TDBのシャープもダメだったので、会社にNTTコミュニケーションズのがあったかも、と休日にわざわざ出社したものの見つからず、ヤマダ電気でポイント購入。イッパツで認識。(<strong>参考:</strong><a href="http://labo.kokodayo.com/wiki/Linux/Friio.html#p995aeed">Linux/Friio &#8211; ここだよっと　LABO　Wiki</a>)</li>
<li>vrsをインストール後、friiorec serverに気づき格闘中。やはり納戸に仕舞わないと五月蝿い。</li>
</ol>
<p>目標。小さなファイルはEmacsではなく、viで編集する習慣をつける(<a href="http://www.geocities.co.jp/SiliconValley/4805/visousa/visousa000.htm">viの操作</a>)。とりあえずPS3でmediatombを見つけて、プロジェクターで映画を見るところまで行けましたが、予約録画がなかなか。。。</p>
]]></content:encoded>
			<wfw:commentRss>http://www.boenkyo.com/archives/1022/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
	<xhtml:link rel="alternate" media="handheld" type="text/html" href="http://www.boenkyo.com/archives/1022" />
	</item>
		<item>
		<title>ファイルサーバをExpress 5800/110Geに入れ替え</title>
		<link>http://www.boenkyo.com/archives/1019</link>
		<comments>http://www.boenkyo.com/archives/1019#comments</comments>
		<pubDate>Wed, 21 Jan 2009 15:56:59 +0000</pubDate>
		<dc:creator>masaki</dc:creator>
				<category><![CDATA[自宅サーバ]]></category>
		<category><![CDATA[5800/100Ge]]></category>
		<category><![CDATA[CentOS5.2]]></category>

		<guid isPermaLink="false">http://www.boenkyo.com/archives/1019</guid>
		<description><![CDATA[NTT-XストアでExpress5800/110Geが12,800円送料無料だったので購入。CentOS5.2を入れて、Mediatombもインストールできて、RAIDも組めて、さて今晩あたりいったんバックアップを取って [...]]]></description>
			<content:encoded><![CDATA[<div class="social4i" style="height:29px;">
<div class="social4in" style="height:29px;float: left;">
<div class="socialicons s4twitter" style="float:left;margin-right: 10px;background:url(&quot;http://goo.gl/zjqd1&quot;) no-repeat;"><a href="http://twitter.com/share" data-url="http://www.boenkyo.com/archives/1019" data-counturl="http://www.boenkyo.com/archives/1019" data-text="ファイルサーバをExpress 5800/110Geに入れ替え" class="twitter-share-button" data-count="horizontal" data-via=""></a></div>
<div class="socialicons s4fblike" style="float:left;margin-right: 10px;">
<div id="fb-root"></div>
<p><fb:like href="http%3A%2F%2Fwww.boenkyo.com%2Farchives%2F1019" send="false" layout="button_count" width="100" height="21" show_faces="false" font=""></fb:like></div>
<div class="socialicons s4plusone" style="float:left;margin-right: 10px;"><g:plusone size="medium" href="http://www.boenkyo.com/archives/1019" count="true"></g:plusone></div>
<div class="socialicons s4fbshare" style="position: relative;float:left;margin-right: 10px;">
<div class="s4ifbshare" ><a name="fb_share" type="button_count" share_url="http%3A%2F%2Fwww.boenkyo.com%2Farchives%2F1019" href="http://www.facebook.com/sharer.php"></a></div>
</div>
</div>
<div style="clear:both"></div>
</div>
<p>NTT-XストアでExpress5800/110Geが12,800円送料無料だったので購入。CentOS5.2を入れて、Mediatombもインストールできて、RAIDも組めて、さて今晩あたりいったんバックアップを取っておくかなと思ったらRAID組むときに誤ったのか、おかしくなってきてしまい、結局再インストール中。今度はインストール記録を付けておこうと誓うのであった。。。</p>
]]></content:encoded>
			<wfw:commentRss>http://www.boenkyo.com/archives/1019/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
	<xhtml:link rel="alternate" media="handheld" type="text/html" href="http://www.boenkyo.com/archives/1019" />
	</item>
	</channel>
</rss>

