-
Notifications
You must be signed in to change notification settings - Fork 0
/
ft1040_test.py
64 lines (53 loc) · 1.99 KB
/
ft1040_test.py
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
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
import ctypes
import os
import platform
lib = ctypes.CDLL(".\dll_ft1040\dll_x64\smncsftmt.dll")
# c programming language 宏
DEV_ID_0 = ctypes.c_int(0)
FTMT_START_FREQ_DIV_1 = ctypes.c_int(1)
FTMT_START_FREQ_DIV_2 = ctypes.c_int(2)
FTMT_START_FREQ_DIV_3 = ctypes.c_int(3)
FTMT_START_FREQ_DIV_4 = ctypes.c_int(4)
FTMT_TTTR_END_MODE_TIME = ctypes.c_int(0)
FTMT_TASK_RUN_MODE_T3 = ctypes.c_int(0x03)
FilePath = ctypes.c_char_p(b"D:\ODMRequipment\File")
# dll_path = ""
# wd = os.path.abspath(os.path.dirname(__file__))
# arch = platform.architecture()[0]
# if arch == '64bit':
# dll_path = os.path.join(wd, 'dll_ft1040\dll_x64\smncsftmt.dll')
# print("64 bit smncsftmt.dll is dynamically loaded")
# else:
# dll_path = os.path.join(wd, 'dll_ft1040\dll_x86\smncsftmt.dll')
# print("32 bit smncsftmt.dll is dynamically loaded")
# print(dll_path)
# if os.path.isfile(dll_path):
# lib = ctypes.CDLL(dll_path)
# GetDevType = lib.GetDevType
# GetDevType.argtypes = [ctypes.c_int, ctypes.c_char_p]
# GetDevType.restype = ctypes.c_int
# print(GetDevType(ctypes.c_int(0), ctypes.c_char_p(b"my dev")))
SetTTTREndMode = lib.SetTTTREndMode
SetTTTREndMode.argtypes = [ctypes.c_int]
SetTTTREndMode.restype = ctypes.c_int
rtn = SetTTTREndMode(FTMT_TTTR_END_MODE_TIME)
print(rtn)
GetDevType = lib.GetDevType
GetDevType.argtypes = [ctypes.c_int, ctypes.c_char_p]
GetDevType.restype = ctypes.c_int
rtn = hex(GetDevType(DEV_ID_0,ctypes.c_char_p(b"my dev")))
print(rtn)
# GetSerialNumber = lib.GetSerialNumber
# # GetSerialNumber.restype = ctypes.c_uint32
# print(type(GetSerialNumber(0)))
# print(lib.GetPartNumber(0))
SetStartFreqDiv = lib.SetStartFreqDiv
SetStartFreqDiv.argtypes = [ctypes.c_int, ctypes.c_int]
SetStartFreqDiv.restype = ctypes.c_int
rtn = SetStartFreqDiv(DEV_ID_0,FTMT_START_FREQ_DIV_1)
print(rtn)
GetFilePath = lib.GetFilePath
GetFilePath.argtypes = [ctypes.c_int, ctypes.c_int, ctypes.c_char_p]
GetFilePath.restype = ctypes.c_int
rtn = GetFilePath(DEV_ID_0, FTMT_TASK_RUN_MODE_T3, FilePath)
print(rtn)