def __call__(self, packet): """ Handle CONTROL packets """ if packet.request.header.type_id == 'CONTROL': for transaction, response in zip(packet.request.data, packet.response.data): response.data = IPBusWords.parse(self.__transaction__(transaction)).data return packet
def write(result): request.write(json.dumps({ "success": True, "data": IPBusWords.build(IPBusConstruct.parse(result).data[0]), "error": None, "traceback": None })) request.finish()
def write(result): request.write( json.dumps({ "success": True, "data": IPBusWords.build(IPBusConstruct.parse(result).data[0]), "error": None, "traceback": None })) request.finish()
def __transaction__(self, transaction): protocol = self.registry.get(self.parse_address(transaction.address), None) if protocol is None: raise KeyError(transaction.address) protocol = protocol() if transaction.header.type_id == 'READ': return IPBusWords.parse( protocol.read(transaction.address, transaction.header.words)).data elif transaction.header.type_id == 'WRITE': protocol.write(transaction.address, bytes(bytearray(transaction.data))) return