# gr-Trellis FSM

**URL:** <https://www.ruby-forum.com/t/gr-trellis-fsm/218414>\
**Category:** GNU Radio\
**Created:** [March 30, 2012, 8:44pm UTC](https://www.ruby-forum.com/t/gr-trellis-fsm/218414 "2012-03-30T20:44:28Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![luislavena](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/l/0ea827/32.png) [@luislavena](https://www.ruby-forum.com/u/luislavena)\
**Post date:** [March 30, 2012, 8:44pm UTC](https://www.ruby-forum.com/t/gr-trellis-fsm/218414/1 "2012-03-30T20:44:28Z")

</div>

I’ve implemented a Manchester Decoder via an FSM using the combined  
Viterbi  
algorithm in gr-trellis, and its working great decoding my signal.  
However,  
I’ve noticed that after ~1000 times running (see code), I get an  
error…

what(): fsm::fsm(const char \*name): file open error

I’d expect this to happen in case of a buffer overrun or RAM limitation,  
but  
even if I reduce the time between packets, I get the same error.

Thanks for your help.

* * *

Manchester\_FSM\_test.py

* * *

#!/usr/bin/env python

from gnuradio import gr  
from gnuradio import trellis  
from gnuradio import eng\_notation  
import math  
import sys  
#import fsm\_utils  
from gnuradio.eng\_option import eng\_option  
from optparse import OptionParser

def main():  
for i in range(2005):

x=manchester([1,0,0,1,1,0,1,0,1,0,0,1,1,0,1,0,1,0,0,1,1,0,1,0,1,0,0,1,1,0,1,0,1,0,0,1,1,0,1,0,1,0,0,1,1,0,1,0,1,0,0,1,1,0,1,0,1,0,0,1,1,0,1,0,1,0,0,1,1,0,1,0,1,0,0,1,1,0,1,0,1,0,0,1,1,0,1,0,1,0,0,1,1,0,1,0,1,0,0,1,1,0,1,0,1,0,0,1,1,0,1,0,1,0,0,1,1,0,1,0,1,0,0,1,1,0,1,0])  
print i

def run\_test  
(f,Kb,bitspersymbol,K,dimensionality,constellation,data\_in):  
tb = gr.top\_block ()

```
src = gr.vector_source_s(data_in)

#src_head = gr.head (gr.sizeof_short,Kb/16) # packet size in shorts
#s2fsmi = gr.packed_to_unpacked_ss(bitspersymbol,gr.GR_MSB_FIRST) #

```

unpack shorts to symbols compatible with the FSM input cardinality  
#enc = trellis.encoder\_bb(f,0) # initial state = 0  
#mod = gr.chunks\_to\_symbols\_sf(constellation,dimensionality)  
va =  
trellis.viterbi\_combined\_sb(f,K,0,-1,dimensionality,constellation,trellis.TRELLIS\_EUCLIDEAN)

# Put -1 if the Initial/Final states are not set.

```
dst = gr.vector_sink_b();
tb.connect (src,va,dst)

tb.run()

return dst.data()

```

def manchester(data\_in):

```
fname="fsm_files/manchester_encoder.fsm"

# system parameters
f=trellis.fsm(fname) # get the FSM specification from a file (will

```

hopefully be automated in the future…)

```
Kb=64
bitspersymbol = int(round(math.log(f.I())/math.log(2))) # bits per 

```

FSM  
input symbol  
K=Kb/bitspersymbol # packet size in trellis steps

```
dimensionality = 2
constellation = [0, 0,0,1,1,0,1,1]
if len(constellation)/dimensionality != f.O():
    sys.stderr.write ('Incompatible FSM output cardinality and

```

modulation size.\n’)  
#sys.exit (1)

(data)=run\_test(f,Kb,bitspersymbol,K,dimensionality,constellation,data\_in)

# 

run experiment with different seed to get different noise realizations  
return data

if **name** == ‘ **main** ’:  
main()

* * *

Manchester\_encoder.fsm

* * *

2 2 4

0 1  
0 1

1 2  
1 2

## Manchester Encoder

View this message in context:  
[http://old.nabble.com/gr-Trellis-FSM-tp33544924p33544924.html](http://old.nabble.com/gr-Trellis-FSM-tp33544924p33544924.html)  
Sent from the GnuRadio mailing list archive at [Nabble.com](http://Nabble.com).
