# How to receive data using pynq.lib.iic.AxiIIC?

**URL:** <https://discuss.pynq.io/t/how-to-receive-data-using-pynq-lib-iic-axiiic/1201>\
**Category:** Support\
**Created:** [April 29, 2020, 4:40am UTC](https://discuss.pynq.io/t/how-to-receive-data-using-pynq-lib-iic-axiiic/1201 "2020-04-29T04:40:19Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![Hi\_There](https://sea1.discourse-cdn.com/flex019/user_avatar/discuss.pynq.io/hi_there/32/763_2.png) [@Hi\_There](https://discuss.pynq.io/u/Hi_There)\
**Post date:** [April 29, 2020, 4:40am UTC](https://discuss.pynq.io/t/how-to-receive-data-using-pynq-lib-iic-axiiic/1201/1 "2020-04-29T04:40:19Z")

</div>

I can successfully send data from the pynq to the slave device (MSP430) but I am not sure how to receive data from the MSP430.

What parameter should I put in the second spot of the receive function? It seems like it’s asking me to predict the data that should be coming to it.

 ![image](https://us1.discourse-cdn.com/flex019/uploads/pynq1/original/1X/2f8f4a0850660903f8ab909ff3194b086587838f.png)

---

<div class="post-metadata">

**Author:** ![cathalmccabe](https://sea1.discourse-cdn.com/flex019/user_avatar/discuss.pynq.io/cathalmccabe/32/3348_2.png) [@cathalmccabe](https://discuss.pynq.io/u/cathalmccabe)\
**Post date:** [April 29, 2020, 6:12am UTC](https://discuss.pynq.io/t/how-to-receive-data-using-pynq-lib-iic-axiiic/1201/2 "2020-04-29T06:12:49Z")

</div>

See info here:  
[https://pynq.readthedocs.io/en/v2.5.1/pynq\_libraries/axiiic.html?highlight=iic#axiiic](https://pynq.readthedocs.io/en/v2.5.1/pynq_libraries/axiiic.html?highlight=iic#axiiic)

Cathal

---

<div class="post-metadata">

**Author:** ![Hi\_There](https://sea1.discourse-cdn.com/flex019/user_avatar/discuss.pynq.io/hi_there/32/763_2.png) [@Hi\_There](https://discuss.pynq.io/u/Hi_There)\
**Post date:** [April 29, 2020, 8:16pm UTC](https://discuss.pynq.io/t/how-to-receive-data-using-pynq-lib-iic-axiiic/1201/3 "2020-04-29T20:16:11Z")

</div>

I’m not sure what the data parameter should be there. I know it’s supposed to be a cdata pointer but is that a register on the pynq?

The PYNQ doc is not really specific on the parameter other than that it is is bytes-like. Should it be a buffer, register, RX\_FIFO ?

---

<div class="post-metadata">

**Author:** ![Hi\_There](https://sea1.discourse-cdn.com/flex019/user_avatar/discuss.pynq.io/hi_there/32/763_2.png) [@Hi\_There](https://discuss.pynq.io/u/Hi_There)\
**Post date:** [April 30, 2020, 9:00pm UTC](https://discuss.pynq.io/t/how-to-receive-data-using-pynq-lib-iic-axiiic/1201/4 "2020-04-30T21:00:03Z")

</div>

Figured it out! The data parameter in the receive() function should be a bytes object produced by bytes(size) function.

Example:

`test = bytes(1)` should return an bytes object of size 1 byte

`type(test)` should return “bytes”

So if I expect to receive a char from a slave device with address 0x30, I would type

`test_IIC = lib.AxiIIC(ol.ip_dict["axi_iic_0"])`

and `test_IIC.receive(0x30,test,1,0)` will output 1.

This site helped me understand as well [Python bytes()](https://www.programiz.com/python-programming/methods/built-in/bytes) .
