Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

windows open serial device fail #109

Open
ismiberto opened this issue Mar 11, 2022 · 2 comments
Open

windows open serial device fail #109

ismiberto opened this issue Mar 11, 2022 · 2 comments

Comments

@ismiberto
Copy link

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;
}
@mzillgith
Copy link
Contributor

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")

@ismiberto
Copy link
Author

Thanks. The code it build without UNICODE.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants