-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtest.py
More file actions
29 lines (23 loc) · 964 Bytes
/
test.py
File metadata and controls
29 lines (23 loc) · 964 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
from ctypes import create_string_buffer
from Quantis import LIB, QuantisDeviceType, QuantisError, QuantisDeviceHandle, QDH_p, QuantisOperations, QO_p
def main():
qdh = QDH_p()
retval = LIB.QuantisOpen(QuantisDeviceType.QUANTIS_DEVICE_PCI, 0, qdh)
if retval != QuantisError.QUANTIS_SUCCESS:
print("error on call to QuantisOpen: %d", retval)
return 1
size = 128
b = create_string_buffer(size)
retval = LIB.QuantisReadHandled(qdh, b, 128)
if retval < QuantisError.QUANTIS_SUCCESS:
print("error on call to QuantisReadHandled: %d", retval)
return 2
LIB.QuantisClose(qdh)
data = b.raw[:retval]
for i in range(0, len(data), 16):
chunk = data[i:i+16]
hex_chunk = ' '.join(f'{x:02X}' for x in chunk)
ascii_chunk = ''.join(chr(x) if 32 <= x < 127 else '.' for x in chunk)
print(f'{i:04X} {hex_chunk:<48} {ascii_chunk}')
if __name__ == "__main__":
main()