Forum: GNU Radio How can I read byte by byte from a file and send it to input stream of a block.

Announcement (2017-05-07): is now read-only since I unfortunately do not have the time to support and maintain the forum any more. Please see and for other Rails- und Ruby-related community platforms.
Mir A. (Guest)
on 2008-12-29 11:52
(Received via mailing list)
I want to read a byte from a file and send it to an input stream. Each
I read one byte from the file i want to send it onto the input stream of
particular block and then read the next byte and do the same. I looked
gr.message_source() which does similar work to what I need. But I see
when we use gr.message_from_string(databyte) and then do
msgq().insert_tail(msg) we add some more information to the data byte. I
just want to send the particular byte read onto the stream. How can I do

Eric B. (Guest)
on 2008-12-29 16:35
(Received via mailing list)
On Mon, Dec 29, 2008 at 03:48:15AM -0600, Mir A. wrote:
> Thanks
> Ali

gr.file_source(gr.sizeof_char, "/path/to/my/file")
Mir A. (Guest)
on 2008-12-30 00:56
(Received via mailing list)
Hi Eric ,

I know what file_source does but I was looking for something else.
look at the code below to know what i am looking for.

    fil=open("/home/murtuza/t",'r')     # I first open a file to read

    while n<1:
        data =  # then read one byte only
        send_pkt(data) # then send it over the stream to a block that
processes that particular byte.
        print "called"


If you look at program data is read from a file and then
send_pkt() is called. send_pkt() module in calls
"self.packet_transmitter.send_pkt(payload, eof)" which then calls
in mod_pkts. Here, the payload is inserted into the message queue by the
statement self._pkt_input.msgq().insert_tail(msg). I want to do
similar except for the fact that I want to put the unmodified byte in
queue unlike mod_pkts which first uses message_from_string and then
the msg on to the queue.

If this can be done using file_source then can u tell how?

I am working on something that requires me to do this. May be this is
not an
ideal way of doing it but still I want to know if it is possible.

This topic is locked and can not be replied to.