bonjour,

j'essaye de piloter un microcontrôleur FTDI UM245R avec des fonctions Python. J'ai suivi la documentation :
https://docs.python.org/3/library/ctypes.html et le lien :
http://stackoverflow.com/questions/2...le-from-python
Code Python : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
import ctypes
import ctypes.wintypes as wTypes
 
# chargement de la DLL
ftdiDLL = ctypes.WinDLL("C:\\Windows\\System32\\ftd2xx.dll")
 
# ouverture du port
protoFuncOpen = ctypes.WINFUNCTYPE(ctypes.c_uint32, ctypes.c_int, ctypes.c_void_p)
paramFuncOpen = (1, "iDevice", 0),(1, "ftHandle", 0)
 
funcOpen = protoFuncOpen(("FT_Open",ftdiDLL), paramFuncOpen)
iDevice = ctypes.c_int(0)
ftHandle = wTypes.DWORD(0)
print(funcOpen(iDevice, ctypes.byref(ftHandle)))
print(iDevice, ftHandle)
 
# fermeture du port
protoFuncClose = ctypes.WINFUNCTYPE(ctypes.c_uint32, wTypes.DWORD)
paramFuncClose = (1, "ftHandle",0)
 
funcClose = protoFuncClose(("FT_Close",ftdiDLL), paramFuncClose)
print(funcClose(ftHandle))

La documentation des fonctions FT_Open et FT_Close indiquent :

FT_HANDLE DWORD
FT_STATUS (DWORD)

FT_STATUS FT_Open (int iDevice, FT_HANDLE *ftHandle)
FT_STATUS FT_Close (FT_HANDLE ftHandle)
Le type DWORD de Windows correspond au type uint32 de Python.

Pour l'appel à la fonction FT_Open, je n'ai pas de souci. Par contre, pour FT_Close j'ai l'erreur suivante :
funcClose = protoFuncClose(("FT_Close",ftdiDLL), paramFuncClose)
ValueError: paramflags must have the same length as argtypes
Où est mon erreur ?