Skip to content

Commit

Permalink
Merge pull request #319 from analogdevicesinc/tfcollins/bin-gen
Browse files Browse the repository at this point in the history
Add byte file generation support for iio_writedev
  • Loading branch information
tfcollins authored Mar 29, 2022
2 parents c79544a + 50b4854 commit 2088598
Showing 1 changed file with 9 additions and 2 deletions.
11 changes: 9 additions & 2 deletions adi/rx_tx.py
Original file line number Diff line number Diff line change
Expand Up @@ -366,6 +366,8 @@ class tx(dds, rx_tx_common):
_tx_channel_names: List[str] = []
_complex_data = False
__txbuf = None
_output_byte_filename = "out.bin"
_push_to_file = False

def __init__(self, tx_cyclic_buffer=False):
if self._complex_data:
Expand Down Expand Up @@ -548,8 +550,13 @@ def tx(self, data_np=None):
)

# Send data to buffer
self.__txbuf.write(bytearray(data))
self.__txbuf.push()
if self._push_to_file:
f = open(self._output_byte_filename, "ab")
f.write(bytearray(data))
f.close()
else:
self.__txbuf.write(bytearray(data))
self.__txbuf.push()


class rx_tx(rx, tx, phy):
Expand Down

0 comments on commit 2088598

Please sign in to comment.