当前位置: 首页>>代码示例>>Python>>正文


Python GDBWebSocket.write方法代码示例

本文整理汇总了Python中gdb_websocket.GDBWebSocket.write方法的典型用法代码示例。如果您正苦于以下问题:Python GDBWebSocket.write方法的具体用法?Python GDBWebSocket.write怎么用?Python GDBWebSocket.write使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在gdb_websocket.GDBWebSocket的用法示例。


在下文中一共展示了GDBWebSocket.write方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: GDBServer

# 需要导入模块: from gdb_websocket import GDBWebSocket [as 别名]
# 或者: from gdb_websocket.GDBWebSocket import write [as 别名]

#.........这里部分代码省略.........
                        new_command = False
                        break
                    try:
                        if self.shutdown_event.isSet() or self.detach_event.isSet():
                            break
                        self.abstract_socket.setBlocking(0)
                        data += self.abstract_socket.read()
                        if data.index("$") >= 0 and data.index("#") >= 0:
                            break
                    except (ValueError, socket.error):
                        pass
                
                if self.shutdown_event.isSet():
                    return
            
                if self.detach_event.isSet():
                    continue
                
                self.abstract_socket.setBlocking(1)
                    
                data = data[data.index("$"):]
                
                self.lock.acquire()
            
                if len(data) != 0:
                    # decode and prepare resp
                    [resp, ack, detach] = self.handleMsg(data)
            
                    if resp is not None:
                        # ack
                        if ack:
                            resp = "+" + resp
                        # send resp
                        self.abstract_socket.write(resp)
                        # wait a '+' from the client
                        try:
                            data = self.abstract_socket.read()
                            if data[0] != '+':
                                logging.debug('gdb client has not ack!')
                            else:
                                logging.debug('gdb client has ack!')
                            if data.index("$") >= 0 and data.index("#") >= 0:
                                new_command = True
                        except:
                            pass
                        
                    if detach:
                        self.abstract_socket.close()
                        self.lock.release()
                        break
                    
                self.lock.release()
        
        
    def handleMsg(self, msg):
        
        if msg[0] != '$':
            logging.debug('msg ignored: first char != $')
            return None, 0, 0
        
        #logging.debug('-->>>>>>>>>>>> GDB rsp packet: %s', msg)
        
        # query command
        if msg[1] == 'q':
            return self.handleQuery(msg[2:]), 1, 0
            
开发者ID:ervandarnell,项目名称:pyOCD,代码行数:69,代码来源:gdbserver.py

示例2: GDBServer

# 需要导入模块: from gdb_websocket import GDBWebSocket [as 别名]
# 或者: from gdb_websocket.GDBWebSocket import write [as 别名]

#.........这里部分代码省略.........
                        new_command = False
                        break
                    try:
                        if self.shutdown_event.isSet() or self.detach_event.isSet():
                            break
                        self.abstract_socket.setBlocking(0)
                        data += self.abstract_socket.read()
                        if data.index("$") >= 0 and data.index("#") >= 0:
                            break
                    except (ValueError, socket.error):
                        pass
                
                if self.shutdown_event.isSet():
                    return
            
                if self.detach_event.isSet():
                    continue
                
                self.abstract_socket.setBlocking(1)
                    
                data = data[data.index("$"):]
                
                self.lock.acquire()
            
                if len(data) != 0:
                    # decode and prepare resp
                    [resp, ack, detach] = self.handleMsg(data)
            
                    if resp is not None:
                        # ack
                        if ack:
                            resp = "+" + resp
                        # send resp
                        self.abstract_socket.write(resp)
                        # wait a '+' from the client
                        try:
                            data = self.abstract_socket.read()
                            if data[0] != '+':
                                logging.debug('gdb client has not ack!')
                            else:
                                logging.debug('gdb client has ack!')
                            if data.index("$") >= 0 and data.index("#") >= 0:
                                new_command = True
                        except:
                            pass
                        
                    if detach:
                        self.abstract_socket.close()
                        self.lock.release()
                        break
                    
                self.lock.release()
        
        
    def handleMsg(self, msg):
        
        if msg[0] != '$':
            logging.debug('msg ignored: first char != $')
            return None, 0, 0
        
        #logging.debug('-->>>>>>>>>>>> GDB rsp packet: %s', msg)
        
        # query command
        if msg[1] == 'q':
            return self.handleQuery(msg[2:]), 1, 0
            
开发者ID:henryeherman,项目名称:pyOCD,代码行数:69,代码来源:gdbserver.py

示例3: GDBServer

# 需要导入模块: from gdb_websocket import GDBWebSocket [as 别名]
# 或者: from gdb_websocket.GDBWebSocket import write [as 别名]

