/* Test with I-87054 DIO Module at Slot 03 of LinCon. sa This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. i87kdio.c v1.0 2004.9.1 by Edward */ #include #include #include "icpdas_mbs.h" #include "msw.h" char szSend[80], szReceive[80]; DWORD dwBuf[12]; float fBuf[12]; void change_bit(int *val, int num, char bitval) { *val=((*val & ~(1< 0) { printf("open Slot failed!\n"); return (-1); } //Check Open_Com1 wRetVal = Open_Com(COM1, 115200, Data8Bit, NonParity, OneStopBit); if (wRetVal > 0) { printf("open port failed!\n"); return (-1); } //Choose Slot3 ChangeToSlot(4); while (1) { for (i=0;i<8;i++) { if (iMemory_DO[i]) { change_bit(&tval,i,1); } else { change_bit(&tval,i,0); } } if (tval != tval2 ) { //--- digital output ---- **(DigitalOut_87K()**) dwBuf[0] = 1; // COM Port dwBuf[1] = 00; // Address dwBuf[2] = 0x87054; // ID dwBuf[3] = 0; // CheckSum disable dwBuf[4] = 100; // TimeOut , 100 msecond dwBuf[5] = tval; // digital output dwBuf[6] = 0; // string debug wRetVal = DigitalOut_87K(dwBuf, fBuf, szSend, szReceive); // DO Output // printf("DO Value= %u\n", dwBuf[5]); tval2=tval; } usleep(100); //--- digital Input ---- **(DigitalIn_87K()**) dwBuf[0] = 1; // COM Port dwBuf[1] = 00; // Address dwBuf[2] = 0x87054; // ID dwBuf[3] = 0; // CheckSum disable dwBuf[4] = 100; // TimeOut , 100 msecond dwBuf[6] = 0; // string debug DigitalIn_87K(dwBuf, fBuf, szSend, szReceive); // DI Input //get di value and put value to share memory set_di(dwBuf[5]); // printf("DI Value= %d\n",dwBuf[5]); usleep(100); } Close_Com(COM1); Close_SlotAll(); return 0; }