75 lines
1.5 KiB
C++
75 lines
1.5 KiB
C++
|
|
// <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ʾĿ<CABE>ģ<EFBFBD><C4A3><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ż<EFBFBD><C5BC>ͨ<EFBFBD><CDA8><EFBFBD>óɹ<C3B3>״̬<D7B4><CCAC><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ͨ<EFBFBD><CDA8><EFBFBD>óɿ<C3B3><C9BF><EFBFBD>״̬<D7B4><CCAC>
|
|||
|
|
// <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ؿ<EFBFBD><D8BF><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>״̬<D7B4><CCAC>
|
|||
|
|
|
|||
|
|
#include "stdafx.h"
|
|||
|
|
#include "windows.h"
|
|||
|
|
#include "stdio.h"
|
|||
|
|
#include "conio.h"
|
|||
|
|
|
|||
|
|
#include "PCI2312.h"
|
|||
|
|
|
|||
|
|
int main(int argc, char* argv[])
|
|||
|
|
{
|
|||
|
|
int iChannel;
|
|||
|
|
BYTE bDISts[16], bDOSts[16];
|
|||
|
|
HANDLE hDevice;
|
|||
|
|
int DeviceLgcID = 0;
|
|||
|
|
|
|||
|
|
hDevice = PCI2312_CreateDevice(DeviceLgcID);
|
|||
|
|
if(hDevice == INVALID_HANDLE_VALUE)
|
|||
|
|
{
|
|||
|
|
printf("CreateDevice Error...\n");
|
|||
|
|
_getch();
|
|||
|
|
return 0;
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
// ǿ<>ҽ<EFBFBD><D2BD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ӳ<EFBFBD><D3B2><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ṹ<EFBFBD><E1B9B9><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ʼ<EFBFBD><CABC><EFBFBD><EFBFBD>ȷ<EFBFBD><C8B7>ֵ
|
|||
|
|
memset(bDOSts, 0x00, sizeof(bDOSts));
|
|||
|
|
for(iChannel=0; iChannel<16; iChannel++)
|
|||
|
|
{
|
|||
|
|
if(iChannel%2 == 0)
|
|||
|
|
bDOSts[iChannel] = 0; // ż<><C5BC>ͨ<EFBFBD><CDA8><EFBFBD><EFBFBD>Ϊ<EFBFBD>͵<EFBFBD>ƽ"0"
|
|||
|
|
else
|
|||
|
|
bDOSts[iChannel] = 1; // <20><><EFBFBD><EFBFBD>ͨ<EFBFBD><CDA8><EFBFBD><EFBFBD>Ϊ<EFBFBD>ߵ<EFBFBD>ƽ"1"
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
Repeat:
|
|||
|
|
for(iChannel=0; iChannel<16; iChannel++)
|
|||
|
|
{
|
|||
|
|
printf("bDOSts[%d] = %d\n", iChannel, bDOSts[iChannel]);
|
|||
|
|
}
|
|||
|
|
printf("Press any key to set DO\n\n");
|
|||
|
|
_getch();
|
|||
|
|
if(!PCI2312_SetDeviceDO(hDevice, bDOSts)) // <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|||
|
|
{
|
|||
|
|
printf("SetDeviceDO Error...\n");
|
|||
|
|
_getch();
|
|||
|
|
goto Exit;
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
printf("\n");
|
|||
|
|
printf("Press any key to get DI\n\n");
|
|||
|
|
_getch();
|
|||
|
|
if(!PCI2312_GetDeviceDI(hDevice, bDISts)) // <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|||
|
|
{
|
|||
|
|
printf("PCI2312_GetDeviceDI...\n");
|
|||
|
|
_getch();
|
|||
|
|
goto Exit;
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
for(iChannel=0; iChannel<16; iChannel++)
|
|||
|
|
{
|
|||
|
|
printf("bDISts[%d] = %d\n", iChannel, bDISts[iChannel]);
|
|||
|
|
}
|
|||
|
|
printf("\n");
|
|||
|
|
char Key;
|
|||
|
|
printf("Press ESC to quit\n");
|
|||
|
|
Key = _getch();
|
|||
|
|
if(Key != 27) goto Repeat;
|
|||
|
|
|
|||
|
|
Exit:
|
|||
|
|
PCI2312_ReleaseDevice(hDevice);
|
|||
|
|
return 0;
|
|||
|
|
}
|
|||
|
|
|