Exemple #1
0
 def got_data(self, data):
     """
     Callback for receiving new data from the device.
     """
     if self.get_current_state() == SBE37ProtocolState.DIRECT_ACCESS:
         # direct access mode
         if len(data) > 0:
             mi_logger.debug("SBE37Protocol._got_data(): <" + data + ">") 
             # check for echoed commands from instrument (TODO: this should only be done for telnet?)
             if len(self._sent_cmds) > 0:
                 # there are sent commands that need to have there echoes filtered out
                 oldest_sent_cmd = self._sent_cmds[0]
                 if string.count(data, oldest_sent_cmd) > 0:
                     # found a command echo, so remove it from data and delete the command form list
                     data = string.replace(data, oldest_sent_cmd, "", 1) 
                     self._sent_cmds.pop(0)            
             if len(data) > 0 and self._driver_event:
                 self._driver_event(DriverAsyncEvent.DIRECT_ACCESS, data)
                 # TODO: what about logging this as an event?
         return
     
     if len(data)>0:
         # Call the superclass to update line and prompt buffers.
         CommandResponseInstrumentProtocol.got_data(self, data)
 
         # If in streaming mode, process the buffer for samples to publish.
         cur_state = self.get_current_state()
         if cur_state == SBE37ProtocolState.AUTOSAMPLE:
             if SBE37_NEWLINE in self._linebuf:
                 lines = self._linebuf.split(SBE37_NEWLINE)
                 self._linebuf = lines[-1]
                 for line in lines:
                     self._extract_sample(line)                    
Exemple #2
0
    def got_data(self, data):
        """
        Callback for receiving new data from the device.
        """
        # Call the superclass to update line and promp buffers.
        CommandResponseInstrumentProtocol.got_data(self, data)

        # If in streaming mode, process the buffer for samples to publish.
        cur_state = self.get_current_state()
        if cur_state == SBE16ProtocolState.AUTOSAMPLE:
            if SBE16_NEWLINE in self._linebuf:
                lines = self._linebuf.split(SBE16_NEWLINE)
                self._linebuf = lines[-1]
                for line in lines:
                    self._extract_sample(line)