aboutsummaryrefslogtreecommitdiffstats
path: root/pySim/transport/__init__.py
diff options
context:
space:
mode:
authorHarald Welte <laforge@osmocom.org>2021-04-02 13:00:18 +0200
committerHarald Welte <laforge@osmocom.org>2021-04-02 21:08:35 +0200
commitee3501fc620de621d6b55cb7b2ea0b960b938f68 (patch)
treeba4e267e4667dfbe5c2ed8a817f25ab9d9d6b691 /pySim/transport/__init__.py
parent082d4e095688df3cbbb8675e4bf4bdade6a28d14 (diff)
Add more documentation to the classes/methods
* add type annotations in-line with PEP484 * convert existing documentation to follow the "Google Python Style Guide" format understood by the sphinx.ext.napoleon' extension * add much more documentation all over the code base Change-Id: I6ac88e0662cf3c56ae32d86d50b18a8b4150571a
Diffstat (limited to 'pySim/transport/__init__.py')
-rw-r--r--pySim/transport/__init__.py64
1 files changed, 35 insertions, 29 deletions
diff --git a/pySim/transport/__init__.py b/pySim/transport/__init__.py
index d720259..f946af8 100644
--- a/pySim/transport/__init__.py
+++ b/pySim/transport/__init__.py
@@ -24,48 +24,53 @@ from pySim.utils import sw_match
#
class LinkBase(object):
+ """Base class for link/transport to card."""
- def wait_for_card(self, timeout=None, newcardonly=False):
- """wait_for_card(): Wait for a card and connect to it
+ def wait_for_card(self, timeout:int=None, newcardonly:bool=False):
+ """Wait for a card and connect to it
- timeout : Maximum wait time (None=no timeout)
- newcardonly : Should we wait for a new card, or an already
- inserted one ?
+ Args:
+ timeout : Maximum wait time in seconds (None=no timeout)
+ newcardonly : Should we wait for a new card, or an already inserted one ?
"""
pass
def connect(self):
- """connect(): Connect to a card immediately
+ """Connect to a card immediately
"""
pass
def disconnect(self):
- """disconnect(): Disconnect from card
+ """Disconnect from card
"""
pass
def reset_card(self):
- """reset_card(): Resets the card (power down/up)
+ """Resets the card (power down/up)
"""
pass
- def send_apdu_raw(self, pdu):
- """send_apdu_raw(pdu): Sends an APDU with minimal processing
+ def send_apdu_raw(self, pdu:str):
+ """Sends an APDU with minimal processing
- pdu : string of hexadecimal characters (ex. "A0A40000023F00")
- return : tuple(data, sw), where
- data : string (in hex) of returned data (ex. "074F4EFFFF")
- sw : string (in hex) of status word (ex. "9000")
+ Args:
+ pdu : string of hexadecimal characters (ex. "A0A40000023F00")
+ Returns:
+ tuple(data, sw), where
+ data : string (in hex) of returned data (ex. "074F4EFFFF")
+ sw : string (in hex) of status word (ex. "9000")
"""
pass
def send_apdu(self, pdu):
- """send_apdu(pdu): Sends an APDU and auto fetch response data
-
- pdu : string of hexadecimal characters (ex. "A0A40000023F00")
- return : tuple(data, sw), where
- data : string (in hex) of returned data (ex. "074F4EFFFF")
- sw : string (in hex) of status word (ex. "9000")
+ """Sends an APDU and auto fetch response data
+
+ Args:
+ pdu : string of hexadecimal characters (ex. "A0A40000023F00")
+ Returns:
+ tuple(data, sw), where
+ data : string (in hex) of returned data (ex. "074F4EFFFF")
+ sw : string (in hex) of status word (ex. "9000")
"""
data, sw = self.send_apdu_raw(pdu)
@@ -82,15 +87,16 @@ class LinkBase(object):
return data, sw
def send_apdu_checksw(self, pdu, sw="9000"):
- """send_apdu_checksw(pdu,sw): Sends an APDU and check returned SW
-
- pdu : string of hexadecimal characters (ex. "A0A40000023F00")
- sw : string of 4 hexadecimal characters (ex. "9000"). The
- user may mask out certain digits using a '?' to add some
- ambiguity if needed.
- return : tuple(data, sw), where
- data : string (in hex) of returned data (ex. "074F4EFFFF")
- sw : string (in hex) of status word (ex. "9000")
+ """Sends an APDU and check returned SW
+
+ Args:
+ pdu : string of hexadecimal characters (ex. "A0A40000023F00")
+ sw : string of 4 hexadecimal characters (ex. "9000"). The user may mask out certain
+ digits using a '?' to add some ambiguity if needed.
+ Returns:
+ tuple(data, sw), where
+ data : string (in hex) of returned data (ex. "074F4EFFFF")
+ sw : string (in hex) of status word (ex. "9000")
"""
rv = self.send_apdu(pdu)