Write binary data to instrument
(self, data)
| 325 | super().finalize() |
| 326 | |
| 327 | def write_raw(self, data): |
| 328 | """Write binary data to instrument |
| 329 | """ |
| 330 | |
| 331 | if self.term_char is not None: |
| 332 | flags = OP_FLAG_TERMCHAR_SET |
| 333 | term_char = str(self.term_char).encode('utf-8')[0] |
| 334 | data += term_char |
| 335 | |
| 336 | flags = 0 |
| 337 | |
| 338 | num = len(data) |
| 339 | |
| 340 | offset = 0 |
| 341 | |
| 342 | while num > 0: |
| 343 | if num <= self.RECV_CHUNK: |
| 344 | flags |= OP_FLAG_END |
| 345 | |
| 346 | block = data[offset:offset+self.RECV_CHUNK] |
| 347 | |
| 348 | error, size = self.client.device_write(self.link, self.io_timeout, self.lock_timeout, flags, block) |
| 349 | |
| 350 | if error: |
| 351 | raise Vxi11Error("error writing data: %d" % error) |
| 352 | elif size < len(block): |
| 353 | raise Vxi11Error("did not write complete block") |
| 354 | |
| 355 | offset += size |
| 356 | num -= size |
| 357 | |
| 358 | def read_raw(self, num=-1): |
| 359 | """Read binary data from instrument |
no test coverage detected