Ejemplo n.º 1
0
    def __tcp_read(self, isGpsd=False):
        buf = ''
        data = True

        while data and not self._cancel:
            reads, writes, errors = select.select([self._comm], [self._comm],
                                                  [self._comm], 0.1)
            for read in reads:
                data = read.recv(64)
                buf += data
                while buf.find('\n') != -1:
                    line, buf = buf.split('\n', 1)
                    if not isGpsd:
                        pos = line.find('$')
                        if pos != -1 and pos + 1 < len(line):
                            yield line[pos + 1:].rstrip('\r\n')
                    else:
                        yield line
                    if self._raw:
                        line = limit_to_ascii(line)
                        post_event(self._notify,
                                   EventThread(Event.LOC_RAW, 0, line))

            for write in writes:
                if self._send is not None:
                    write.sendall(self._send)
                    self._send = None

            for _error in errors:
                post_event(self._notify,
                           EventThread(Event.LOC_ERR, 0, 'Connection dropped'))
        return
Ejemplo n.º 2
0
    def __tcp_read(self, isGpsd=False):
        buf = ''
        data = True

        while data and not self._cancel:
            reads, writes, errors = select.select([self._comm],
                                                  [self._comm],
                                                  [self._comm],
                                                  0.1)
            for read in reads:
                data = read.recv(64)
                buf += data
                while buf.find('\n') != -1:
                    line, buf = buf.split('\n', 1)
                    if not isGpsd:
                        pos = line.find('$')
                        if pos != -1 and pos + 1 < len(line):
                            yield line[pos + 1:].rstrip('\r\n')
                    else:
                        yield line
                    if self._raw:
                        line = limit_to_ascii(line)
                        post_event(self._notify, EventThread(Event.LOC_RAW,
                                                             0, line))

            for write in writes:
                if self._send is not None:
                    write.sendall(self._send)
                    self._send = None

            for _error in errors:
                post_event(self._notify, EventThread(Event.LOC_ERR,
                                                     0,
                                                     'Connection dropped'))
        return
Ejemplo n.º 3
0
 def __serial_read(self):
     data = True
     while data and not self.cancel:
         data = self.comm.readline()
         yield data
         if self.raw:
             data = limit_to_ascii(data)
             post_event(self.notify, EventThread(Event.LOC_RAW, 0, data))
     return
Ejemplo n.º 4
0
 def __serial_read(self):
     data = True
     while data and not self.cancel:
         data = self.comm.readline()
         yield data
         if self.raw:
             data = limit_to_ascii(data)
             post_event(self.notify, EventThread(Event.LOC_RAW,
                                                 0, data))
     return
Ejemplo n.º 5
0
 def __tcp_read(self):
     buf = ''
     data = True
     while data and not self.cancel:
         try:
             data = self.comm.recv(1024)
         except socket.timeout as error:
             post_event(self.notify, EventThread(Event.LOC_ERR, 0, error))
             return
         buf += data
         while buf.find('\n') != -1:
             line, buf = buf.split('\n', 1)
             yield line
             if self.raw:
                 line = limit_to_ascii(line)
                 post_event(self.notify,
                            EventThread(Event.LOC_RAW, 0, line))
     return
Ejemplo n.º 6
0
 def __tcp_read(self):
     buf = ''
     data = True
     while data and not self.cancel:
         try:
             data = self.comm.recv(1024)
         except socket.timeout as error:
             post_event(self.notify, EventThread(Event.LOC_ERR,
                                                 0, error))
             return
         buf += data
         while buf.find('\n') != -1:
             line, buf = buf.split('\n', 1)
             yield line
             if self.raw:
                 line = limit_to_ascii(line)
                 post_event(self.notify, EventThread(Event.LOC_RAW,
                                                     0, line))
     return
Ejemplo n.º 7
0
 def __serial_read(self):
     isSentence = False
     sentence = ''
     while not self._cancel:
         data = self._comm.read(1)
         if data:
             self._timeout.reset()
             if data == '$':
                 isSentence = True
                 continue
             if data == '\r' or data == '\n':
                 isSentence = False
                 if sentence:
                     yield sentence
                     if self._raw:
                         line = limit_to_ascii(sentence)
                         post_event(self._notify,
                                    EventThread(Event.LOC_RAW, 0, line))
                     sentence = ''
             if isSentence:
                 sentence += data
         else:
             time.sleep(0.1)
Ejemplo n.º 8
0
 def __serial_read(self):
     isSentence = False
     sentence = ''
     while not self._cancel:
         data = self._comm.read(1)
         if data:
             self._timeout.reset()
             if data == '$':
                 isSentence = True
                 continue
             if data == '\r' or data == '\n':
                 isSentence = False
                 if sentence:
                     yield sentence
                     if self._raw:
                         line = limit_to_ascii(sentence)
                         post_event(self._notify, EventThread(Event.LOC_RAW,
                                                              0, line))
                     sentence = ''
             if isSentence:
                 sentence += data
         else:
             time.sleep(0.1)