|
1 | 1 | #!/usr/bin/env python |
2 | | -# |
3 | | -# Copyright (C) 2020 Analog Devices, Inc. |
4 | | -# Author: Cristian Iacob <[email protected]> |
5 | | -# |
6 | | -# This program is free software; you can redistribute it and/or |
7 | | -# modify it under the terms of the GNU General Public License |
8 | | -# as published by the Free Software Foundation; either version 2 |
9 | | -# of the License, or (at your option) any later version. |
10 | | -# |
11 | | -# This program is distributed in the hope that it will be useful, |
12 | | -# but WITHOUT ANY WARRANTY; without even the implied warranty of |
13 | | -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
14 | | -# GNU General Public License for more details. |
15 | | -# |
16 | | -# You should have received a copy of the GNU General Public License |
17 | | -# along with this program; if not, write to the Free Software |
18 | | -# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. |
| 2 | +""" |
| 3 | +Copyright (C) 2020 Analog Devices, Inc. |
| 4 | +Author: Cristian Iacob <[email protected]> |
| 5 | +
|
| 6 | +This program is free software; you can redistribute it and/or |
| 7 | +modify it under the terms of the GNU General Public License |
| 8 | +as published by the Free Software Foundation; either version 2 |
| 9 | +of the License, or (at your option) any later version. |
| 10 | +
|
| 11 | +This program is distributed in the hope that it will be useful, |
| 12 | +but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 13 | +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 14 | +GNU General Public License for more details. |
| 15 | +
|
| 16 | +You should have received a copy of the GNU General Public License |
| 17 | +along with this program; if not, write to the Free Software |
| 18 | +Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. |
| 19 | +""" |
19 | 20 |
|
20 | 21 | import time |
21 | 22 | import sys |
@@ -196,15 +197,15 @@ def write(self): |
196 | 197 | num_samples = self.arguments.num_samples |
197 | 198 |
|
198 | 199 | while app_running: |
199 | | - bytes_to_read = self.buffer._length if num_samples == 0 \ |
200 | | - else min(self.buffer._length, num_samples * self.device.sample_size) |
| 200 | + bytes_to_read = len(self.buffer) if num_samples == 0 \ |
| 201 | + else min(len(self.buffer), num_samples * self.device.sample_size) |
201 | 202 | write_len = bytes_to_read |
202 | 203 | data = [] |
203 | 204 |
|
204 | 205 | while bytes_to_read > 0: |
205 | 206 | read_data = sys.stdin.buffer.read(bytes_to_read) |
206 | 207 | if len(read_data) == 0: |
207 | | - exit(0) |
| 208 | + sys.exit(0) |
208 | 209 | bytes_to_read -= len(read_data) |
209 | 210 | data.extend(read_data) |
210 | 211 |
|
|
0 commit comments