root / pykocard / trunk / pykocard / cartadistcrs.py @ 3536

Revision 3536, 2.5 kB (checked in by jerome, 14 years ago)

Added the card's structure.

  • Property svn:eol-style set to native
  • Property svn:keywords set to Author Date Id Revision
Line 
1# -*- coding: utf-8 -*-
2#
3# PyKoCard
4#
5# PyKoCard : Smart Card / Vending Card managing library
6#
7# (c) 2010 Jerome Alet <alet@librelogiciel.com>
8# This program is free software: you can redistribute it and/or modify
9# it under the terms of the GNU General Public License as published by
10# the Free Software Foundation, either version 3 of the License, or
11# (at your option) any later version.
12#
13# This program is distributed in the hope that it will be useful,
14# but WITHOUT ANY WARRANTY; without even the implied warranty of
15# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
16# GNU General Public License for more details.
17#
18# You should have received a copy of the GNU General Public License
19# along with this program.  If not, see <http://www.gnu.org/licenses/>.
20#
21# $Id$
22#
23
24import sys
25
26class CartadisTCRS :
27    """A class to manage Cartadis TCRS vending card readers.
28
29       Documentation was found in a Cartadis TCRS reader's paper manual.
30
31       Cartadis is a registered trademark from Copie Monnaie France (C.M.F.)
32    """
33    def __init__(self, device, timeout, debug) :
34        """Initializes the connection to the reader."""
35        self.device = device
36        self.timeout = timeout
37        self.debug = debug
38        self.serialport = None
39
40        self.tcrsprompt = chr(13) + chr(10) + '$' # the prompt
41        self.eoc = chr(13) # end of command
42
43        # Each Cartadis vending card contain the following informations :
44        #
45        # the card can only be read on readers for which this group number
46        # was specifically allowed.
47        self.group = None
48        # the number of credits on the card.
49        self.value = None
50        # the two following fields allow the card
51        # to be assigned to a particular individual.
52        # only plastic cards can use such attributes,
53        # for throw-away cards, these values should both be set to 0
54        self.department = None
55        self.account = None
56        # transaction number. Max 3000 for plastic cards, else 500.
57        self.trnum = None
58
59    def __del__(self) :
60        """Ensures the serial link is closed on deletion."""
61        self.close()
62
63    def close(self) :
64        """Closes the serial link if it is open."""
65        if self.serialport is not None :
66            self.serialport.close()
67            self.serialport = None
68
69    def logDebug(self, message) :
70        """Logs a debug message."""
71        if self.debug :
72            sys.stderr.write("%s\n" % message)
73            sys.stderr.flush()
74
Note: See TracBrowser for help on using the browser.