80 lines
1.6 KiB
C
80 lines
1.6 KiB
C
|
|
#include "windows.h"
|
|||
|
|
#include <PCI2312.H>
|
|||
|
|
#include <stdio.h>
|
|||
|
|
|
|||
|
|
|
|||
|
|
static int (__stdcall *getch)(void);
|
|||
|
|
static int (__stdcall *kbhit)(void);
|
|||
|
|
|
|||
|
|
|
|||
|
|
int main(int argc, char* argv[])
|
|||
|
|
{
|
|||
|
|
BYTE bDISts[16];
|
|||
|
|
BYTE bDOSts[16];
|
|||
|
|
int iChannel;
|
|||
|
|
char Key;
|
|||
|
|
HANDLE hDevice;
|
|||
|
|
int DeviceLgcID = 0;
|
|||
|
|
|
|||
|
|
HINSTANCE hInst = LoadLibrary("MSVCRT.DLL");
|
|||
|
|
getch = GetProcAddress(hInst, "_getch");
|
|||
|
|
kbhit = GetProcAddress(hInst, "_kbhit");
|
|||
|
|
|
|||
|
|
hDevice = PCI2312_CreateDevice(DeviceLgcID);
|
|||
|
|
if(hDevice == INVALID_HANDLE_VALUE)
|
|||
|
|
{
|
|||
|
|
printf("Create Device 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");
|
|||
|
|
|
|||
|
|
printf("Press ESC to quit\n");
|
|||
|
|
Key = getch();
|
|||
|
|
if(Key != 27) goto Repeat;
|
|||
|
|
|
|||
|
|
Exit:
|
|||
|
|
PCI2312_ReleaseDevice(hDevice);
|
|||
|
|
return 0;
|
|||
|
|
}
|
|||
|
|
|