aboutsummaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
-rw-r--r--pyfantom.py27
1 files changed, 22 insertions, 5 deletions
diff --git a/pyfantom.py b/pyfantom.py
index 0dca9cf..75d6e3a 100644
--- a/pyfantom.py
+++ b/pyfantom.py
@@ -39,8 +39,13 @@ VI_ERROR_IO = -0x4000ffc2 # Equivalent to 0xBFFF003E
DEBUG = True
+libpath = None
# Check platform.
-if platform.system() == 'Darwin':
+platform_type = platform.system()
+if DEBUG:
+ print "Running on %s Platform" % platform_type
+
+if platform_type == 'Darwin':
import sys
if sys.maxsize > 2**32:
raise RuntimeError("fantom drivers not available in 64 bit mode.\n"
@@ -48,11 +53,21 @@ if platform.system() == 'Darwin':
"$ export VERSIONER_PYTHON_PREFER_32_BIT=yes\n"
"$ arch -i386 python\n"
"\n\tNote: This approach will work for for both Apple's Python >= 2.6\n\t\tand MacPorts' Python >= 2.7 installation\n")
- libpath = '/Library/Frameworks/Fantom.framework/Fantom'
+ #libpath = '/Library/Frameworks/Fantom.framework/Fantom'
+ libpath = ctypes.util.find_library('fantom')
from AppKit import NSAutoreleasePool, NSApplication
- #libpath = ctypes.util.find_library('Fantom')
+elif platform_type == 'Linux':
+ libpath = ctypes.util.find_library('fantom')
+elif platform_type == 'Windows':
+ libpath = ctypes.util.find_library('fantom')
+else:
+ raise RuntimeError('Unsupported platform')
+
+if libpath is not None:
+ if DEBUG:
+ print "Found Fantom Library (", libpath, ")"
else:
- raise RuntimeError('unsupported platform')
+ raise RuntimeError("Fantom Driver not found")
# Load library.
dll = ctypes.cdll.LoadLibrary(libpath)
@@ -101,6 +116,8 @@ dll.nFANTOM100_unpairBluetooth.argtypes = [c_char_p, POINTER(c_int)]
dll.nFANTOM100_unpairBluetooth.restype = None
dll.nFANTOM100_isPaired.argtypes = [c_char_p, POINTER(c_int)]
dll.nFANTOM100_isPaired.restype = c_ushort
+if DEBUG:
+ print "Load Library Done"
class FantomException(RuntimeError):
"""Exception thrown on Fantom library error."""
@@ -611,7 +628,7 @@ if __name__ == '__main__':
# check_bt == True: Bluetooth Interface
# check_bt == False: USB Interface
- check_bt = True
+ check_bt = False
get_info = True
play_tone = True
get_battery = True