예제 #1
0
    # Logging
    if args.log:
        print("Logging Enabled: " + str(args.log))
        logging.basicConfig(filename="OBCI.log",
                            format='%(asctime)s - %(levelname)s : %(message)s',
                            level=logging.DEBUG)
        logging.getLogger('yapsy').setLevel(logging.DEBUG)
        logging.info('---------LOG START-------------')
        logging.info(args)
    else:
        print("user.py: Logging Disabled.")

    print("\n-------INSTANTIATING BOARD-------")
    board = bci.OpenBCICyton(port=args.port,
                             daisy=args.daisy,
                             filter_data=args.filtering,
                             scaled_output=True,
                             log=args.log,
                             aux=args.aux)

    #  Info about effective number of channels and sampling rate
    if board.daisy:
        print("Force daisy mode:")
    else:
        print("No daisy:")
        print(board.getNbEEGChannels(), "EEG channels and",
              board.getNbAUXChannels(), "AUX channels at",
              board.getSampleRate(), "Hz.")

    print("\n------------PLUGINS--------------")
    # Loop round the plugins and print their names.
    print("Found plugins:")
예제 #2
0
파일: udp_server.py 프로젝트: kshatilov/CNB
class UDPServer(object):
    def __init__(self, ip, port, json):
        self.ip = ip
        self.port = port
        self.json = json
        print("Selecting raw UDP streaming. IP: ", self.ip, ", port: ",
              str(self.port))
        self.server = socket.socket(
            socket.AF_INET,  # Internet
            socket.SOCK_DGRAM)

    def send_data(self, data):
        self.server.sendto(data, (self.ip, self.port))

    def handle_sample(self, sample):
        if self.json:
            # Just send channel data.
            self.send_data(json.dumps(sample.channel_data))
        else:
            # Pack up and send the whole OpenBCISample object.
            self.send_data(pickle.dumps(sample))


args = parser.parse_args()
obci = open_bci.OpenBCICyton(args.serial, int(args.baud))
if args.filter_data:
    obci.filter_data = True
sock_server = UDPServer(args.host, int(args.port), args.json)
obci.start_streaming(sock_server.handle_sample)
예제 #3
0
 def __init__(self, port='COM3'):
     self.board = bci.OpenBCICyton(port=port, scaled_output=False, log=True)
     time.sleep(10)
예제 #4
0
import time


def printData(sample):
    #os.system('clear')
    print("----------------")
    print("%f" % (sample.id))
    print(sample.channel_data)
    print(sample.aux_data)
    print("----------------")


if __name__ == '__main__':
    port = '/dev/tty.usbserial-DN0096XA'
    baud = 115200
    logging.basicConfig(filename="test.log",
                        format='%(message)s',
                        level=logging.DEBUG)
    logging.info('---------LOG START-------------')
    board = bci.OpenBCICyton(port=port, scaled_output=False, log=True)

    #32 bit reset
    board.ser.write('v')
    time.sleep(0.100)

    #connect pins to vcc
    board.ser.write('p')
    time.sleep(0.100)

    #board.start_streaming(printData)
    board.print_packets_in()