# Making new block with GRC or write python

**URL:** <https://www.ruby-forum.com/t/making-new-block-with-grc-or-write-python/240570>\
**Category:** GNU Radio\
**Created:** [April 21, 2014, 10:49am UTC](https://www.ruby-forum.com/t/making-new-block-with-grc-or-write-python/240570 "2014-04-21T10:49:07Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![Detlef\_R](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/d/58f4c7/32.png) [@Detlef\_R](https://www.ruby-forum.com/u/Detlef_R)\
**Post date:** [April 21, 2014, 10:49am UTC](https://www.ruby-forum.com/t/making-new-block-with-grc-or-write-python/240570/1 "2014-04-21T10:49:07Z")

</div>

Dear List,

To make my question on  
[https://www.mail-archive.com/removed\_email\_address@domain.invalid/msg48001.html](https://www.mail-archive.com/removed_email_address@domain.invalid/msg48001.html) more  
clear, I would like to add more details.

I want to implement a bidirectional two-way relaying network using 3  
USRPs  
and GNU Radio. The model is at \*attachment 1. \*  
\*1st slot: \*Two end nodes (A, B) send information to relay node (R) in  
different frequencies. Relay node receives both and make a bitwise XOR  
mapping.  
_2nd slot:_ Relay node sends the XORed message to end nodes. Each end  
nodes  
performs another XOR on this message and its original message to extract  
information from other end node.

For time synchronization, the following protocol using a beacon added in  
relay node has been proposed:  
\*Node A, B \*(see in _attachment 2_):

- Wait for beacon
- Receive beacon
- Transmit message
- Wait for message from relay
- Receive message from relay
- Restart  
\*Node R \*(see in _attachment 3_):
- Transmit the beacon
- Wait for the two messages to be received,
- Check for error
- Combine the messages,
- Transmit the combined message,
- Restart

My question is should I make this process by making some new blocks in  
GRC  
or writing python script? In addition, how to tell a RX/TX chain to  
start/stop since these USRPs work in half-duplex mode?

## Thank you so much. Hoang

Ngo K. Hoang  
Faculty of Electronics and Telecommunications -  
University of Engineering and Technology (UET) - Vietnam National  
University, Hanoi (VNU)  
Vice-president of Student Association of UET  
Alternative email: removed\_email\_address@domain.invalid  
Mobilephone: +84.163.682.7874

---

<div class="post-metadata">

**Author:** ![Hoang\_Ngo\_K](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/h/97f17d/32.png) [@Hoang\_Ngo\_K](https://www.ruby-forum.com/u/Hoang_Ngo_K)\
**Post date:** [April 25, 2014, 5:53am UTC](https://www.ruby-forum.com/t/making-new-block-with-grc-or-write-python/240570/2 "2014-04-25T05:53:01Z")

</div>

On Mon, Apr 21, 2014 at 4:47 AM, Hoang Ngo K.  
[removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid)wrote:

> mapping.
> 
> - Wait for message from relay  
> My question is should I make this process by making some new blocks in GRC  
> or writing python script? In addition, how to tell a RX/TX chain to  
> start/stop since these USRPs work in half-duplex mode?
> 
> Thank you so much.  
> Hoang

Take a look at gr-mac:  
[https://github.com/jmalsbury/gr-mac](https://github.com/jmalsbury/gr-mac)

It’s all done in GRC and would be an appropriate starting point. GRC  
produces Python code, so you can always take that and work in Python  
when  
you get into a place with GRC that you can’t do what you want.

Tom

---

<div class="post-metadata">

**Author:** ![Hoang\_Ngo\_K](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/h/97f17d/32.png) [@Hoang\_Ngo\_K](https://www.ruby-forum.com/u/Hoang_Ngo_K)\
**Post date:** [April 29, 2014, 8:23am UTC](https://www.ruby-forum.com/t/making-new-block-with-grc-or-write-python/240570/3 "2014-04-29T08:23:54Z")

</div>

Thank you Tom,

I’ve installed gr-mac and try on running some flow graph.  
Some blocks there give output as message, but I want to take complex  
samples. How could I convert from message to complex?  
I used Message Source for that purpose but this error appears:  
\*NameError: global name ‘blocks\_message\_soure\_0\_msgg\_in’ is not defined  
\*

Best,  
Hoang
