I have an application where I need to collect the data for 5 seconds from the USRP source and do offline processing for 5 seconds in a repeated manner. I am planning to use the lock & unlock features of the gnuradio to obtain my goals. The major part of my code is given below:
def reconf1(self): self.disconnect((self.gr_throttle_0, 0),(self.gr_file_sink_0, 0)) # Disconnecting the throttle & the file sink
self.connect((self.gr_throttle_0, 0), (self.gr_null_sink_0, 0)) # re-connecting the throttle & the null sink
def reconf2(self): self.disconnect((self.gr_throttle_0, 0),(self.gr_null_sink_0, 0)) # disconnecting the throttle & the null sink
self.connect((self.gr_throttle_0, 0),(self.gr_file_sink_0, 0)) # re-connecting the throttle & the file sink
................................
if __name__ == '__main__':
tb = SingleSource() var = 1 tb.start() # Flow graph starts for loop in range(0,2): sleep(5) # Collects the data in the file sink
tb.lock() tb.reconf1() # Flowgraph gets locked & reconfigured and unlocked
tb.unlock() # Now, data is going to the null sink. I don't need this data sleep(5) ................. # Offline processing
open("SineData.dat",'w').close() # I WANT TO ERASE THE DATA IN THE FILE SINK AFTER PROCESSING # SO THAT THE FILE SIZE DOES NOT BIGGER
tb.lock() tb.reconf2() # File sink is getting reconnected so that I can collect the data in the next run tb.unlock()
Now, the problem is: the file size of "SineData.dat" should not grow with each loop since I am using open("SineData.dat",'w').close() . In each new loop, I expect the file to only contain the latest information and not the previous ones. However, I am finding that the file size keeps growing with each loop, i.e., the open("SineData.dat",'w').close() command is not working.
Any suggestion will be very appreciated.
Thanks,
Nazmul
-- Muhammad Nazmul Islam
Graduate Student Electrical & Computer Engineering Wireless Information & Networking Laboratory
Rutgers, USA.