Vector Source variable from file

Hi all,

I have a vector source that repeats and points to two variables A + B ,
within variable A is 1100 is it possible to have variable B point to a
file
that contains a whole bunch of binary combinations separated line by
line.

Ideally I would like to run a flow graph and upon every repeat cycle to
go
down the list of possible combinations within the file for variable B.

Cheers

Tom,

I’m new to gnuradio, so let’s see if any replies offer better advice.
But I did something similar to what you ask. In my case, the value of
the variable is a call to my python code. You can see what I did in the
top two examples at

http://udel.edu/~mm/gr/

Both grc file and my code are there. You can write something that pulls
the numbers from your file.

Good luck,
Mike

Ill just explain a little different, it may prompt somebody to say hey
this
is easy just do this… ( I wish)

I have a variable called Data2, within this variable is S+S+S+L
Variable S is 1000
Variable L is 100

Data2 is feed into a vector source, this source looks like Data1+Data2
(repeat=yes) Data1 is static data.

I would like to cycle through all possible combinations of the variable
Data2 on each repeat cycle of the vector source.

S+S+S+S
S+S+S+L
S+S+L+L
S+L+L+L
L+L+L+L
L+S+S+S
L+S+S+L
Etc…
Etc…

Thanks Mike,

I created python code to open the file which has the random data in in
it
however unfortunately the vector source complains "can only concatenate
list
(not module) to list, not quite sure what I’m doing wrong.

Will keep at it lol

Hi Tom,

A few things;

I have a vector source that repeats and points to two variables A + B
How do I have to read that? Do you have a vector source, and you set its
data to be the concatenation of list A and list B?

variable A is 1100
I assume you mean that A is [1,1,0,0] (a python list of integers), not
1100 (an integer, which is 1 more than 1099).
a file that contains a whole bunch of binary combinations separated
line by line.
Ah, I think you’re talking about a text file containing lines that look
like “11010100101”, right? Notice that these are strings of characters,
not binary data.
Why are they separated line by line?

Please confirm I understand you correctly:
You want the vector source to emit the following:
[1,1,0,0,bits,from,the,first,line,1,1,0,0,bits,from,the,second,line,1,1,0,0
…]

If that’s the case, it’s not impossible to do:

in your vector source, you’ll have to put in some ugly-ish python.
Something like

numpy.ravel([ [1,1,0,0] + [ ord(character) - ord(“0”) for character in
line[:-1]] for line in open(“txt.xt”,“r”).readlines() ])

(you might need to add an import block “import numpy” for this to work).

Greetings,
Marcus

Thanks Marcus for getting back to me,

You will have to forgive me as i am new to Gnuradio and Python but I
will
try my best to answer these.

How do I have to read that? Do you have a vector source, and you set its
data to be the concatenation of list A and list B?

Correct

I assume you mean that A is [1,1,0,0] (a python list of integers), not
1100 (an integer, which is 1 more than 1099).

Correct my variable A contains [1,1,0,0]

Ah, I think you’re talking about a text file containing lines that look
like “11010100101”, right? Notice that these are strings of characters,
not
binary data.
Why are they separated line by line?

I could put them in square brackets to look like

[1,0,0,0]
[1,0,0,0,0,0]
etc

Please confirm I understand you correctly:
You want the vector source to emit the following:

[1,1,0,0,bits,from,the,first,line,1,1,0,0,bits,from,the,second,line,1,1,0,0

…]

If that’s the case, it’s not impossible to do:

in your vector source, you’ll have to put in some ugly-ish python.
Something like

numpy.ravel([ [1,1,0,0] + [ ord(character) - ord(“0”) for character in
line[:-1]] for line in open(“txt.xt”,“r”).readlines() ])

(you might need to add an import block “import numpy” for this to work).

Greetings,
Marcus

Since I have variable A defined as [1,0,0,0] and variable B defined as
[1,0,0,0,0,0] do you think it’s possible with some Python code to get my
vector source to cycle through all possible combinations of those
variables
up to four? Hope that makes sense.

A+A+A+A
A+A+A+B
A+A+B+B
A+B+B+B
B+B+B+B
B+B+B+A
B+B+A+A
B+A+A+A
etc…

This forum is not affiliated to the Ruby language, Ruby on Rails framework, nor any Ruby applications discussed here.

| Privacy Policy | Terms of Service | Remote Ruby Jobs