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

Added com port stuff #510

Merged
merged 1 commit into from
Sep 21, 2015
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions CHANGES.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ Next Release (4.2.1)

Features
--------
* [#510](https://github.com/java-native-access/jna/pull/510): Added `GetCommState`, `GetCommTimeouts` `SetCommState` and `SetCommTimeouts` to `com.sun.jna.platform.win32.Kernel32`. Added `DCB` structure to `com.sun.jna.platform.win32.WinBase` - [@MBollig](https://github.com/MBollig)

Bug Fixes
---------
Expand Down
84 changes: 84 additions & 0 deletions contrib/platform/src/com/sun/jna/platform/win32/Kernel32.java
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@

import com.sun.jna.Native;
import com.sun.jna.Pointer;
import com.sun.jna.platform.win32.WinNT.HANDLE;
import com.sun.jna.ptr.IntByReference;
import com.sun.jna.ptr.PointerByReference;
import com.sun.jna.win32.W32APIOptions;
Expand Down Expand Up @@ -2729,4 +2730,87 @@ boolean GetVolumePathNamesForVolumeName(String lpszVolumeName,
* @see <a href="https://msdn.microsoft.com/en-us/library/windows/desktop/aa364433(v=vs.85).aspx">FindVolumeClose</a>
*/
boolean FindVolumeClose(HANDLE hFindVolume);

/**
* Retrieves the current control settings for a specified communications
* device.
*
* @param hFile
* [in] A handle to the communications device.<br>
* The
* {@link com.sun.jna.platform.win32.Kernel32#CreateFile(String, int, int, com.sun.jna.platform.win32.WinBase.SECURITY_ATTRIBUTES, int, int, com.sun.jna.platform.win32.WinNT.HANDLE)}
* function returns this {@link HANDLE}.
* @param lpDCB
* [in, out] A pointer to a {@link WinBase.DCB} structure that
* receives the control settings information.
*
* @return If the function succeeds, the return value is nonzero. <br>
* If the function fails, the return value is zero. To get extended
* error information, call {@link Kernel32#GetLastError()}.
*
*/
boolean GetCommState(HANDLE hFile, WinBase.DCB lpDCB);

/**
*
* Retrieves the time-out parameters for all read and write operations on a
* specified communications device.<br>
* <br>
* For more information about time-out values for communications devices,
* see the {@link Kernel32#SetCommTimeouts} function.
*
* @param hFile
* [in] A handle to the communications device. The
* {@link com.sun.jna.platform.win32.Kernel32#CreateFile(String, int, int, com.sun.jna.platform.win32.WinBase.SECURITY_ATTRIBUTES, int, int, com.sun.jna.platform.win32.WinNT.HANDLE)}
* function returns this handle.
*
* @param lpCommTimeouts
* [in] A pointer to a {@link WinBase.COMMTIMEOUTS} structure in
* which the time-out information is returned.
* @return If the function succeeds, the return value is nonzero.
*
* If the function fails, the return value is zero. To get extended
* error information, call {@link Kernel32#GetLastError()}.
*
*
*
*/
boolean GetCommTimeouts(HANDLE hFile, WinBase.COMMTIMEOUTS lpCommTimeouts);

/**
* Configures a communications device according to the specifications in a
* device-control block (a {@link WinBase.DCB} structure). The function
* reinitializes all hardware and control settings, but it does not empty
* output or input queues.
*
* @param hFile
* [in] A handle to the communications device. The
* {@link com.sun.jna.platform.win32.Kernel32#CreateFile(String, int, int, com.sun.jna.platform.win32.WinBase.SECURITY_ATTRIBUTES, int, int, com.sun.jna.platform.win32.WinNT.HANDLE)}
* function returns this handle.
* @param lpDCB
* [in] A pointer to a {@link WinBase.DCB} structure that
* contains the configuration information for the specified
* communications device.
* @return If the function succeeds, the return value is nonzero. If the
* function fails, the return value is zero. To get extended error
* information, call {@link Kernel32#GetLastError()}.
*/
boolean SetCommState(HANDLE hFile, WinBase.DCB lpDCB);

/**
* Sets the time-out parameters for all read and write operations on a
* specified communications device.
*
* @param hFile
* [in] A handle to the communications device. The
* {@link com.sun.jna.platform.win32.Kernel32#CreateFile(String, int, int, com.sun.jna.platform.win32.WinBase.SECURITY_ATTRIBUTES, int, int, com.sun.jna.platform.win32.WinNT.HANDLE)}
* function returns this handle.
* @param LPCOMMTIMEOUTS
* [in] A pointer to a {@link WinBase.COMMTIMEOUTS} structure
* that contains the new time-out values.
* @return If the function succeeds, the return value is nonzero. <br>
* If the function fails, the return value is zero. To get extended
* error information, call {@link Kernel32#GetLastError()}.
*/
boolean SetCommTimeouts(HANDLE hFile, WinBase.COMMTIMEOUTS lpCommTimeouts);
}
Loading