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

Revision 3534, 1.7 kB (checked in by jerome, 14 years ago)

Added the PyKoCard? subproject, now that I've finally put my hands onto
a real manual !!! Cartadis TCRS vending card readers / encoders will be
supported soon, they are used in most libraries of French universities,
at least. More than that : the API is small and code will be easy to
write :-)

I think it's better to put all this outside of PyKota since it will
probably be used mostly with Tea4CUPS alone, or a combination of
Tea4CUPS and PyKota. This Python module will be useable without any of
these software too.

  • 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
24class CartadisTCRS :
25    """A class to manage Cartadis TCRS vending card readers.
26
27       Documentation was found in a Cartadis TCRS reader's paper manual.
28
29       Cartadis is a registered trademark from Copie Monnaie France (C.M.F.)
30    """
31    def __init__(self, device, timeout, debug) :
32        """Initializes the connection to the reader."""
33        self.device = device
34        self.timeout = timeout
35        self.debug = debug
36        self.serialport = None
37
38    def __del__(self) :
39        """Ensures the serial link is closed on deletion."""
40        self.close()
41
42    def close(self) :
43        """Closes the serial link if it is open."""
44        if self.serialport is not None :
45            self.serialport.close()
46            self.serialport = None
47
48    def debug(self, message) :
49        """Logs a debug message."""
50        if self.debug :
51            sys.stderr.write("%s\n" % message)
52            sys.stderr.flush()
Note: See TracBrowser for help on using the browser.