Пример #1
0
 def connectSerial(self, comport, autopublish):
     self.drone = AscTec(self)
     try:
         result = self.drone.connectDrone(comport, autopublish=autopublish)
     except Exception, e:
         print UAV_Logger.log_error("Comport not opened: " + str(e))
         sys.exit(1)
Пример #2
0
 def connectDrone(self, port, autopublish=None, sending_intervall=None, poll_intervall=None):
     ''' Trys to connect a drone to the serial port specified by this class'''
     
     if autopublish is not None:
         self.__autopublish = autopublish
     if sending_intervall is not None:
         self.__sendingIntervall =  sending_intervall
     if poll_intervall is not None:
         self.__pollIntervall =  poll_intervall
         
     error, message = 0, ""
     self.__comport = port
     if not self.connected:
         try:
             ## connect serial
             AscTec.serial = serial.Serial(port=self.__comport,
                                      baudrate=self.__baud,
                                      parity=self.__parity,
                                      stopbits=self.__stopbits,
                                      bytesize=self.__databits)
         except Exception, e:
             LOG.log_error(str(e))
             error = 1
             message = str(e)
Пример #3
0
    parser.add_option("--port", help="the port of the socket.io-server", default=8081)
    parser.add_option("--host", help="the socket.io-servers IP", default="localhost")
    parser.add_option("--logging_level", help="Specify logging level: DEBUG,INFO", default="INFO")
#     parser.add_option("--logfile", help="specify a file for logging", default=None)
    return parser
   
if __name__ == "__main__":
    parser = init_parser()
    options, args = parser.parse_args()
    host, port = options.host, options.port
    comport = options.comport
    autopublish = options.autopublish.lower() == "true"
    
    if options.logging_level == "DEBUG":
        logging.basicConfig(level=UAV_Logger.APP_DEBUG)
    else:
        logging.basicConfig(level=UAV_Logger.INFO)
    logging.log(logging.INFO, "---------------Starting new LOG------------------")
    UAV_Logger.serialLogger_enable(True)
    UAV_Logger.socketIoLogger_enable(False)
    UAV_Logger.appLogger_enable(True)
    
    uav = startup_UAV(host, port)
    if comport is not None:
        try:
            comport = int(comport)
            startup_serial(uav, comport, autopublish)
        except SerialException, e:
            UAV_Logger.log_error("Serial not available: " + str(e))
        except Exception,e:
            UAV_Logger.log_error("Unexspected Error: "+ str(e))