# -*- coding: utf-8 -*- # # PyKoCard # # PyKoCard : Smart Card / Vending Card managing library # # (c) 2010 Jerome Alet # This program is free software: you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by # the Free Software Foundation, either version 3 of the License, or # (at your option) any later version. # # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. # # You should have received a copy of the GNU General Public License # along with this program. If not, see . # # $Id$ # import sys class CartadisTCRS : """A class to manage Cartadis TCRS vending card readers. Documentation was found in a Cartadis TCRS reader's paper manual. Cartadis is a registered trademark from Copie Monnaie France (C.M.F.) """ def __init__(self, device, timeout, debug) : """Initializes the connection to the reader.""" self.device = device self.timeout = timeout self.debug = debug self.serialport = None def __del__(self) : """Ensures the serial link is closed on deletion.""" self.close() def close(self) : """Closes the serial link if it is open.""" if self.serialport is not None : self.serialport.close() self.serialport = None def logDebug(self, message) : """Logs a debug message.""" if self.debug : sys.stderr.write("%s\n" % message) sys.stderr.flush()