Hi,

I am working on a cognitive radio system. the transmitter side senses the
spectrum and then transmits on a carrier frequency which it finds free.
The receiver should be kept synchronized with the transmitter. The
transmitter is for now tx_voice.py and receiver is rx_voice.py.
*Assumptions:*
The trasmitter is only using 3 freqs: 460e6 461e6 462e6    Hz
The receiver also knows this set of frequencies

*Till now:*
I have implemented the power detector module in the transmitter.

*Problem:*
I am failing to implement the required changes in rx_voice.py
I don't know where to implement the following logic in rx_voice.py:
*If no packet is received on freq1
        check freq2
else
         stay* (also keep checking if data is being received,If packets are
not being received then move to another frequency)

and so on

*2nd Approach:*
I tried a new approach with same logic by using the concept of subprocesses
;
i wrote the following code:

#####################################################################################
import time
import subprocess

while(True):
    output=open("tempdata", "w")
    process=subprocess.Popen(*["./rx_voice.py", "-f", "460e6", "-r",
"500000"*]*]*, stdout=output)
    time.sleep(1) ### Just so that rx_voice initial output is ingored
    check_size_1=subprocess.Popen(["du", "-b", "tempdata"],
stdout=subprocess.PIPE).communicate()[0]
    time.sleep(2)
    check_size_2=subprocess.Popen(["du", "-b", "tempdata"],
stdout=subprocess.PIPE).communicate()[0]
    check_size_1=check_size_1.split(" ")[0];
    check_size_2=check_size_2.split(" ")[0];
    if(check_size_1!=check_size_2):
        while(True):
            check_size_1=subprocess.Popen(["du", "-b", "tempdata"],
stdout=subprocess.PIPE).communicate()[0]
            time.sleep(2)
            check_size_2=subprocess.Popen(["du", "-b", "tempdata"],
stdout=subprocess.PIPE).communicate()[0]
            check_size_1=check_size_1.split(" ")[0];
            check_size_2=check_size_2.split(" ")[0];
            if(check_size_1!=check_size_2):
                pass
            else:
                process.kill()
                output.close()
                break;


    else:
        process.kill()
        output.close()


    output=open("tempdata", "w")
    process=subprocess.Popen(*["./rx_voice.py", "-f", "461e6", "-r",
"500000"*], stdout=output)
    time.sleep(1) ### Just so that rx_voice initial output is ingored
    check_size_1=subprocess.Popen(["du", "-b", "tempdata"],
stdout=subprocess.PIPE).communicate()[0]
    time.sleep(2)
    check_size_2=subprocess.Popen(["du", "-b", "tempdata"],
stdout=subprocess.PIPE).communicate()[0]
    check_size_1=check_size_1.split(" ")[0];
    check_size_2=check_size_2.split(" ")[0];
    if(check_size_1!=check_size_2):
        while(True):
            check_size_1=subprocess.Popen(["du", "-b", "tempdata"],
stdout=subprocess.PIPE).communicate()[0]
            time.sleep(2)
            check_size_2=subprocess.Popen(["du", "-b", "tempdata"],
stdout=subprocess.PIPE).communicate()[0]
            check_size_1=check_size_1.split(" ")[0];
            check_size_2=check_size_2.split(" ")[0];
            if(check_size_1!=check_size_2):
                pass
            else:
                process.kill()
                output.close()
                break;

    else:
        process.kill()

    output=open("tempdata", "w")
    process=subprocess.Popen(*["./rx_voice.py", "-f", "462e6", "-r",
"500000"*], stdout=output)
    time.sleep(1) ### Just so that rx_voice initial output is ingored
    check_size_1=subprocess.Popen(["du", "-b", "tempdata"],
stdout=subprocess.PIPE).communicate()[0]
    time.sleep(2)
    check_size_2=subprocess.Popen(["du", "-b", "tempdata"],
stdout=subprocess.PIPE).communicate()[0]
    check_size_1=check_size_1.split(" ")[0];
    check_size_2=check_size_2.split(" ")[0];
    if(check_size_1!=check_size_2):
        while(True):
            check_size_1=subprocess.Popen(["du", "-b", "tempdata"],
stdout=subprocess.PIPE).communicate()[0]
            time.sleep(2)
            check_size_2=subprocess.Popen(["du", "-b", "tempdata"],
stdout=subprocess.PIPE).communicate()[0]
            check_size_1=check_size_1.split(" ")[0];
            check_size_2=check_size_2.split(" ")[0];
            if(check_size_1!=check_size_2):
                pass
            else:
                process.kill()
                output.close()
                break;
    else:
        process.kill()
#############################################################################################END

*But the problem arises because the opening of a process (rx_voice.py) takes
some time (maybe because of some messages which are displayed everytime when
rx_voice.py is started)  *
*
NOTE: kill() only runs in python 2.6 and maybe higher versions*


Can someone please help me in my initial approach (editing rx_voice.py or
receive_path.py)   OR my subprocess approach??
time is not on my side :)

Regards
Ali
_______________________________________________
Discuss-gnuradio mailing list
Discuss-gnuradio@gnu.org
http://lists.gnu.org/mailman/listinfo/discuss-gnuradio

Reply via email to