#include "pds700.h"

int main(int argc, char *argv[])
{
	WORD rs;
	char in_str[BUFSIZ], tmp[BUFSIZ], out_str[BUFSIZ];
	pds_mod_t mod;
	int index = 0, i;

	if (argc!= 4)
	{
		fprintf(stderr,"Usage:%s [PDS ip] [comport number] [baudrate]\a\n",argv[0]);
		exit(1);
	}
	
	memset(&mod, 0, sizeof(pds_mod_t));
	//BaudRate = 115200, DataFormat = 8n1
	rs = Open_Com(&mod, argv[1], 10000, atoi(argv[2]), atoi(argv[3]), 8, 0, 1);

	if(rs)
	{
		printf("Error Code %d : Open PDS-700 COM%d Error\n", rs, atoi(argv[2]));
		exit(1);
	}


	printf("Send String to PDS COM%d : ",atoi(argv[2]));
	scanf("%s", out_str);

	rs = Send_String(&mod, atoi(argv[2]), out_str);

	if(rs)
		printf("Error Code %d : Send String Error\n", rs);

	rs = Read_String(&mod, atoi(argv[2]), in_str);

	if(rs)
               	printf("Error Code %d : Read String Error\n", rs);

	printf("Read string from PDS COM%d : %s\n", atoi(argv[2]), in_str);

	Close_Module(&mod);
}
