38.9.4.1 Function for read/write
Direct read API of single handle system
INT WINAPI
ReadDeviceBit(LPCSTR sNodeName,LPCSTR sDeviceName,WORD* owData,WORD
wCount);
INT WINAPI
ReadDevice16(LPCSTR sNodeName,LPCSTR sDeviceName,WORD* owData,WORD
wCount);
INT WINAPI
ReadDevice32(LPCSTR sNodeName,LPCSTR sDeviceName,DWORD*
odwData,WORD wCount);
INT WINAPI
ReadDeviceBCD16(LPCSTR sNodeName,LPCSTR sDeviceName,WORD*
owData,WORD wCount);
INT WINAPI
ReadDeviceBCD32(LPCSTR sNodeName,LPCSTR sDeviceName,DWORD*
odwData,WORD wCount);
INT WINAPI
ReadDeviceFloat(LPCSTR sNodeName,LPCSTR sDeviceName,FLOAT*
oflData,WORD wCount);
INT WINAPI
ReadDeviceDouble(LPCSTR sNodeName,LPCSTR sDeviceName,DOUBLE*
odbData,WORD wCount);
INT WINAPI
ReadDeviceStr(LPCSTR sNodeName,LPCSTR sDeviceName,LPSTR psData,WORD
wCount);
INT WINAPI
ReadDevice(LPCSTR sNodeName,LPCSTR sDeviceName,LPVOID
pData,WORD wCount,WORD wAppKind);
INT WINAPI
ReadDeviceVariant(LPCSTR sNodeName,LPCSTR sDeviceName,LPVARIANT
pData,WORD wCount,WORD wAppKind);
Single handle system API
INT WINAPI
WriteDeviceBit(LPCSTR sNodeName,LPCSTR sDeviceName,WORD*
pwData,WORD wCount);
INT WINAPI
WriteDevice16(LPCSTR sNodeName,LPCSTR sDeviceName,WORD* pwData,WORD
wCount);
INT WINAPI
WriteDevice32(LPCSTR sNodeName,LPCSTR sDeviceName,DWORD*
pdwData,WORD wCount);
INT WINAPI
WriteDeviceBCD16(LPCSTR sNodeName,LPCSTR sDeviceName,WORD*
pwData,WORD wCount);
INT WINAPI
WriteDeviceBCD32(LPCSTR sNodeName,LPCSTR sDeviceName,DWORD*
pdwData,WORD wCount);
INT WINAPI
WriteDeviceFloat(LPCSTR sNodeName,LPCSTR sDeviceName,FLOAT*
pflData,WORD wCount);
INT WINAPI
WriteDeviceDouble(LPCSTR sNodeName,LPCSTR sDeviceName,DOUBLE*
pdbData,WORD wCount);
INT WINAPI
WriteDeviceStr(LPCSTR sNodeName,LPCSTR sDeviceName,LPCSTR
psData,WORD wCount);
INT WINAPI
WriteDevice(LPCSTR sNodeName,LPCSTR sDeviceName,LPVOID
pData,WORD wCount,WORD wAppKind);
INT WINAPI
WriteDeviceVariant(LPCSTR sNodeName,LPCSTR sDeviceName,LPVARIANT
pData,WORD wCount,WORD wAppKind);
Group Symbol Read API for Single Handle
INT WINAPI
ReadSymbol(LPCSTR sNodeName,LPCSTR sSymbolName,LPVOID
oReadBufferData);
INT WINAPI
ReadSymbolVariant(LPCSTR sNodeName,LPCSTR sSymbolName,LPVARIANT
pData);
Group Symbol Write API for Single Handle
INT WINAPI
WriteSymbolD(LPCSTR sNodeName,LPCSTR sSymbolName,LPVOID
pWriteBufferData);
INT WINAPI
WriteSymbolVariantD(LPCSTR sNodeName,LPCSTR sSymbolName,LPVARIANT
pData);
Argument
sDeviceName: Directly describes the symbol
names and device addresses registered in GP-Pro EX.
-
For example, use a symbol
"SWITCH1"
-
For example, directly specify the device address
"M100"
The following table shows the data types that
you can specify when using symbols in each function.
Function
|
Symbol data type
|
Bit
|
16 Bit
|
32 Bit
|
Float
|
Double
|
String
|
Signed/ Unsigned/ Hexadecimal
|
BCD
|
Signed/ Unsigned/ Hexadecimal
|
BCD
|
XXXDeviceBit
|
○
|
—
|
—
|
—
|
—
|
—
|
—
|
—
|
XXXDevice16
|
—
|
○
|
—
|
—
|
—
|
—
|
—
|
—
|
XXXDevice32
|
—
|
—
|
—
|
○
|
—
|
—
|
—
|
—
|
XXXDeviceBCD16
|
—
|
—
|
○
|
—
|
—
|
—
|
—
|
—
|
XXXDeviceBCD32
|
—
|
—
|
—
|
—
|
○
|
—
|
—
|
—
|
XXXDeviceFloat
|
—
|
—
|
—
|
—
|
—
|
○
|
—
|
—
|
XXXDeviceDouble
|
—
|
—
|
—
|
—
|
—
|
—
|
○
|
—
|
XXXDeviceStr
|
—
|
—
|
—
|
—
|
—
|
—
|
—
|
○
|
XXXDevice
|
○
|
○
|
○
|
○
|
○
|
○
|
○
|
○
|
Defines the destination pointer for values
that are read or values that are written. For each function, please
define the corresponding data format pointer.
Data types for access
|
Argument type
|
Bit Data
|
WORD *
pwData
|
16 bit data
|
WORD *
pwData
|
32 bit data
|
DWORD *
pdwData
|
16-bit BCD data
|
WORD *
pwData
|
32-bit BCD data
|
DWORD *
pdwData
|
Single float number data
|
FLOAT *
pflData
|
Double float number data
|
DOUBLE *
pdbData
|
Text data
|
LPTSTR
psData
|
General data
|
LPVOID
pData
|
General data (for VB)
|
LPVARIANT
pData
|
For the Read/WriteDeviceStr function, the
amount of text data is expressed in single-byte units. If the
symbol refers to a 16-bit device, use two characters to specify the
number. If it refers to a 32-bit device, use four characters.
The following table shows the maximum amount of read/write
data.
Data types for access
|
Read/Write
|
Bit Data
|
255
|
16 bit data
|
1020
|
32 bit data
|
510
|
16-bit BCD data
|
1020
|
32-bit BCD data
|
510
|
Single float number data
|
510
|
Double float number data
|
255
|
Text data
|
1020 characters (Single-byte)
|
To specify the Data Type Value, you can
either directly specify the value or specify using a constant name.
For more details, please refer to the following.
38.9.5.1 Data Type
Return value (NULL)
Normal end: 0
Abnormal end: Error Code
Supplementary
pwData stores the same amount of data as in
wCount starting from D0 bit.
For example, when wCount = 20
|
F
|
E
|
D
|
C
|
B
|
A
|
9
|
8
|
7
|
6
|
5
|
4
|
3
|
2
|
1
|
0
|
PwData
|
16
|
15
|
14
|
13
|
12
|
11
|
10
|
9
|
8
|
7
|
6
|
5
|
4
|
3
|
2
|
1
|
PwData+1
|
*
|
*
|
*
|
*
|
*
|
*
|
*
|
*
|
*
|
*
|
*
|
*
|
20
|
19
|
18
|
17
|
it is more efficient to read/write in 16/32
bits using Read/WriteDevice16 and Read/WriteDevice32 than using
Read/WriteDeviceBit.
"*" contains undefined values. Mask the
value using an application program.
Use these functions for handling data as BCD
internally in the device/PLC. Note that data (pxxData contents) to
be sent to /received from the functions is binary data, not
BCD.
BCD conversion is performed in the [WinGP SDK]. Negative numbers
cannot be handled.
Function Name
|
Decimal notation
|
Hexadecimal notation
|
Read/WriteDeviceBCD16
|
0 to 9999
|
0000 to 270F
|
Read/WriteDeviceBCD32
|
0 to 99999999
|
00000000 to 05F5E0FF
|
For variables to receive text data, secure
sufficient data space to receive the data.
|