Esempio n. 1
0
    def startGstreamerAudio():

        spawnNonDaemonProcess(reactor, TerminalEchoProcessProtocol(),
                              '/usr/bin/python',
                              ['python', 'gstream_audio.py'])
        #spawnNonDaemonProcess(reactor, TerminalEchoProcessProtocol(), '/bin/sh', ['sh', 'gstream_audio_mod.sh'])

        log('Started gstreamer audio')
Esempio n. 2
0
    def __init__(self):
        queues = []

        self.config = Config()
        self.reactor = reactor

        self.oximeterReader = OximeterReader(self)

        self.motionDetectorStatusReader = MotionDetectionStatusReaderProtocol(
            self)
        spawnNonDaemonProcess(reactor, self.motionDetectorStatusReader,
                              'python', ['python', 'MotionDetectionServer.py'])
        log('Started motion detection process')

        self.influxLogger = InfluxLoggerClient()
        spawnNonDaemonProcess(reactor, self.influxLogger, 'python',
                              ['python', 'InfluxDbLogger.py'])
        log('Started influxdb logging process')

        logger = Logger(self)
        logger.run()
        log('Started logging')

        factory = protocol.Factory()
        factory.protocol = JpegStreamReader
        factory.queues = queues
        factory.latestImage = None
        reactor.listenTCP(9999, factory)
        log('Started listening for MJPEG stream')

        root = File('web')
        root.putChild('stream.mjpeg', MJpegResource(queues))
        root.putChild('latest.jpeg', LatestImageResource(factory))
        root.putChild('status', StatusResource(self))
        root.putChild('ping', PingResource())
        root.putChild('getConfig', GetConfigResource(self))
        root.putChild('updateConfig', UpdateConfigResource(self))

        site = server.Site(root)
        PORT = 80
        BACKUP_PORT = 8080

        portUsed = PORT
        try:
            reactor.listenTCP(PORT, site)
            log('Started webserver at port %d' % PORT)
        except twisted.internet.error.CannotListenError:
            portUsed = BACKUP_PORT
            reactor.listenTCP(BACKUP_PORT, site)
            log('Started webserver at port %d' % BACKUP_PORT)

        startZeroConfServer(portUsed)

        startAudioIfAvailable()

        reactor.run()
Esempio n. 3
0
def startAudio():
    spawnNonDaemonProcess(reactor, LoggingProtocol('janus'), '/opt/janus/bin/janus', 
                          ['janus', '-F', '/opt/janus/etc/janus/'])
    log('Started Janus')

    def startGstreamerAudio():
        spawnNonDaemonProcess(reactor, LoggingProtocol('gstream-audio'), '/bin/sh', 
                              ['sh', 'gstream_audio.sh'])
        log('Started gstreamer audio')

    reactor.callLater(2, startGstreamerAudio)
Esempio n. 4
0
def startAudio():
    spawnNonDaemonProcess(reactor, TerminalEchoProcessProtocol(),
                          '/opt/janus/bin/janus',
                          ['janus', '-F', '/opt/janus/etc/janus/'])
    log('Started Janus')

    def startGstreamerAudio():

        spawnNonDaemonProcess(reactor, TerminalEchoProcessProtocol(),
                              '/usr/bin/python',
                              ['python', 'gstream_audio.py'])
        #spawnNonDaemonProcess(reactor, TerminalEchoProcessProtocol(), '/bin/sh', ['sh', 'gstream_audio_mod.sh'])

        log('Started gstreamer audio')

    reactor.callLater(2, startGstreamerAudio)
Esempio n. 5
0
    def startGstreamerVideo(self):

        videosrc = '/dev/video0'

        try:
            out = subprocess.check_output(['v4l2-ctl', '--list-devices'])
        except subprocess.CalledProcessError as e:
            out = e.output

        lines = out.splitlines()
        for (idx, line) in enumerate(lines):
            if 'bcm2835' in line:
                nextline = lines[idx + 1]
                videosrc = nextline.strip()

        spawnNonDaemonProcess(reactor, TerminalEchoProcessProtocol(),
                              '/bin/sh', ['sh', 'gstream_video.sh', videosrc])

        log('Started gstreamer video using device %s' % videosrc)
