Exemple #1
0
func waitUntilCardPresent(ctx *scard.Context, reader string) error {
	rs := []scard.ReaderState{{Reader: reader, CurrentState: scard.STATE_UNAWARE}}

	for rs[0].EventState&scard.STATE_PRESENT == 0 {
		err := ctx.GetStatusChange(rs, scard.INFINITE)
		if err != nil {
			return err
		}
	}

	return nil
}
Exemple #2
0
func waitUntilCardPresent(ctx *scard.Context, readers []string) (int, error) {
	rs := make([]scard.ReaderState, len(readers))
	for i := range rs {
		rs[i].Reader = readers[i]
		rs[i].CurrentState = scard.STATE_UNAWARE
	}

	for {
		for i := range rs {
			if rs[i].EventState&scard.STATE_PRESENT != 0 {
				return i, nil
			}
		}
		err := ctx.GetStatusChange(rs, scard.INFINITE)
		if err != nil {
			return -1, err
		}
	}

	panic("unreachable")
}