hi,
I am designing a transmitter which needs to transmit two different types ,
tone (of 1k frequency) and data (2k & 3k frequency).Both of them take user
input, does processing and produce output on sound card of the laptop (am
not using usrp).

I have implemented this all in a single flow graph and used lock and unlock
to reconfigure the flow-graph.But it gets to a hanging state and looks like
it is waiting for something in queue. I did try to use gr.message(1) before
locking , which  locked and unlocked the flow-graph but the problem is that
after using gr.message(1), self.src  does not get further data from the
queue and without using it, it is stucked.

plz find some way out for me to transmit tone and data as required.




 class tx_graph(gr.top_block):

    def __init__(self):
        gr.top_block.__init__(self)


        self.src = gr.message_source(gr.sizeof_char, msgq_limit)

    #
    #  tone_blocks                            // tone processing blocks here
    #


    #
    #  data_blocks                            // data processing blocks here
    #

    self.sink = audio.sink(audio_rate,"plughw:0,0")
    self.connect(self.src,//data_blocks//,self.sink)    # assume that
initially data is being transmitted

    def tone_transmit(self):
    self.lock()
    self.disconnect(self.src,//data_blocks//,self.sink)
    self.connect(self.src,//tone_blocks//,self.sink)
    self.unlock()

def main():

   fg=tx_graph()
   fg.start()




    while True :
        // assume first only data is being tranmitted


            try:




            message = raw_input("Enter a message to transmit (Ctrl-D to
exit): ")
                    msg64 = base64.standard_b64encode(message)
                    print "Encoding message= %s to base64= %s" %
(message,msg64)

                    payload = clock_sync+sync+encode_6b_8b(msg64)+stop_sync
                    pkt = struct.pack('%iB' % (len(payload)),*payload)

                    msg = gr.message_from_string(pkt)

                    fg.src.msgq().insert_tail(msg)

            except EOFError:
                print "\nExiting."
                fg.src.msgq().insert_tail(gr.message(1))
                fg.wait()

    // assume now only tone is being transmitted



            try:
            fg.tone_transmit()
                    message = raw_input(" transmit a 5ms tone (Ctrl-D to
exit): ")
                pkt = struct.pack('B', 0xff)

                    msg = gr.message_from_string(pkt)
                    fg.src.msgq().insert_tail(msg)

            except EOFError:
                print "\nExiting."
                fg.src.msgq().insert_tail(gr.message(1))
                fg.wait()




if __name__ == '__main__':        # main python entry here
    try:
        main()
    except KeyboardInterrupt:
        pass



-- 
*Niaz Ahmed*



“We are always more anxious to be distinguished for a talent which we do not
possess, than to be praised for the fifteen which we do possess”*    :  Mark
Twain <http://thinkexist.com/quotes/mark_twain/>*

* <http://thinkexist.com/quotes/mark_twain/>*
_______________________________________________
Discuss-gnuradio mailing list
Discuss-gnuradio@gnu.org
https://lists.gnu.org/mailman/listinfo/discuss-gnuradio

Reply via email to