Esempio n. 6
0
    def __init__(self):
        queues = []

        self.config = Config()
        self.reactor = reactor

        self.oximeterReader = OximeterReader(self)

        self.motionDetectorStatusReader = MotionDetectionStatusReaderProtocol(
            self)
        spawnNonDaemonProcess(reactor, self.motionDetectorStatusReader,
                              'python', ['python', 'MotionDetectionServer.py'])
        log('Started motion detection process')

        logger = Logger(self)
        logger.run()
        log('Started logging')

        factory = protocol.Factory()
        factory.protocol = JpegStreamReader
        factory.queues = queues
        reactor.listenTCP(9999, factory)
        log('Started listening for MJPEG stream')

        root = File('web')
        root.putChild('stream.mjpeg', MJpegResource(queues))
        root.putChild('status', StatusResource(self))
        root.putChild('ping', PingResource())
        root.putChild('getConfig', GetConfigResource(self))
        root.putChild('updateConfig', UpdateConfigResource(self))
        root.putChild('getChart', GetChart(self))
        root.putChild('getTemp', GetTemp(self))
        root.putChild('playMusic', PlayMusic(self))

        site = server.Site(root)
        PORT = 80
        BACKUP_PORT = 8080
        try:
            reactor.listenTCP(PORT, site)
            log('Started webserver at port %d' % PORT)
        except twisted.internet.error.CannotListenError, ex:
            reactor.listenTCP(BACKUP_PORT, site)
            log('Started webserver at port %d' % BACKUP_PORT)
Esempio n. 7
0
    def __init__(self):
        queues = []

        self.config = Config()
        self.reactor = reactor

        self.video = Video(self)
        spawnNonDaemonProcess(reactor, self.video, 'python',
                              ['python', 'VideoServer.py'])
        log('Started Video process')

        logger = Logger(self)
        logger.run()
        log('Started logging')

        factory = protocol.Factory()
        factory.protocol = JpegStreamReader
        factory.queues = queues
        factory.latestImage = None
        reactor.listenTCP(9999, factory)
        log('Started listening for MJPEG stream')

        root = File('web')
        root.putChild('stream.mjpeg', MJpegResource(queues))
        root.putChild('latest.jpeg', LatestImageResource(factory))
        root.putChild('ping', PingResource())

        site = server.Site(root)
        PORT = 80
        BACKUP_PORT = 8080

        portUsed = PORT
        try:
            reactor.listenTCP(PORT, site)
            log('Started webserver at port %d' % PORT)
        except twisted.internet.error.CannotListenError:
            portUsed = BACKUP_PORT
            reactor.listenTCP(BACKUP_PORT, site)
            log('Started webserver at port %d' % BACKUP_PORT)

        startZeroConfServer(portUsed)

        reactor.run()
Esempio n. 8
0
    def errLineReceived(self, line):
        if 'starting data transfer loop' in line:
            os.system('chmod 777 /dev/ttyUSB0')
            self.serialPort = SerialPort(basic.LineReceiver(),
                                         '/dev/ttyToUSB',
                                         reactor,
                                         timeout=3)
            self.loop = LoopingCall(writeToSerialPort, self.serialPort,
                                    self.emulator)
            self.loop.start(2)


parser = argparse.ArgumentParser('Emulator for an oximeter')
parser.add_argument('--interactive',
                    dest='interactive',
                    action='store_true',
                    help='Interactive mode (default is randomized)')
args = parser.parse_args()

if args.interactive:
    emulator = UserInputEmulator()
    stdio.StandardIO(emulator)
else:
    emulator = RandomizedEmulator()

args = r'socat -d -d pty,raw,echo=0,link=/dev/ttyUSB0 pty,raw,echo=0,link=/dev/ttyToUSB'.split(
)
spawnNonDaemonProcess(reactor, SocatProcessProtocol(emulator), 'socat', args)

reactor.run()
Esempio n. 9
0
 def startGstreamerAudio():
     spawnNonDaemonProcess(reactor, LoggingProtocol('gstream-audio'), '/bin/sh', 
                           ['sh', 'gstream_audio.sh'])
     log('Started gstreamer audio')