// 7K87K_ao.cpp : Defines the entry point for the console application. // #include "stdafx.h" #include "stdio.h" #include "PACSDK.h" int main(int argc, char* argv[]) { if(argc < 6) { printf("ICPDAS (R) SDK Demo for XP-8000\n\n"); printf("This demo is for remote 87K and 7K modules.\n"); printf("usage: 7K87K_ao.exe ConnectionString Address iChannel iAO_TotalCh fAO_value\n\n"); printf("where\n"); printf(" ConnectionString:\n"); printf(" -the COM port, baud rate, parity bits,\n"); printf(" data bits, and stop bits.\n\n"); printf(" Address:\n"); printf(" - number of slot for remote modules\n"); printf(" iChannel:\n"); printf(" - AO value read from the channel\n"); printf(" iAO_TotalCh:\n"); printf(" - number of AO's channel\n"); printf(" fAO_value:\n"); printf(" - AO value to write\n"); } else { BOOL err; char strErr[32]; float fValue = 0; char connectionstring[32]; sprintf(connectionstring, "%s",argv[1]); //Open com port except COM1,COM1 is for local. //This demo is for remote 87K and 7K modules. HANDLE hPort = uart_Open(connectionstring); if(hPort == INVALID_HANDLE_VALUE) { pac_GetErrorMessage(pac_GetLastError(), strErr); printf("Open Error: %s. The error code is %x\n", strErr, pac_GetLastError()); return 0; } //Read AO value err = pac_WriteAO(hPort, PAC_REMOTE_IO(atoi(argv[2])), atoi(argv[3]), atoi(argv[4]), atof(argv[5])); if(err == FALSE) { pac_GetErrorMessage(pac_GetLastError(), strErr); printf("Read AO's Error: %s. The error code is %x\n", strErr, pac_GetLastError()); return 0; } //Close com port err = uart_Close(hPort); if(err == FALSE) { pac_GetErrorMessage(pac_GetLastError(), strErr); printf("Close Error: %s. The error code is %x\n", strErr, pac_GetLastError()); return 0; } } return 0; }