com_GetDigitalByte
This function reads a complete byte from a digital input port of a device by
Serial Port.
Declaration
BOOL
com_GetDigitalByte ( HANDLE hDevice,
DWORD
dwPort,
LPBYTE
lpbyPortState
);
Parameters
hDevice
A valid device handle, previously obtained from com_OpenDevice
dwPort
The index of the port on the card to manipulate. The first port has index 0.
For more information, please see “Read Address Table” following below.
lpbyPortState
A pointer to a variable of type BYTE receiving the new state of the port
Return value
TRUE if successful, FALSE otherwise.
If an error occurred, GetLastError() may return the following values:
ERROR_INVALID_PARAMETER – The handle passed was invalid, or the port number was out of
range for the device selected.
Example
HANDLE hDevice = com_OpenDevice(0x01,0);
if (hDevice != INVALID_HANDLE_VALUE)
{
com_GetDigitalByte( hDevice, 0, &byState); // reads the state of the first input port
com_CloseDevice(hDevice);
}
Remarks
Please see “Serial_Communication.pdf” to set hardware for serial communication, and USB_LAB
-
KIT, USB_STARTER, USB_8PR are not supported by serial communication.