2006年10月09日

PythonでUSB-IO @ 電子工作

MacでUSB-IOを使おうと思い、ネットで見つかる唯一のMacでの動作例を試しているのですが、何故か上手く行きません。インストールの途中でエラーが出て先に進めません。

後で見ると問題が分かるかも知れないので、取り敢えず、手順も含めてメモとして書いておきます。ちなみにこちらの環境はMac OS X 10.3.9。iBook G4(1.2GHz)です。10.4の環境もあるので、同じ事を後ほど試してみます。

試そうとしているページは下記のページ

Control USBIO module from Python on MacOSX
>>関連リンク

ではインストールです。先ずはSWIG。

Simplified Wrapper and Interface Generator
>>関連リンク

$cd swig-1.3.29
$./configure --with-python=/usr/bin/python
$make
$ su
# make install

問題なければ、バージョンの確認。

$ swig -version

SWIG Version 1.3.29

Compiled with g++ [powerpc-apple-darwin7.9.0]
Please see >>関連リンク for reporting bugs and further information

となればOKのはず。

そして、AppleがADCで配布しているIOKit/USBのサンプル「HID Utilities」です。ビルドする前に、少し書き換える必用がある様なので、最初に紹介したサイトを参考にして書き換えます。問題なくビルドできたら、出来たものを/usr/local/libへコピーします。

次にHIDonMacOSXディレクトリーに移って、いよいよPythonからUSB-IOを使うためのセットアップです。しかし、エラーが出ます。(T_T) Pythonも殆ど使ったことがないし、SWIGも未知のモノ。つまりは分からないものが殆どなので、原因追及に時間が掛かりそう。Undefined symbolsなどが出ているので、必用なモノが必用なところにない雰囲気。一応ログを書いておきます。

$ python setup.py build
running build
running build_py
creating build
creating build/lib.darwin-7.9.0-Power_Macintosh-2.3
copying HID_Utilities.py -> build/lib.darwin-7.9.0-Power_Macintosh-2.3
copying HIDDeviceInfo.py -> build/lib.darwin-7.9.0-Power_Macintosh-2.3
copying USBIO.py -> build/lib.darwin-7.9.0-Power_Macintosh-2.3
running build_ext
building '_HID_Utilities' extension
swigging HID_Utilities.i to HID_Utilities_wrap.c
swig -python -o HID_Utilities_wrap.c HID_Utilities.i
HID_Utilities_External.h:332: Warning(509): Overloaded HIDCalibrateValue(long,pRecElement) is shadowed by HIDCalibrateValue(SInt32,pRecElement) at HID_Utilities_External.h:232.
HID_Utilities_External.h:336: Warning(509): Overloaded HIDScaleValue(long,pRecElement) is shadowed by HIDScaleValue(SInt32,pRecElement) at HID_Utilities_External.h:236.
creating build/temp.darwin-7.9.0-Power_Macintosh-2.3
gcc -fno-strict-aliasing -Wno-long-double -no-cpp-precomp -mno-fused-madd -fno-common -dynamic -DNDEBUG -g -O3 -Wall -Wstrict-prototypes -I/System/Library/Frameworks/Python.framework/Versions/2.3/include/python2.3 -c HID_Utilities_wrap.c -o build/temp.darwin-7.9.0-Power_Macintosh-2.3/HID_Utilities_wrap.o
HID_Utilities_wrap.c:2296: warning: function declaration isn't a prototype
HID_Utilities_wrap.c:2512: warning: function declaration isn't a prototype
HID_Utilities_wrap.c:2690: warning: function declaration isn't a prototype
HID_Utilities_wrap.c:2711: warning: function declaration isn't a prototype
HID_Utilities_wrap.c:2801: warning: function declaration isn't a prototype
HID_Utilities_wrap.c:9889: warning: function declaration isn't a prototype
gcc -Wl,-F. -Wl,-F. -bundle -framework Python build/temp.darwin-7.9.0-Power_Macintosh-2.3/HID_Utilities_wrap.o -L/usr/local/lib -L/usr/local/lib -L/System/Library/Frameworks/IOKit.framework -L/System/Library/Frameworks/CoreFoundation.framework -lHIDUtilities -o build/lib.darwin-7.9.0-Power_Macintosh-2.3/_HID_Utilities.so -framework CoreFoundation -framework IOKit
ld: Undefined symbols:
_HIDTransactionAddElement
_HIDTransactionClear
_HIDTransactionCommit
_HIDTransactionGetElementDefault
_HIDTransactionGetElementValue
_HIDTransactionHasElement
_HIDTransactionRemoveElement
_HIDTransactionSetElementDefault
_HIDTransactionSetElementValue
error: command 'gcc' failed with exit status 1

最後にエラーが出ているので、その先に進めません。(T_T)

何か基本的なところを忘れているような気がします。

閲覧数: 6791 / はてなブックマークusers

関連商品

amazon.co.jp・詳細ページへ

blog comments powered by Disqus

関連日記

アマゾン広告

この日記ページは閲覧数などの条件に応じて、閲覧制限を行っています。他からリンクしていただいても、そのリンクから辿った閲覧者が当ページの内容をご覧頂けない場合があります。ご了承下さい。

▼日記検索

Mac

Shade

3D

Flash

ゲーム

ウェブ

音楽

映画

デジカメ

Windows

Linux

携帯電話

テレビ

広島

電子工作

iOS

▼ 最近のトラックバック

▼ランキング

▼関連サイト