// 7K87K_Basic.cpp : Defines the entry point for the console application. // #include "stdafx.h" #include "stdio.h" #include "PACSDK.h" int main(int argc, char* argv[]) { BOOL err; char strErr[32]; char SendData[20]; char Response[20]; char connectionstring[32]; int iSlot=0; printf("ICPDAS (R) SDK Demo for XP-8000\n"); printf("This demo is for remote 87K and 7K modules.\n"); memset(SendData,0,sizeof(SendData)); memset(Response,0,sizeof(Response)); //Get com port printf("Input com's connectionstring(like\"COM2,9600,N,8,1\"):"); scanf("%s",connectionstring); //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; } while(1) { printf("Type \"q\" to exit\n"); printf("Input command:"); scanf("%s",SendData); if(!strcmp(SendData,"q") || !strcmp(SendData,"quit")) break; //use uart_SendCmd function to send command, and use 3th parameter to get result BOOL iret = uart_SendCmd(hPort, SendData,Response); if(!iret) { pac_GetErrorMessage(pac_GetLastError(), strErr); printf("Error: %s. The error code is %x\n", strErr, pac_GetLastError()); } else { printf("Response:%s\n",Response); } printf("\n"); } 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; }