Closed jensanjo closed 1 year ago
I found the problem in camlibs/ptp2/library.c
.
The WSAStartup
is called in camera_init
, but only if the camera port type is GP_PORT_PTPIP
:
case GP_PORT_PTPIP: {
GPPortInfo info;
char *xpath;
#if defined(HAVE_LIBWS232) && defined(WIN32)
WORD wsaVersionWanted = MAKEWORD(1, 1);
WSADATA wsaData;
if (WSAStartup(wsaVersionWanted, &wsaData)) {
GP_LOG_E("WSAStartup failed.");
return GP_ERROR;
}
#endif
In camera_exit
WSACleanup
is called, but in this only if the port type is NOT GP_PORT_PTPIP
, which is obviously not what was intended. Since my port type is GP_PORT_USB
the WSAStartup
is not called, but the WSACleanup
is.
#if defined(HAVE_LIBWS232) && defined(WIN32)
else if ((camera->port!=NULL) && camera->port->type != GP_PORT_PTPIP) {
WSACleanup();
}
#endif
This issue was originally reported at python-gphoto2 issue 152 The problem
After initializing the camera and then calling
gp_camera_exit
an erroroccurs when i create a socket.System OS: Windows 10 + MSYS2 MingW 64-bit Python 3.8 libgphoto2-2.5.27 python-gphoto2 2.3.4 camera: Canon EOS 1200D
To Reproduce
Example program
Output