def __init__(self, path2device, channel, rxmac): self.ser = serialinterface.SerialInterface(path2device, 115200, 0) self.free = threading.Lock() self.queueslock = threading.Lock() self.packets = Queue.PriorityQueue() self.outpackets = Queue.Queue() self.crc = crcmod.predefined.mkCrcFun('crc-ccitt-false') self.queues = {} self.callbacks = [] self.ctrs = {} self.reader = threading.Thread(target=self.readerThread) self.reader.daemon = True self.writer = threading.Thread(target=self.writerThread) self.writer.daemon = True self.writer.start() self.reader.start() self.packetlength = None self.txmac = None self.rxmac = None self.channel = None self.gameChannel = channel self.setPacketLength(0x20) self.setRxMAC(rxmac) self.setChannel(channel) self.ctr = 0
def __init__(self): threading.Thread.__init__(self) self.daemon = True self.interface = serialinterface.SerialInterface('/dev/ttyUSB0', 115200, timeout = 5) self.pricelines = {1: {'cost': Decimal("1.5")}, 3: {'cost': Decimal("1.0")}} self.interface.create_channel('C') self.interface.create_channel('T') self.interface.start() self.start()
def __init__(self, device, autoUpdate=1.0): self._interface = serialinterface.SerialInterface( serial.Serial, device, 115200, 8, 'N', 2) log.debug("interface setup OK") self._ports = {} self.resetReboot() log.debug("reset reboot OK") self.updatePorts() log.debug("updated Ports") self._poller = None if autoUpdate is not None: log.info("starting auto-poller") self._poller = StatePoller(self, autoUpdate) self._poller.start()
def createSerial(dev): ser = serialinterface.SerialInterface(dev, 115200, 1) # put the bridge into full drive mode # ser.write('\\F') return ser
help="data to program to eeprom") # parser.add_option("-d", "--data", # dest = "data", # default = "", # help = "data to write to eeprom") (options, args) = parser.parse_args() options.pagesize = int(options.pagesize) options.baudrate = int(options.baudrate) options.chunksize = int(options.chunksize) return options options = parse() serial = serialinterface.SerialInterface(options.serial, options.baudrate, .1) """ t = 0.001 n = 300 while 1: serial.write( "\x5c\x30\x00\x43\xff\x12\x12\x5c\x31") time.sleep(t) for i in range(1,n): serial.write("\x5c\x30\x32\x43\x12\x12\x12\x5c\x31") time.sleep(t) print "." time.sleep(t) serial.write( "\x5c\x30\x00\x43\x12\x12\x12\x5c\x31") for i in range(1,n): serial.write("\x5c\x30\x32\x43\x12\x12\x12\x5c\x31") time.sleep(t)
#!/usr/bin/python import acabsl import time import serialinterface import sys import random print sys.argv[1] serial = serialinterface.SerialInterface(sys.argv[1], 115200, 1) t = 1 acabsl.update() def set_all(r, g, b): for w in range(acabsl.NOOFWALLS): for x in range(acabsl.WALLSIZEX): for y in range(acabsl.WALLSIZEY): acabsl.send(x, y, r, g, b, 0, w) def set_pattern(): set_all(0, 0, 0) r = random.random() * 127 + 127 g = random.random() * 127 + 127 b = random.random() * 127 + 127 acabsl.send(5, 0, r, g, b)
def createBridge(dev): serial = serialinterface.SerialInterface(dev, 115200, 1) queue = Queue.Queue(130) updatequeue = Queue.Queue(1) updatequeues.append(updatequeue) return (queue, serial, updatequeue)
def createSerial(dev): return serialinterface.SerialInterface(dev, 115200, 1)
def __init__(self, config): self.logger = logging.getLogger('logger') self.logger.info('Starting lockd') #add_custom_print_exception() serialdevice = config.get('Master Controller', 'serialdevice') baudrate = config.get('Master Controller', 'baudrate') self.serial_interface = serialinterface.SerialInterface(serialdevice, baudrate, timeout=.1) self.input_queue = Queue.Queue() udpcommand = UDPCommand('127.0.0.1', 2323, self.input_queue) self.doors = {} self.master = None display = None self.display_controller = None self.logic = DoorLogic() for section in config.sections(): if config.has_option(section, 'type'): t = config.get(section, 'type') if t == 'door': door_name = section self.logger.debug('Adding door "%s"'%door_name) buttons = {1: 'manual_control', 2: 'bell_code'} door = Door(door_name, config, self.serial_interface, self.input_queue, buttons) door_address = config.get(door_name, 'address') self.doors[door_address] = door self.logic.add_door(door) else: self.logger.warning('Unknown entry type "%s"', t) elif section == 'Master Controller': #txseq = int(config.get(section, 'txsequence')) #rxseq = int(config.get(section, 'rxsequence')) #key = config.get(section, 'key') buttons_section = 'Master Controller Buttons' buttons = {} for button_name in config.options(buttons_section): button_pin = int(config.get(buttons_section, button_name)) buttons[button_pin] = button_name leds_section = 'Master Controller LEDs' leds = {} for led_name in config.options(leds_section): led_pin = int(config.get(leds_section, led_name)) leds[led_name] = led_pin self.master = MasterController(self.serial_interface, self.input_queue, buttons, leds) elif section == 'Display': display_type = config.get(section, 'display_type') max_update_rate = float(config.get(section, 'max_update_rate')) if display_type == "Nokia_1600": from display import Display display = Display(self.serial_interface) elif display_type == 'simulation': from display_pygame import Display display = Display() elif display_type == 'network': from display_network import Display display = Display() elif display_type == 'None': display = None else: self.logger.warning('Unknown display type "%s"', display_type) elif section == 'Status Receiver': host = config.get(section, 'host') port = int(config.get(section, 'port')) self.announcer = Announcer(host, port) self.logic.add_state_listener(self.announcer.update_state) if self.master == None: self.logger.error('Please specify a self.master controller') sys.exit(1) self.interface_logic = UserInterfaceLogic(self.master) self.logic.add_state_listener(self.interface_logic.update_state) if display != None: self.display_controller = DisplayController(display, max_update_rate) self.display_logic = DisplayLogic(self.display_controller) self.logic.add_state_listener(self.display_logic.update_state) for door in self.doors.values(): self.display_logic.add_door(door) else: self.logger.warning('No display specified.') self.input_queue.put({'origin_name': 'init', 'origin_type': DoorLogic.Origin.INTERNAL, 'input_name': '', 'input_type': DoorLogic.Input.COMMAND, 'input_value': 'down'})
facility=19) logger.addHandler(handler) logger.info('Starting lockd') #add_custom_print_exception() try: #if 1: serialdevice = config.get('Master Controller', 'serialdevice') baudrate = config.get('Master Controller', 'baudrate') announcer = Announcer(False) ser = serialinterface.SerialInterface(serialdevice, baudrate, timeout=.1) command_queue = Queue.Queue() udpcommand = UDPCommand('127.0.0.1', 2323, command_queue) doors = {} master = None for section in config.sections(): if config.has_option(section, 'type'): t = config.get(section, 'type') if t == 'door': name = section txseq = int(config.get(section, 'txsequence')) rxseq = int(config.get(section, 'rxsequence'))