コード例 #1
0
ファイル: dixpagwpe.py プロジェクト: iddq/DIXPRS
    def engine(self):
        # Check received frames if connecion active
        #print "AGWPE phase: %d" % (self.phase)
        if self.phase == 9:
            rq = []

            try:
                s = self.sockt.recv(10000)

                # Check for error
                if len(s) == 0:
                    self.phase = 10

                # Process received data
                else:
                    p = s

                    while True:
                        plen = ord(p[28]) + 256 * ord(p[29]) + 36
                        w = p[:plen]

                        if len(w) == plen:
                            rq.append((s[0], w))

                        p = p[plen:]

                        if len(p) == 0:
                            break

            except socket.timeout:
                pass

            except socket.error:
                self.phase = 10

            for p in rq:
                if p[1][4] == 'K':
                    xtx = dixpcommon.raw2txt(p[1][37:])

                    if xtx <> '':
                        xsx = (ord(p[0]), xtx)
                        self.rxque.put(xsx)

            return

        # Start connection
        if self.phase == 0:
            self.sockt = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
            self.sockt.settimeout(0.5)

            try:
                self.sockt.connect((self.servr, self.prtnr))
                self.phase = 1

            except socket.error, s:
                self.phase = 10

            return
コード例 #2
0
        elif k == 'TXTAIL':
            _ax25.RawTx(soc, b2a(chr(0x04) + chr(v)), 2, axdev)

        elif k == 'DUPLEX':
            _ax25.RawTx(soc, b2a(chr(0x05) + chr(v)), 2, axdev)

    # Main program loop

    while True:
        try:
            r = _ax25.RawRx(soc)

            if r[0][1] == axdev:

                if r[1][0] == chr(0x00):
                    txt = dixpcommon.raw2txt(r[1][1:])

                    if txt <> '':
                        st = "R" + dev + "0" + txt  # Single channel device

                        if soccc <> []:
                            stcc = "DIXPRS2201|" + mycall + "|" + st[:
                                                                     2] + "|" + st[
                                                                         3:]

                        # Send it to GW

                        if socgw <> None:
                            socgw.send(st)

                        # Send it to main program
コード例 #3
0
                        st = buf + w[i]
            
                        if st <> '':
                            lst.append(st)
                            buf = ''
            
                    if w[n - 1] <> '':
                        buf = w[n - 1]                

                # Loop through received frames
                for p in lst:
                    if len(p) == 0:
                        continue
                        
                    if ord(p[0]) == 0:
                        txt = dixpcommon.raw2txt(p[1:])
                        #print "KISS RAW2TXT:", txt
                        #print "========================================="

                        if txt <> '':                             
                            st = "R" + dev + "0" + txt # Single channel device
                            
                            # Send it to GW
                            if socgw <> None:
                                socgw.send(st)
                                        
                            # Send it to main program
                            if soctx <> None:
                                soctx.send(st)                                                          
                                 
                            if soccc <> []:
コード例 #4
0
ファイル: dixpax25.py プロジェクト: ampledata/dixprs
        elif k == 'TXTAIL':
             _ax25.RawTx(soc, b2a(chr(0x04) + chr(v)), 2, axdev)
            
        elif k == 'DUPLEX':
             _ax25.RawTx(soc, b2a(chr(0x05) + chr(v)), 2, axdev)

    # Main program loop    
    
    while True:
        try:        
            r = _ax25.RawRx(soc)            

            if r[0][1] == axdev:

                if r[1][0] == chr(0x00):
                    txt = dixpcommon.raw2txt(r[1][1:])
                                    
                    if txt <> '':
                        st = "R" + dev + "0" + txt # Single channel device
                        
                        if soccc <> []:
                            stcc = "DIXPRS2201|" + mycall + "|" + st[:2] + "|" + st[3:]
                            
                        # Send it to GW 
 
                        if socgw <> None:
                            socgw.send(st)
                            
                                 
                        # Send it to main program
                        if soctx <> None: