Moving towards complete DMR rebuild for re-write
This commit is contained in:
		
							parent
							
								
									45104d2328
								
							
						
					
					
						commit
						9b6a071cee
					
				
							
								
								
									
										47
									
								
								dmr_decon.py
									
									
									
									
									
								
							
							
						
						
									
										47
									
								
								dmr_decon.py
									
									
									
									
									
								
							@ -39,38 +39,33 @@ def voice_head_term(_string):
 | 
				
			|||||||
    info = burst[0:98] + burst[166:264]
 | 
					    info = burst[0:98] + burst[166:264]
 | 
				
			||||||
    de_int_info = bptc19696.deinterleave(info)    
 | 
					    de_int_info = bptc19696.deinterleave(info)    
 | 
				
			||||||
    slot_type = burst[98:108] + burst[156:166]
 | 
					    slot_type = burst[98:108] + burst[156:166]
 | 
				
			||||||
    sync = burst[108:156]
 | 
					 | 
				
			||||||
    if sync == const.BS_DATA_SYNC:
 | 
					 | 
				
			||||||
        sync = True
 | 
					 | 
				
			||||||
    else:
 | 
					 | 
				
			||||||
        sync = False
 | 
					 | 
				
			||||||
    lc = to_bytes(lc_data_9(de_int_info))
 | 
					    lc = to_bytes(lc_data_9(de_int_info))
 | 
				
			||||||
    cc = to_bytes(slot_type[0:4])
 | 
					    cc = to_bytes(slot_type[0:4])
 | 
				
			||||||
    dtype = to_bytes(slot_type[4:8])
 | 
					    dtype = to_bytes(slot_type[4:8])
 | 
				
			||||||
    return (lc, cc, dtype, sync)
 | 
					    return (lc, cc, dtype)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
def voice_burst(_string):
 | 
					def voice_sync(_string):
 | 
				
			||||||
 | 
					    burst = to_bits(_string)
 | 
				
			||||||
 | 
					    ambe = [0,0,0]
 | 
				
			||||||
 | 
					    ambe[0] = burst[0:72]
 | 
				
			||||||
 | 
					    ambe[1] = burst[72:108] + burst[156:192]
 | 
				
			||||||
 | 
					    ambe[2] = burst[192:264]
 | 
				
			||||||
 | 
					    return (ambe)
 | 
				
			||||||
 | 
					    
 | 
				
			||||||
 | 
					    
 | 
				
			||||||
 | 
					def voice(_string):
 | 
				
			||||||
    burst = to_bits(_string)
 | 
					    burst = to_bits(_string)
 | 
				
			||||||
    ambe = [0,0,0]
 | 
					    ambe = [0,0,0]
 | 
				
			||||||
    ambe[0] = burst[0:72]
 | 
					    ambe[0] = burst[0:72]
 | 
				
			||||||
    ambe[1] = burst[72:108] + burst[156:192]
 | 
					    ambe[1] = burst[72:108] + burst[156:192]
 | 
				
			||||||
    ambe[2] = burst[192:264]
 | 
					    ambe[2] = burst[192:264]
 | 
				
			||||||
    sync = burst [108:156]
 | 
					 | 
				
			||||||
    if sync == const.BS_VOICE_SYNC:
 | 
					 | 
				
			||||||
        cc = bitarray('00')
 | 
					 | 
				
			||||||
        lcss = bitarray('00')
 | 
					 | 
				
			||||||
        sync = True
 | 
					 | 
				
			||||||
    else:
 | 
					 | 
				
			||||||
    emb = burst[108:116] + burst[148:156]
 | 
					    emb = burst[108:116] + burst[148:156]
 | 
				
			||||||
    embeded = burst[116:148]
 | 
					    embeded = burst[116:148]
 | 
				
			||||||
    cc = (emb[0:4])
 | 
					    cc = (emb[0:4])
 | 
				
			||||||
    # pi = (emb[4:5])
 | 
					    # pi = (emb[4:5])
 | 
				
			||||||
    lcss = (emb[5:7])
 | 
					    lcss = (emb[5:7])
 | 
				
			||||||
        sync = False
 | 
					    return (ambe, cc, lcss, embeded)
 | 
				
			||||||
    if not sync and lcss == const.LCSS_FIRST_FRAG or  lcss == const.LCSS_CONT_FRAG or lcss == const.LCSS_LAST_FRAG:
 | 
					 | 
				
			||||||
        pass
 | 
					 | 
				
			||||||
    return (ambe, cc, lcss, sync)
 | 
					 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
def to_bytes(_bits):
 | 
					def to_bytes(_bits):
 | 
				
			||||||
@ -107,47 +102,47 @@ if __name__ == '__main__':
 | 
				
			|||||||
    t0 = time()
 | 
					    t0 = time()
 | 
				
			||||||
    lc = voice_head_term(data_head)
 | 
					    lc = voice_head_term(data_head)
 | 
				
			||||||
    t1 = time()
 | 
					    t1 = time()
 | 
				
			||||||
    print(h(lc[0]), h(lc[1]), h(lc[2]), lc[3])
 | 
					    print(h(lc[0]), h(lc[1]), h(lc[2]))
 | 
				
			||||||
    print(t1-t0, '\n')
 | 
					    print(t1-t0, '\n')
 | 
				
			||||||
    
 | 
					    
 | 
				
			||||||
    print('Voice Burst A Validation:')
 | 
					    print('Voice Burst A Validation:')
 | 
				
			||||||
    t0 = time()
 | 
					    t0 = time()
 | 
				
			||||||
    lc = voice_burst(voice_a)
 | 
					    lc = voice_sync(voice_a)
 | 
				
			||||||
    t1 = time()
 | 
					    t1 = time()
 | 
				
			||||||
    print(lc[0], h(lc[1]), h(lc[2]), lc[3])
 | 
					    print(lc[0])
 | 
				
			||||||
    print(t1-t0, '\n')
 | 
					    print(t1-t0, '\n')
 | 
				
			||||||
    
 | 
					    
 | 
				
			||||||
    print('Voice Burst B Validation:')
 | 
					    print('Voice Burst B Validation:')
 | 
				
			||||||
    t0 = time()
 | 
					    t0 = time()
 | 
				
			||||||
    lc = voice_burst(voice_b)
 | 
					    lc = voice(voice_b)
 | 
				
			||||||
    t1 = time()
 | 
					    t1 = time()
 | 
				
			||||||
    print(lc[0], h(lc[1]), h(lc[2]), lc[3])
 | 
					    print(lc[0], h(lc[1]), h(lc[2]), lc[3])
 | 
				
			||||||
    print(t1-t0, '\n')
 | 
					    print(t1-t0, '\n')
 | 
				
			||||||
    
 | 
					    
 | 
				
			||||||
    print('Voice Burst C Validation:')
 | 
					    print('Voice Burst C Validation:')
 | 
				
			||||||
    t0 = time()
 | 
					    t0 = time()
 | 
				
			||||||
    lc = voice_burst(voice_c)
 | 
					    lc = voice(voice_c)
 | 
				
			||||||
    t1 = time()
 | 
					    t1 = time()
 | 
				
			||||||
    print(lc[0], h(lc[1]), h(lc[2]), lc[3])
 | 
					    print(lc[0], h(lc[1]), h(lc[2]), lc[3])
 | 
				
			||||||
    print(t1-t0, '\n')
 | 
					    print(t1-t0, '\n')
 | 
				
			||||||
    
 | 
					    
 | 
				
			||||||
    print('Voice Burst D Validation:')
 | 
					    print('Voice Burst D Validation:')
 | 
				
			||||||
    t0 = time()
 | 
					    t0 = time()
 | 
				
			||||||
    lc = voice_burst(voice_d)
 | 
					    lc = voice(voice_d)
 | 
				
			||||||
    t1 = time()
 | 
					    t1 = time()
 | 
				
			||||||
    print(lc[0], h(lc[1]), h(lc[2]), lc[3])
 | 
					    print(lc[0], h(lc[1]), h(lc[2]), lc[3])
 | 
				
			||||||
    print(t1-t0, '\n')
 | 
					    print(t1-t0, '\n')
 | 
				
			||||||
    
 | 
					    
 | 
				
			||||||
    print('Voice Burst E Validation:')
 | 
					    print('Voice Burst E Validation:')
 | 
				
			||||||
    t0 = time()
 | 
					    t0 = time()
 | 
				
			||||||
    lc = voice_burst(voice_e)
 | 
					    lc = voice(voice_e)
 | 
				
			||||||
    t1 = time()
 | 
					    t1 = time()
 | 
				
			||||||
    print(lc[0], h(lc[1]), h(lc[2]), lc[3])
 | 
					    print(lc[0], h(lc[1]), h(lc[2]), lc[3])
 | 
				
			||||||
    print(t1-t0, '\n')
 | 
					    print(t1-t0, '\n')
 | 
				
			||||||
    
 | 
					    
 | 
				
			||||||
    print('Voice Burst F Validation:')
 | 
					    print('Voice Burst F Validation:')
 | 
				
			||||||
    t0 = time()
 | 
					    t0 = time()
 | 
				
			||||||
    lc = voice_burst(voice_f)
 | 
					    lc = voice(voice_f)
 | 
				
			||||||
    t1 = time()
 | 
					    t1 = time()
 | 
				
			||||||
    print(lc[0], h(lc[1]), h(lc[2]), lc[3])
 | 
					    print(lc[0], h(lc[1]), h(lc[2]), lc[3])
 | 
				
			||||||
    print(t1-t0, '\n')
 | 
					    print(t1-t0, '\n')
 | 
				
			||||||
@ -156,5 +151,5 @@ if __name__ == '__main__':
 | 
				
			|||||||
    t0 = time()
 | 
					    t0 = time()
 | 
				
			||||||
    lc = voice_head_term(voice_term)
 | 
					    lc = voice_head_term(voice_term)
 | 
				
			||||||
    t1 = time()
 | 
					    t1 = time()
 | 
				
			||||||
    print(h(lc[0]), h(lc[1]), h(lc[2]), lc[3])
 | 
					    print(h(lc[0]), h(lc[1]), h(lc[2]))
 | 
				
			||||||
    print(t1-t0)
 | 
					    print(t1-t0)
 | 
				
			||||||
							
								
								
									
										28
									
								
								hb_router.py
									
									
									
									
									
								
							
							
						
						
									
										28
									
								
								hb_router.py
									
									
									
									
									
								
							@ -11,6 +11,7 @@ from __future__ import print_function
 | 
				
			|||||||
# Python modules we need
 | 
					# Python modules we need
 | 
				
			||||||
import sys
 | 
					import sys
 | 
				
			||||||
from binascii import b2a_hex as h
 | 
					from binascii import b2a_hex as h
 | 
				
			||||||
 | 
					from bitarray import bitarray
 | 
				
			||||||
 | 
					
 | 
				
			||||||
# Debugging functions
 | 
					# Debugging functions
 | 
				
			||||||
from pprint import pprint
 | 
					from pprint import pprint
 | 
				
			||||||
@ -22,7 +23,7 @@ from twisted.internet import task
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
# Things we import from the main hblink module
 | 
					# Things we import from the main hblink module
 | 
				
			||||||
from hblink import CONFIG, HBMASTER, HBCLIENT, logger, systems, hex_str_3, int_id
 | 
					from hblink import CONFIG, HBMASTER, HBCLIENT, logger, systems, hex_str_3, int_id
 | 
				
			||||||
import dmr_decon
 | 
					import dmr_decon, crc
 | 
				
			||||||
 | 
					
 | 
				
			||||||
# Import Bridging rules
 | 
					# Import Bridging rules
 | 
				
			||||||
# Note: A stanza *must* exist for any MASTER or CLIENT configured in the main
 | 
					# Note: A stanza *must* exist for any MASTER or CLIENT configured in the main
 | 
				
			||||||
