I'm wanting to read from my bluetooth device (it just sends data/header with a 
checksum at the end, in a continuous mode "a biofeedback device") and I'm 
getting a weird error in my logs not allowing me to use multiple sockets. I 
guess with wsgi, I'm creating a link/module between the two apis (apache / 
python), and then lets apache manage the socket / port communication on the 
application layer. How ever, I'm not able to connect to my device. Is there 
something simple I'm missing? The test code is the following

#!/usr/bin/python

# Written by Yevgeniy Medynskiy (euge...@gatech.edu)
# Date modified: December 2006
#
# No copyright. No warranty. Distributed as-is.
#
# http://www.gvu.gatech.edu/ccg/resources/wearableRFID.html

import time
import bluetooth
import sys

class MyWriter:

    def __init__(self, stdout, filename):
        #self.stdout = stdout
        self.logfile = file(filename, 'a')

    def write(self, text):
        #self.stdout.write(text)
        self.logfile.write(text)

    def close(self):
        #self.stdout.close()
        self.logfile.close()

writer = MyWriter(sys.stdout, 'logging.txt')
sys.stdout = writer

#
## Change to your device's Bluetooth address
#
device = "10:00:E8:AC:4D:D0"

port = 1

#
## Read command and request for acknowledgement.
#

socket = bluetooth.BluetoothSocket(bluetooth.RFCOMM)

#print "Attempting to connect to " + device + ":" + str(port) + "...",
socket.connect((device, port))
#print "done."

#print "Receiving data..."


data = ""
try:
        while True:
                try:
                        data = socket.recv(255)
                except bluetooth.BluetoothError, b:
                        print "Bluetooth Error: ", b

                if len(data) > 0: print data

except KeyboardInterrupt:
        #print "Closing socket...",
        socket.close()
        #print "done."

[Wed Dec 12 17:00:31 2012] [error] [client 127.0.0.1] mod_wsgi (pid=2780): 
Target WSGI script 'C:/Project/index.py' cannot be loaded as Python module.
[Wed Dec 12 17:00:31 2012] [error] [client 127.0.0.1] mod_wsgi (pid=2780): 
Exception occurred processing WSGI script 'C:/Project/index.py'.
[Wed Dec 12 17:00:31 2012] [error] [client 127.0.0.1] Traceback (most recent 
call last):
[Wed Dec 12 17:00:31 2012] [error] [client 127.0.0.1]   File 
"C:/Project/index.py", line 45, in <module>
[Wed Dec 12 17:00:31 2012] [error] [client 127.0.0.1]     
socket.connect((device, port))
[Wed Dec 12 17:00:31 2012] [error] [client 127.0.0.1]   File 
"C:\\Python26\\lib\\site-packages\\bluetooth\\msbt.py", line 53, in connect
[Wed Dec 12 17:00:31 2012] [error] [client 127.0.0.1]     bt.connect 
(self._sockfd, addr, port)
[Wed Dec 12 17:00:31 2012] [error] [client 127.0.0.1] IOError: Only one usage 
of each socket address (protocol/network address/port) is normally permitted.\r
[Wed Dec 12 17:00:31 2012] [error] [client 127.0.0.1] 

I realize that in order for me to feed information back to apache and then onto 
my client, is I need to def application().... but I wanted to make sure it was 
just that, and not something that I don't know about using sockets.
-- 
http://mail.python.org/mailman/listinfo/python-list

Reply via email to