-
-
Notifications
You must be signed in to change notification settings - Fork 123
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
win32 DCB structure feature #233
Comments
Of course! I've updated the main branch with this and added a number of relevant Win32 APIs. Please let me know if you need anything else. |
v2.1.2 is published, including these changes: https://pub.dev/packages/win32 |
Thanks for quick updates! Now I can find DCB struct. But I have a little problem about setting DCB parameters. DCB dcbSerialParameters = {0};
if (!GetCommState(this->handler, &dcbSerialParameters))
{
std::cerr << "Failed to get current serial parameters\n";
} else
{
dcbSerialParameters.BaudRate = CBR_115200;
} How can I set dcbSerialParameters in dart? I try final dcb = DCB();
dcb.BaudRate = 115200; But I met "Exited (3221225477)" |
You need to do something like: final dcb = calloc<DCB>();
dcb.ref.BaudRate = 115200;
|
Thanks! Now I know how to use native Struct. BTW, I found when I open "COM5" using dart, the handle always euqal -1. But I can open this port sucessfully with similar C++ code. final portName = TEXT("COM5");
final handler = CreateFile(portName, GENERIC_ALL, 0, nullptr, OPEN_EXISTING,
FILE_ATTRIBUTE_NORMAL, NULL);
if (handler == INVALID_HANDLE_VALUE) {
final lastError = GetLastError();
if (lastError == ERROR_FILE_NOT_FOUND) {
print(portName.toDartString() + "is not available");
} else {
print('get ${lastError}');
}
print("handler error");
return;
} |
I added an example here: This seems to work successfully on my machine at least:
|
LOL... After compare with the example, I found my code bug. I use |
Hello,
I can't find DCB struct in this package. Would it be possible to provide wrappers to DCB interfaces in winbase.h? It's important to implement serial port communication.
Thanks.
The text was updated successfully, but these errors were encountered: