Changeset 381

Show
Ignore:
Timestamp:
07/27/09 15:17:45 (15 years ago)
Author:
sriram
Message:

Correcting bug

Files:
1 modified

Legend:

Unmodified
Added
Removed
  • vtcross/branches/sriram/dsa.py

    r380 r381  
    3939 
    4040        def rx_callback(ok, payload): 
     41                print "inside rx callback\n" 
    4142                global n_rcvd, n_right,sync_status,mode,ch,traffic_flag 
    4243                ############################################################## 
     
    6162                                        ack_payload = struct.pack('!HsH', pktno & 0xffff,data,ch & 0xffff) #+ data 
    6263                                        send_pkt(tb,ack_payload) #sending back the acknowledgement 
     64                        else: 
     65                                print "sync packet not ok\n" 
    6366                ############################################################## 
    6467                 
     
    7477                                        payload = struct.pack('!15s', data) 
    7578                                        send_pkt(tb,payload) 
     79                                 
     80                                #(data_header,) = struct.unpack('!s', payload[0]) 
     81                                #if data_header == 'd': 
     82                                #       comm = struct.unpack('!14s', payload[1:15]) 
     83                                #       print("received this ", comm)  
     84                        else: 
     85                                print "data packet not ok\n" 
    7686                ############################################################## 
    7787 
     
    256266                ################################################Communications mode################################# 
    257267                if mode == "traffic": 
    258                         print "Inside traffic mode" 
     268                                print "Inside traffic mode" 
    259269                        if check_sync == 0: 
    260270                                time.sleep(0.8) 
     
    265275                                        check_sync = 1   
    266276 
    267                                 nbytes = 15 
    268                                 pkt_size = 15 
    269                                 data_pktno = 0 
    270                                 n = 0 
    271                                 while n < nbytes: 
    272                                         #print >> myfile, "inside while" 
    273                                         if options_tx.from_file is None: 
    274                                                 #data = (pkt_size - 2) * chr(data_pktno & 0xff) #0xff is 255 
    275                                                 data = 'dHi how are you' #Sending this message 
    276                                                 #print >> myfile, data 
    277                                                 #print "printing data",data,"****\n" 
    278                                         else: 
    279                                                 data = source_file.read(pkt_size - 2) 
    280                                                 if data == '': 
    281                                                         break; 
     277                        nbytes = 15 
     278                        pkt_size = 15 
     279                        data_pktno = 0 
     280                        n = 0 
     281                        while n < nbytes: 
     282                                #print >> myfile, "inside while" 
     283                                if options_tx.from_file is None: 
     284                                        #data = (pkt_size - 2) * chr(data_pktno & 0xff) #0xff is 255 
     285                                        data = 'dHi how are you' #Sending this message 
     286                                        #print >> myfile, data 
     287                                        #print "printing data",data,"****\n" 
     288                                else: 
     289                                        data = source_file.read(pkt_size - 2) 
     290                                        if data == '': 
     291                                                break; 
    282292         
    283293                         
    284                                         payload = struct.pack('!15s', data) 
    285                                         #print "printing payload",payload,"**\n" 
     294                                payload = struct.pack('!15s', data) 
     295                                #print "printing payload",payload,"**\n" 
    286296                                 
    287                                         send_pkt(tb,payload) 
    288                                         #print "printing payload",payload,"**\n" 
    289                                         n += len(payload) 
    290                                         sys.stderr.write('.') 
    291                                         if options_tx.discontinuous and data_pktno % 5 == 4: 
    292                                                 time.sleep(1) 
    293                                         data_pktno += 1 
    294                                         #print "before sleeping for 10 seconds and value of resend count is",resend_count 
    295                                         time.sleep(0.2) 
    296                                         ch_energy = tb.rxpath.probe.level() #check if primary user is present 
    297                                         print "channel energy is ",ch_energy,"\n" 
    298                                         if int(ch_energy) > 2e7: #if primary user is there then dont transmit on this channel 
    299                                                 mode = "sync" 
    300                          
     297                                send_pkt(tb,payload) 
     298                                print "printing payload",data,"**\n" 
     299                                n += len(payload) 
     300                                sys.stderr.write('.') 
     301                                if options_tx.discontinuous and data_pktno % 5 == 4: 
     302                                        time.sleep(1) 
     303                                data_pktno += 1 
     304                                #print "before sleeping for 10 seconds and value of resend count is",resend_count 
     305                                time.sleep(0.2) 
     306                                ch_energy = tb.rxpath.probe.level() #check if primary user is present 
     307                                print "channel energy is ",ch_energy,"\n" 
     308                                if int(ch_energy) > 2e7: #if primary user is there then dont transmit on this channel 
     309                                        mode = "sync" 
     310                 
    301311 
    302312