blob: b45436dddd012c3acbb9ba50fa84d3aeee59336f (
plain)
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
30
31
32
33
34
35
36
37
38
39
40
|
import cffi
ffi = cffi.FFI()
gs = ffi.string
def to_hex(s):
return "".join("{:02x}".format(ord(c)) for c in s)
def wait(t):
import time
msg = 'Waiting for %d seconds' % t
print(msg.center(40, '='))
time.sleep(t)
def cast_pointer_to_tuple(obj, typen, len):
# usage:
# config = cast_pointer_to_tuple(config_raw_data, 'uint8_t', 5)
return tuple(ffi.cast("%s [%d]" % (typen, len), obj)[0:len])
def get_firmware_version_from_status(C):
status = gs(C.NK_status())
status = [s if 'firmware_version' in s else '' for s in status.split('\n')]
firmware = status[0].split(':')[1]
return firmware
def is_pro_rtm_07(C):
firmware = get_firmware_version_from_status(C)
return '07 00' in firmware
def is_storage(C):
"""
exact firmware storage is sent by other function
"""
firmware = get_firmware_version_from_status(C)
return '01 00' in firmware
|