
/**************************************************************************/
/*  Program	: example2.c   (For RS485)				  */
/*  Description	: Sends	a string from COM1 to COM2 then	reads it back	  */
/*		  from COM2 and	displays it on the screen. It use library */
/*		  function call						  */
/*									  */
/*  (RS485)				COM1		      COM2	  */
/*  Jumper  &				DATA0+	<------>      DATA1+	  */
/*  Setting &	  JP1  - 485		DATA0-	<------>      DATA1-	  */
/*  Signal								  */
/*  Wiring								  */
/*									  */
/**************************************************************************/


#include "adam4500.h"
void	main(void)
{
int	i;
unsigned int length;
unsigned char data[200];

	if (!comm_init(1000))
	{
		printf("COM port initialization failed !\n");
		exit();
	}
	if(!comm_open(1,9600L,0,8,1,1))
	{
		printf("COM1 port open failed !\n");
		exit();
	}

	if(!comm_open(2,9600L,0,8,1,0))
	{
		printf("COM2 port open failed !\n");
		exit();
	}

	for (i=0;i<100;i++)
		if (comm_send(i,1));

	if(comm_get_rec_datas(&length ,	&data ,	2))
		for (i=0; i<length; i++)
			printf("received data=%d",data[i]);

	if (!comm_exit())
	{
		printf("COM port release failed !\n");
		exit();
	}
}




