lib60870 icon indicating copy to clipboard operation
lib60870 copied to clipboard

windows open serial device fail

Open ismiberto opened this issue 2 years ago • 2 comments

In windows, open serial device fail. The function CreateFile accept LPCWSTR type, in code pass device name (self->interfaceName) is a char* data type. serial_port_win32.c

self->comPort = CreateFile(self->interfaceName, GENERIC_READ | GENERIC_WRITE, 0, NULL, OPEN_EXISTING, 0, NULL);

if (self->comPort == INVALID_HANDLE_VALUE) {
	self->lastError = SERIAL_PORT_ERROR_OPEN_FAILED;
	return false;
}

ismiberto avatar Mar 11 '22 17:03 ismiberto

I think this problem happens when the code is compilied with UNICODE defined. See also here: https://stackoverflow.com/questions/51462048/what-is-the-difference-between-createfile-and-createfilea

When you are using a string constant you can try to provide them like _T("COM8")

mzillgith avatar Mar 22 '22 15:03 mzillgith

Thanks. The code it build without UNICODE.

ismiberto avatar Mar 23 '22 14:03 ismiberto