Welcome to the MSR605 Card Reader/Writer user guide! This document will help you get started with using the application to read from and write to magnetic stripe cards.
pip install -r requirements.txt
python main.py
The application supports two major magnetic card standards: ISO 7811 and ISO 7813. Understanding these formats is crucial for proper card reading and writing operations.
ISO 7811 is the international standard for identification cards with magnetic stripes. It defines:
%[format code][primary account number]^[name]^[expiration date][service code][discretionary data]?
%B1234567890123456^CARDHOLDER/NAME^24011234567890123456789?
;[primary account number]=[expiration date][service code][discretionary data]?
;1234567890123456=24011234567890123456?
ISO 7813 is a subset of ISO 7811 specifically for financial transaction cards. Key differences:
%B1234567890123456^CARDHOLDER/NAME^24011234567890123456789?
;1234567890123456=24011234567890123456?
This document provides detailed information about the MSR605 Card Reader/Writer API for developers who want to extend or integrate with the application.
The MSR605 API provides a Python interface for interacting with magnetic stripe card readers/writers. The API is designed to be easy to use while providing access to all device features.
msr605
The main module containing the core functionality.
MSR605
Classclass MSR605:
def __init__(self, port=None, baudrate=9600, timeout=1):
"""Initialize the MSR605 device connection.
Args:
port (str, optional): Serial port name. If None, auto-detection is attempted.
baudrate (int, optional): Communication baud rate. Defaults to 9600.
timeout (int, optional): Read timeout in seconds. Defaults to 1.
"""
pass
def connect(self):
"""Establish connection to the device."""
pass
def disconnect(self):
"""Close the connection to the device."""
pass
def is_connected(self):
"""Check if the device is connected.
Returns:
bool: True if connected, False otherwise.
"""
pass
def read_card(self, tracks=[1, 2, 3]):
"""Read data from a magnetic stripe card.
Args:
tracks (list, optional): List of tracks to read (1, 2, 3). Defaults to all tracks.
Returns:
dict: Dictionary containing track data with track numbers as keys.
"""
pass
def write_card(self, track_data, verify=True):
"""Write data to a magnetic stripe card.
Args:
track_data (dict): Dictionary with track numbers as keys and data as values.
verify (bool, optional): Whether to verify the written data. Defaults to True.
Returns:
bool: True if write was successful, False otherwise.
"""
pass
| Command | Description | Format |
|———|————-|——–|
| ESC e
| Reset device | \x1be
|
| ESC s
| Read card | \x1bs
|
| ESC w
| Write card | \x1bw
|
| ESC x
| Set security level | \x1bx
|
| Response | Description |
|———-|————-|
| \x1b1
| Command successful |
| \x1b2
| Command failed |
| \x1b3
| No card present |
| \x1b4
| Write protect error |
from msr605 import MSR605
# Initialize and connect to the device
device = MSR605()
device.connect()
# Read all tracks
data = device.read_card()
print(f"Track 1: {data.get(1, 'No data')}")
print(f"Track 2: {data.get(2, 'No data')}")
print(f"Track 3: {data.get(3, 'No data')}")
# Read specific tracks
data = device.read_card(tracks=[1, 2])
# Disconnect
device.disconnect()
from msr605 import MSR605
# Initialize and connect to the device
device = MSR605()
device.connect()
# Prepare track data
track_data = {
1: "%B1234567890123456^CARDHOLDER/NAME^25121010000000000000000000000000000?",
2: ";1234567890123456=25121010000000000000?",
3: "" # Empty track 3
}
# Write to card
success = device.write_card(track_data)
print(f"Write {'successful' if success else 'failed'}")
# Disconnect
device.disconnect()
| Character | Description |
|———–|————-|
| %
| Start sentinel (Track 1) |
| ;
| Start sentinel (Track 2 & 3) |
| ?
| End sentinel |
| ^
| Separator (Track 1) |
| =
| Separator (Track 2) |
| \\
| Escape character |
| Exception | Description |
|———–|————-|
| MSR605Error
| Base exception for all MSR605 errors |
| MSR605ConnectionError
| Connection-related errors |
| MSR605CommandError
| Command execution errors |
| MSR605CardError
| Card operation errors |
from msr605 import MSR605, MSR605Error
try:
device = MSR605()
device.connect()
data = device.read_card()
print(data)
except MSR605Error as e:
print(f"Error: {e}")
finally:
if 'device' in locals():
device.disconnect()
from msr605 import MSR605
def main():
try:
# Initialize and connect
device = MSR605()
print("Connecting to device...")
device.connect()
if not device.is_connected():
print("Failed to connect to device")
return
print("Connected. Please swipe a card...")
# Read card
data = device.read_card()
print("\nCard Data:")
for track, value in data.items():
print(f"Track {track}: {value}")
except Exception as e:
print(f"An error occurred: {e}")
finally:
if 'device' in locals():
device.disconnect()
print("\nDisconnected from device")
if __name__ == "__main__":
main()
from msr605 import MSR605
import json
import time
class CardManager:
def __init__(self):
self.device = MSR605()
self.config = self._load_config()
def _load_config(self):
# Load configuration from file
try:
with open('config.json', 'r') as f:
return json.load(f)
except FileNotFoundError:
return {'baudrate': 9600, 'timeout': 1}
def start(self):
try:
# Connect with config
self.device = MSR605(
baudrate=self.config.get('baudrate', 9600),
timeout=self.config.get('timeout', 1)
)
self.device.connect()
print("Card reader ready. Press Ctrl+C to exit.")
while True:
print("\nSwipe a card or press Ctrl+C to exit...")
try:
data = self.device.read_card()
self._process_card(data)
except Exception as e:
print(f"Error reading card: {e}")
time.sleep(0.5)
except KeyboardInterrupt:
print("\nExiting...")
finally:
if hasattr(self, 'device') and self.device.is_connected():
self.device.disconnect()
def _process_card(self, data):
print("\nCard Data:")
for track, value in data.items():
print(f"Track {track}: {value}")
# Save to file
with open('card_data.log', 'a') as f:
f.write(f"{time.ctime()}: {data}\n")
if __name__ == "__main__":
manager = CardManager()
manager.start()
The MSR605 is a software application that allows you to read from and write to magnetic stripe cards using compatible card reader/writer devices. It provides a user-friendly interface for managing card data.
The application is designed to work on:
You can download the latest release from our GitHub Releases page.
The application supports standard magnetic stripe formats:
The application processes all data locally on your computer. No card data is transmitted over the internet unless you explicitly choose to export or share it.
Yes, the application supports encrypting card data before writing to the card. Enable this option in the settings.
We welcome contributions! Please see our Contributing Guidelines for more information.
Yes, the application provides a Python API for integration with other applications. See the API Documentation for details.
Please open an issue on our GitHub Issues page with the following information:
Yes, you can join our community forum at forum.example.com to ask questions and share experiences with other users.
This software is licensed under the GPLv3 License. See the LICENSE file for details.
Yes, the GPLv3 license allows for commercial use, but be aware of the license requirements regarding distribution of source code for any modifications you make.
The complete source code is available on GitHub.
GUI.py
cardReader.py
version.py
sponsor.py
about.py
The application implements a flexible card format system supporting multiple magnetic stripe card standards. This section details the technical implementation of the format handling system.
classDiagram
class CardFormat {
<<enumeration>>
ISO_7811
ISO_7813
}
class TrackSpecification {
+format_name: str
+track_number: int
+max_length: int
+allowed_chars: str
+start_sentinel: str
+end_sentinel: str
+field_separator: str
+__init__()
+validate(data: str) -> Tuple[bool, str]
}
class CardFormatManager {
+get_track_spec(format: CardFormat, track_num: int) -> TrackSpecification
+validate_track_data(format: CardFormat, track_num: int, data: str) -> Tuple[bool, str]
+format_track_data(format: CardFormat, track_num: int, data: str) -> str
+parse_track_data(format: CardFormat, track_num: int, data: str) -> Dict
+detect_format(tracks: List[str]) -> CardFormat
}
CardFormatManager --> TrackSpecification
TrackSpecification --> CardFormat
%[format code][primary account number]^[name]^[expiration date][service code][discretionary data]?
;[primary account number]=[expiration date][service code][discretionary data]?
Reading a Card
Writing a Card
pyinstaller
for executableread_card()
write_card()
decode_track()
export_database()
This document describes the advanced card data visualization features available in the MSR605 Card Reader/Writer application.
The visualization module provides interactive and static visualizations of magnetic stripe card data, helping users analyze and understand the structure and content of card tracks. The visualizations are integrated into the application’s UI and update automatically when new card data is read.
Visualizes the frequency of each character in a track’s data using a bar chart. This helps identify:
Displays the binary representation of the track data as a waveform, showing:
Presents key metrics about the track data:
Analyzes and visualizes the structure of track data by:
matplotlib
: For creating static visualizationsseaborn
: For enhanced statistical visualizationsplotly
: For interactive visualizations (future use)The visualization system is implemented in script/visualization.py
and integrated with the main UI through the AdvancedFunctionsWidget
class.
Track 1: %B1234567890123456^DOE/JOHN^24051234567890123456789?
Track 2: ;1234567890123456=240512345678901?
pip install -r requirements.txt
)