Example #1
0
int scAcr20Shutdown( SC_READER_INFO *ri )
{
	if( ri->si==NULL ) return( SC_EXIT_OK );

	SIO_Close( ri->si );
	ri->si=NULL;

	return( SC_EXIT_OK );
}
Example #2
0
void main ()
{
	char
		taip [80];
	static char
		rbuf [BUFSIZ], tbuf [BUFSIZ];
	int
		done, pid, chr;

	printf ("\n");
	printf ("       Sample TAIP Query/Response Program\n");
	printf ("       Copyright Trimble Navigation 1992\n");
	printf ("       Version %s\n\n", VERSION);

	/*
	*	Configure COM1
	*/
	pid = 0;
	SIO_Open (NULL);
	SIO_IntOpen  (0, 8+4, -1, NULL);
	SIO_PortOpen (pid, 0x3f8, 0, HS_DTR | HS_RTS | HS_CTS, NULL);
	SIO_PortMode (pid, 4800L, 8, NOPARITY, ONEBIT, ONEBIT, NULL);
	SIO_RxOpen   (pid, rbuf, (long)BUFSIZ, HS_NONE, NULL);
	SIO_TxOpen   (pid, tbuf, (long)BUFSIZ, HS_NONE, NULL);

	printf ("       Serial Parameters: COM1, 4800 Baud, 8 data bits, 1 stop bit, no parity\n\n");
	
	printf ("       Press <Enter> to Poll for a PV packet\n");
	printf ("       Press <Escape> to quit\n");
	
	for (done = FALSE; !done; ) {	/* While not done... */
		while (SIO_RxGet (pid, &chr) == 0) { /* While characters coming in */
			taip_byte (chr);	/* send them to the TAIP decoder */
		}
		if (kbhit ()) {		/* if keyboard is hit... */
			switch (getch ()) {		/* get key and switch() */
			case 27:	/* <Escape>, Quit */
				done = TRUE;
				break;
			case '\r':	/* <Enter>, Poll for a PV packet */
				fmt_taip (taip, "QPV");		/* format a TAIP packet */
				ser_send (0, taip, strlen (taip));	/* send it */
				printf ("\nSend: %s\n", taip);		/* print it */
				break;
			}
		}
	}
	SIO_Close (0);	/* Shutdown serial ports */
}
Example #3
0
int scAcr20Detect( SC_READER_DETECT_INFO *rdi )
{
	SIO_INFO *si;
	char *port;
	BYTE buffer[14];

	rdi->prob=0;
	strncpy( rdi->name, "ACR20", SC_READER_NAME_MAXLEN );
	rdi->major=SC_READER_ACR20;
	rdi->minor=0;
	rdi->slots=1;
	rdi->pinpad=FALSE;
	rdi->display=FALSE;

	if( strlen(rdi->param)>=SC_READER_PARAM_MAXLEN )
		return( SC_EXIT_BAD_PARAM );

	if( (strcmp(rdi->param,"0")==0) || (strcmp(rdi->param,"1")==0) ||
		(strcmp(rdi->param,"2")==0) || (strcmp(rdi->param,"3")==0) ) {
		port=scReaderExpandPort( rdi->param );
		if( port==NULL ) return( SC_EXIT_BAD_PARAM );
	} else port=rdi->param;

	/* Open port */
	si = SIO_Open( port );
	if( si==NULL ) return( SC_EXIT_IO_ERROR );

	/* Set main port parameters */
	SIO_SetSpeed( si, 9600 );
	SIO_SetDataBits( si, 8 );
	SIO_SetParity( si, SIO_PARITY_EVEN );
	SIO_SetStopBits( si, 2 );
	SIO_SetIOMode( si, SIO_IOMODE_DIRECT );
	SIO_WriteSettings( si );

	/* Get unwanted bytes */
#ifdef __palmos__
	SIO_Flush(si);
#else
	while(SIO_ReadChar(si)!=-1);
#endif /* __palmos__ */

	/* Wait for status message. */
	SIO_WaitForData( si, 2000000 );

	if( SIO_ReadBuffer( si, buffer, 14 ) != 14 ) {
		SIO_Close( si );
		return( SC_EXIT_OK );
	}

	SIO_Close( si );

	if( memcmp( buffer, "\x02\x30\x31\x46\x46\x30\x30\x30\x31\x31\x32", 11 ) )
		return( SC_EXIT_OK );

	rdi->minor=SC_ACR20_SERIAL;
	/* Unless there is a other reader which sends the same message on
	 * power on it is a sure sign, that his reader is present.
	 */
	rdi->prob=250;

	return( SC_EXIT_OK );
}