int serial3_init (void)
{
    SIO_Open(&gUart3Channel, 115200);
    /* clear input buffer */
    if(serial3_tstc())
        serial3_getc();
    return 0;
}
Beispiel #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 */
}
Beispiel #3
0
/*
 *	初期化
 */
void Initialize(void)
{
	Count = 0;

	ADR_PJDR = 0;					// LED OFF
	ADR_PJDDR = 0x01;

	sta_cyc(CYCHDR1);

	SIO_Open();
	SIO_FlashBuffer();

	h8s_wrb_mem(P1DDR, 0x0F);		// Channel 入出力方向設定
	h8s_wrb_mem(P1DR, 0);			// Select Channel 0
}
Beispiel #4
0
int scAcr20Init( SC_READER_INFO *ri, const char *param )
{
	BYTE getacrstat[] = { 0x01, 0x00 };
	BYTE setprotocol[] = { 0x03, 0x02, 0x00, 0x10 };
	BYTE setnotification[] = { 0x06, 0x01, 0x02 };

	/* Length of response to GET_ACR_STAT is 19 bytes. Additional bytes
	 * is here, so that it is possible to check if response is to long.
	 */
	BYTE rsp[ 19+1 ];
	int ret, rsplen;
	char *port;

	if( ri->slot!=1 ) return( SC_EXIT_NO_SLOT );

	if( param==NULL ) return( SC_EXIT_BAD_PARAM );

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

	if( ri->si!=NULL ) scAcr20Shutdown( ri );

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

	/* Set main port parameters */
	SIO_SetSpeed( ri->si, 9600 );
	SIO_SetDataBits( ri->si, 8 );
	SIO_SetParity( ri->si, SIO_PARITY_NONE );
	SIO_SetStopBits( ri->si, 1 );
	SIO_SetIOMode( ri->si, SIO_IOMODE_DIRECT );
	SIO_WriteSettings( ri->si );

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

#ifdef ACR20_DEBUG
SIO_SetLogFile( ri->si, "LogAcr20.txt" );
printf("[LOG]");
#endif

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

	/* Send GET_ACR_STAT command to see if a Acr20 is there and
	 * to get MAX_C and MAX_R values.
	 */
	rsplen=sizeof(rsp);
	ret = scAcr20SendCmd( ri, getacrstat, rsp, &rsplen, 0 );
	if( ret!=SC_EXIT_OK ) {
		scAcr20Shutdown( ri );
		return( ret );
	}

	if( rsp[0]!=0x90 ) return( SC_EXIT_UNKNOWN_ERROR );

	/* Response should be 19 bytes long. */
	if( rsplen!=19 ) return( SC_EXIT_PROTOCOL_ERROR );

	/* Get maximum data lengths. */
	ri->maxc = rsp[3+10];
	ri->maxr = rsp[3+11];

	/* Send SET_NOTIFICATION command. */
	rsplen=sizeof(rsp);
	ret = scAcr20SendCmd( ri, setnotification, rsp, &rsplen, 0 );
	if( ret!=SC_EXIT_OK ) {
		scAcr20Shutdown( ri );
		return( ret );
	}

	if( rsp[0]!=0x90 ) return( SC_EXIT_UNKNOWN_ERROR );

	/* Send SET_PROTOCOL command. */
	/* For all current ports, i.e. Unix, PalmOS, MS-Windows, set to 38400. */
	rsplen=sizeof(rsp);
	ret = scAcr20SendCmd( ri, setprotocol, rsp, &rsplen, 0 );
	if( ret!=SC_EXIT_OK ) {
		scAcr20Shutdown( ri );
		return( ret );
	}

	if( rsp[0]!=0x90 ) return( SC_EXIT_UNKNOWN_ERROR );

	/* Set port parameters */
	/* For all current ports, i.e. Unix, PalmOS, MS-Windows, set to 38400. */
	SIO_SetSpeed( ri->si, 38400 );
	SIO_WriteSettings( ri->si );

	ri->major=SC_READER_ACR20;
	ri->minor=SC_ACR20_SERIAL;
	ri->etu=104;

	ri->scShutdown=scAcr20Shutdown;
	ri->scGetCap=scAcr20GetCap;
	ri->scActivate=scAcr20Activate;
	ri->scDeactivate=scAcr20Deactivate;
	ri->scWriteBuffer=NULL;
	ri->scReadBuffer=NULL;
	ri->scWriteChar=NULL;
	ri->scReadChar=NULL;
	ri->scSetSpeed=NULL;
	ri->scCardStatus=scAcr20CardStatus;
	ri->scResetCard=scAcr20ResetCard;
	ri->scPTS=NULL;
	ri->scT0=scAcr20T0;
	ri->scT1=scAcr20T1;
	ri->scSendAPDU=scAcr20SendAPDU;
	ri->scVerifyPIN=NULL;
	ri->scWaitReq=NULL;

	return( SC_EXIT_OK );
}
Beispiel #5
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 );
}