Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add reconnect to high-level API #109

Closed
wants to merge 2 commits into from

Conversation

ElouanPetereau
Copy link
Contributor

I added the reconnect method to CardConnection() regarding the issue #107 that simply make a call to SCardReconnect().

The default mode is SCARD_SHARE_SHARED and the default disposition is SCARD_RESET_CARD if none as been given and if the connection object doesn't already have one.

I also added a "reconnect" event for the CardConnectionObserver.

@coveralls
Copy link

coveralls commented Mar 18, 2021

Coverage Status

Coverage decreased (-0.2%) to 28.264% when pulling 458894b on ElouanPetereau:master into 6836b14 on LudovicRousseau:master.


# store the way to dispose the card
if disposition == None:
if self.disposition == None:
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pourquoi tester si self.disposition == None ?
self.disposition == None est mis à la bonne valeur dans la méthode connect().

Par contre si j'appele .reconnect() avant d'appeler .connect() ça plante parce que self.disposition n'existe pas.

Copy link
Contributor Author

@ElouanPetereau ElouanPetereau Mar 19, 2021

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Le test était fait pour utiliser la dispostion par défaut de reconnect (SCARD_RESET_CARD) seulement si aucune disposition n'a été donné dans la méthode reconnect() et que la disposition à été changée pour None. Le paramètre n'étant pas privé, il est possible de le changer mais vérifier cela n'est peut être pas du ressort du pyscard.

En y réfléchissant je ne suis pas sûr que garder la disposition de self.disposition si aucune n'est donnée en paramètre de reconnect() soit le bon comportement. Mieux vaut mettre la disposition à celle donnée en paramètre ou à SCARD_RESET_CARD si aucune n'est donnée.
Ce test peut dans ce cas être supprimé.

Suggested change
if self.disposition == None:

Par contre je ne testait pas si une connexion à bien été faite avant de pouvoir effectuer une reconnexion donc effectuer un test sur le paramètre self.hcard en début de méthode serait utile

if self.hcard == None:
    raise CardConnectionException('Card not connected')

Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Peux-tu mettre ton patch à jour avec les corrections STP ?

@LudovicRousseau
Copy link
Owner

Super.
C'est dans a4a0305

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants