예제 #1
0
def onReceiveCommDataFromSymulator(commData):
    global ipController
    print "Sending: " + str(commData)
    ipController.sendCommData(commData.data)


droneSimulator.setOnReceiveEvent(onReceiveCommDataFromSymulator)


# hanlder for IpController onReceiveEvent
# forwards calid CommData to DroneSimulator
def onReveiveCommDataFromIp(commData):
    global droneSimulator
    print "Received: " + str(commData)
    droneSimulator.notifyCommData(commData)


ipController.setOnReceiveEvent(onReveiveCommDataFromIp)

# main loop
while not closeServerApp:
    print('MainThread: waiting for a connection')
    ipController.acceptConnection()
    droneSimulator.start()
    while ipController.keepConnection() and not closeServerApp:
        ipController.forwardIncomingPacket()
    droneSimulator.close()
    print('MainThread: connection closed')

endHandler(None, None)
예제 #2
0
from IpController import *
from LogWriter import *

logWriter = LogWriter('logs/')

receiver = IpController('',
                        True,
                        False,
                        10,
                        logWriter)


def onReveiveControlDataFromIP(controlData):
    print "MainThread: ", str(controlData)

receiver.setOnReceiveEvent(onReveiveControlDataFromIP)


print('MainThread: waiting for a connection')
receiver.acceptConnection()
while receiver.keepConnection():
    receiver.forwardIncomingPacket()
print('MainThread: connection closed')

logWriter.noteEvent("MainThread: endHandler")
receiver.close()
logWriter.close()

print "DONE"
예제 #3
0
# handler for DroneController onReceiveEvent
# forwards valid CommData to IpController
def onReceiveCommDataFromUart(commData):
  global ipController
  ipController.sendCommData(commData.data)

droneController.setOnReceiveEvent(onReceiveCommDataFromUart)

# hanlder for IpController onReceiveEvent
# forwards calid CommData to DroneController
def onReveiveCommDataFromIp(commData):
  global droneController
  droneController.sendCommData(commData)

ipController.setOnReceiveEvent(onReveiveCommDataFromIp)

def modemThreadTick():
  data=modem.getModemData()
  log_msg="modem: "
  if data:
    log_msg+=str(data)
  else:
    log_msg+="error"
  logWriter.noteEvent(log_msg)

modemThread = TimerThread('modemThread',modemThreadTick, 2)
modemThread.start()

###########################################################################
## MAIN LOOP
from IpController import *
from LogWriter import *

logWriter = LogWriter('logs/')

receiver = IpController('', True, False, 10, logWriter)


def onReveiveControlDataFromIP(controlData):
    print "MainThread: ", str(controlData)


receiver.setOnReceiveEvent(onReveiveControlDataFromIP)

print('MainThread: waiting for a connection')
receiver.acceptConnection()
while receiver.keepConnection():
    receiver.forwardIncomingPacket()
print('MainThread: connection closed')

logWriter.noteEvent("MainThread: endHandler")
receiver.close()
logWriter.close()

print "DONE"