#.........这里部分代码省略.........
                    if time() - self.timeOfLastPacket > 0.5:
                        sleep(0.1)
                    try:
                        if self.shutdown_event.isSet() or self.detach_event.isSet():
                            break
                        self.abstract_socket.setBlocking(0)
                        data += self.abstract_socket.read().decode()
                        if data.index("$") >= 0 and data.index("#") >= 0:
                            break
                    except (ValueError, socket.error):
                        pass
                
                if self.shutdown_event.isSet():
                    return
            
                if self.detach_event.isSet():
                    continue
                
                self.abstract_socket.setBlocking(1)
                    
                data = data[data.index("$"):]
                
                self.lock.acquire()
            
                if len(data) != 0:
                    # decode and prepare resp
                    [resp, ack, detach] = self.handleMsg(data)
            
                    if resp is not None:
                        # ack
                        if ack:
                            resp = "+" + resp
                        # send resp
                        self.abstract_socket.write(resp.encode())
                        # wait a '+' from the client
                        try:
                            data = self.abstract_socket.read().decode()
                            if data[0] != '+':
                                logging.debug('gdb client has not ack!')
                            else:
                                logging.debug('gdb client has ack!')
                            if data.index("$") >= 0 and data.index("#") >= 0:
                                new_command = True
                        except:
                            pass
                        
                    if detach:
                        self.abstract_socket.close()
                        self.lock.release()
                        if self.persist:
                            break
                        else:
                            return

                    self.timeOfLastPacket = time()

                self.lock.release()
        
        
    def handleMsg(self, msg):
        
        if msg[0] != '$':
            logging.debug('msg ignored: first char != $')
            return None, 0, 0
        
        #logging.debug('-->>>>>>>>>>>> GDB rsp packet: %s', msg)
开发者ID:dbrobins,项目名称:pyOCD,代码行数:70,代码来源:gdbserver.py

示例4: GDBServer

# 需要导入模块: from gdb_websocket import GDBWebSocket [as 别名]
# 或者: from gdb_websocket.GDBWebSocket import write [as 别名]

#.........这里部分代码省略.........
                        if self.shutdown_event.isSet() or self.detach_event.isSet():
                            break
                        self.abstract_socket.setBlocking(0)
                        data += self.abstract_socket.read()
                        if data.index("$") >= 0 and data.index("#") >= 0:
                            break
                    except (ValueError, socket.error):
                        pass
                
                if self.shutdown_event.isSet():
                    return
            
                if self.detach_event.isSet():
                    continue
                
                self.abstract_socket.setBlocking(1)
                    
                data = data[data.index("$"):]
                
                self.lock.acquire()
            
                if len(data) != 0:
                    # decode and prepare resp
                    [resp, ack, detach] = self.handleMsg(data)

                    # Clear out data
                    data = ""
            
                    if resp is not None:
                        # ack
                        if ack and self.send_acks:
                            resp = "+" + resp
                        # send resp
                        self.abstract_socket.write(resp)
                        if self.send_acks:
                            # wait a '+' from the client
                            try:
                                data = self.abstract_socket.read()
                                if LOG_ACK:
                                    if data[0] != '+':
                                        logging.debug('gdb client has not ack!')
                                    else:
                                        logging.debug('gdb client has ack!')
                                if self.clear_send_acks:
                                    self.send_acks = False
                                if data.index("$") >= 0 and data.index("#") >= 0:
                                    new_command = True
                            except:
                                pass

                    if detach:
                        self.abstract_socket.close()
                        self.lock.release()
                        if self.persist:
                            break
                        else:
                            return

                    self.timeOfLastPacket = time()

                self.lock.release()
        
        
    def handleMsg(self, msg):
        
        if msg[0] != '$':
开发者ID:geky,项目名称:pyOCD,代码行数:70,代码来源:gdbserver.py

示例5: GDBServer

# 需要导入模块: from gdb_websocket import GDBWebSocket [as 别名]
# 或者: from gdb_websocket.GDBWebSocket import write [as 别名]

#.........这里部分代码省略.........
                        new_command = False
                        break
                    try:
                        if self.shutdown_event.isSet() or self.detach_event.isSet():
                            break
                        self.abstract_socket.setBlocking(0)
                        data += self.abstract_socket.read()
                        if data.index("$") >= 0 and data.index("#") >= 0:
                            break
                    except (ValueError, socket.error):
                        pass

                if self.shutdown_event.isSet():
                    return

                if self.detach_event.isSet():
                    continue

                self.abstract_socket.setBlocking(1)

                data = data[data.index("$") :]

                self.lock.acquire()

                if len(data) != 0:
                    # decode and prepare resp
                    [resp, ack, detach] = self.handleMsg(data)

                    if resp is not None:
                        # ack
                        if ack:
                            resp = "+" + resp
                        # send resp
                        self.abstract_socket.write(resp)
                        # wait a '+' from the client
                        try:
                            data = self.abstract_socket.read()
                            if data[0] != "+":
                                logging.debug("gdb client has not ack!")
                            else:
                                logging.debug("gdb client has ack!")
                            if data.index("$") >= 0 and data.index("#") >= 0:
                                new_command = True
                        except:
                            pass

                    if detach:
                        self.abstract_socket.close()
                        self.lock.release()
                        break

                self.lock.release()

    def handleMsg(self, msg):

        if msg[0] != "$":
            logging.debug("msg ignored: first char != $")
            return None, 0, 0

        # logging.debug('-->>>>>>>>>>>> GDB rsp packet: %s', msg)

        # query command
        if msg[1] == "q":
            return self.handleQuery(msg[2:]), 1, 0

        elif msg[1] == "H":
开发者ID:Kazu-zamasu,项目名称:pyOCD,代码行数:70,代码来源:gdbserver.py


注:本文中的gdb_websocket.GDBWebSocket.write方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。