@ -69,14 +70,27 @@ __status__     = 'pre-alpha'
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
class routerMASTER(HBMASTER):
 | 
					class routerMASTER(HBMASTER):
 | 
				
			||||||
    
 | 
					    
 | 
				
			||||||
 | 
					    def __init__(self, *args, **kwargs):
 | 
				
			||||||
 | 
					        HBMASTER.__init__(self, *args, **kwargs)
 | 
				
			||||||
 | 
					        self.lc_fragments = {'B': '', 'C': '', 'D': '', 'E': '', 'F': ''}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    def dmrd_received(self, _radio_id, _rf_src, _dst_id, _seq, _slot, _call_type, _frame_type, _dtype_vseq, _stream_id, _data):
 | 
					    def dmrd_received(self, _radio_id, _rf_src, _dst_id, _seq, _slot, _call_type, _frame_type, _dtype_vseq, _stream_id, _data):
 | 
				
			||||||
        _bits = int_id(_data[15])
 | 
					        _bits = int_id(_data[15])
 | 
				
			||||||
        if _call_type == 'group':
 | 
					        if _call_type == 'group':
 | 
				
			||||||
            
 | 
					            
 | 
				
			||||||
            if _frame_type == 'data_sync' and (_dtype_vseq == 1 or _dtype_vseq == 2):
 | 
					            if _frame_type == 'data_sync':
 | 
				
			||||||
                print(dmr_decon.voice_head_term(_data[20:53]))
 | 
					                lc = dmr_decon.voice_head_term(_data[20:53])[0]
 | 
				
			||||||
            elif _frame_type == 'voice' or _frame_type == 'voice_sync':
 | 
					                print(h(lc))
 | 
				
			||||||
                print(dmr_decon.voice_burst(_data[20:53]))
 | 
					                if _dtype_vseq == 1:
 | 
				
			||||||
 | 
					                    lc_bits = bitarray()
 | 
				
			||||||
 | 
					                    lc_bits.frombytes(lc)
 | 
				
			||||||
 | 
					                    embedded_lc = lc_bits + crc.csum5(lc)
 | 
				
			||||||
 | 
					                    print('SHIT IS TEH SHIT:', lc_bits)
 | 
				
			||||||
 | 
					                    print('THIS IS THE SHIT:', embedded_lc)
 | 
				
			||||||
 | 
					            elif _frame_type == 'voice_sync':
 | 
				
			||||||
 | 
					                print(dmr_decon.voice_sync(_data[20:53]))
 | 
				
			||||||
 | 
					            elif _frame_type == 'voice':
 | 
				
			||||||
 | 
					                print(dmr_decon.voice(_data[20:53]))
 | 
				
			||||||
            
 | 
					            
 | 
				
			||||||
            _routed = False
 | 
					            _routed = False
 | 
				
			||||||
            for rule in RULES[self._master]['GROUP_VOICE']:
 | 
					            for rule in RULES[self._master]['GROUP_VOICE']:
 | 
				
			||||||
@ -98,6 +112,10 @@ class routerMASTER(HBMASTER):
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
class routerCLIENT(HBCLIENT):
 | 
					class routerCLIENT(HBCLIENT):
 | 
				
			||||||
    
 | 
					    
 | 
				
			||||||
 | 
					    def __init__(self, *args, **kwargs):
 | 
				
			||||||
 | 
					        HBCLIENT.__init__(self, *args, **kwargs)
 | 
				
			||||||
 | 
					        self.lc_fragments = {'B': '', 'C': '', 'D': '', 'E': '', 'F': ''}
 | 
				
			||||||
 | 
					    
 | 
				
			||||||
    def dmrd_received(self, _radio_id, _rf_src, _dst_id, _seq, _slot, _call_type, _frame_type, _dtype_vseq, _stream_id, _data):
 | 
					    def dmrd_received(self, _radio_id, _rf_src, _dst_id, _seq, _slot, _call_type, _frame_type, _dtype_vseq, _stream_id, _data):
 | 
				
			||||||
        _bits = int_id(_data[15])
 | 
					        _bits = int_id(_data[15])
 | 
				
			||||||
        if _call_type == 'group':
 | 
					        if _call_type == 'group':
 | 
				
			||||||
 | 
				
			|||||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user