### Install and Reload udev Rules (Bash) Source: https://context7.com/raleighlittles/itosayde-msr-880/llms.txt Installs the udev rules file, reloads the udev rules, and triggers them to apply the changes. Also verifies device visibility using lsusb. ```bash # Install udev rules and reload sudo cp 101-itosayde-msr-880.rules /etc/udev/rules.d/ sudo udevadm control --reload-rules sudo udevadm trigger # Verify device is visible lsusb | grep 0802 # Output: Bus 001 Device 017: ID 0802:0005 Mako Technologies, LLC STM32 QWERT HID ``` -------------------------------- ### Send Device Connect Command (C++) Source: https://context7.com/raleighlittles/itosayde-msr-880/llms.txt Establishes communication with the card reader firmware after USB initialization by sending a connect handshake sequence. Ensure libusb is installed and the device is initialized. ```cpp // Connect command sequence (captured from Wireshark) std::array connect_data = {0x02, 0x00, 0x02, 0x0c, 0x19, 0x17, 0x00, 0x00}; int* bytes_transferred_cnt = nullptr; rc = libusb_interrupt_transfer(lusb_dev_hndl, endpointOut, connect_data.data(), connect_data.size(), bytes_transferred_cnt, 0); if (rc != LIBUSB_SUCCESS) { std::cerr << "ERROR: Couldn't send connect sequence, rc=" << rc << std::endl; return -1; } std::cout << "Connect handshake sent successfully" << std::endl; ``` -------------------------------- ### Build C++ Application with CMake Source: https://context7.com/raleighlittles/itosayde-msr-880/llms.txt Builds the C++ driver application using CMake, linking against the libusb-1.0 library. Assumes dependencies are installed and the source code is in the 'app' directory. ```bash # Install dependencies (Debian/Ubuntu) sudo apt-get install libusb-1.0-0-dev cmake build-essential # Build the application cd app mkdir build && cd build cmake .. make # Run the application (requires root or proper udev rules) sudo ./itosayde_msr_880_driver_demo.out ``` -------------------------------- ### Send Device Connect Command (Python) Source: https://context7.com/raleighlittles/itosayde-msr-880/llms.txt Python equivalent for sending the connect handshake sequence to establish communication with the card reader. Requires a connected MSR-880 device and appropriate library setup. ```python # Python equivalent - send connect handshake connect_data = [0x02, 0x00, 0x02, 0x0c, 0x19, 0x17, 0x00, 0x00] result = msr880_usb_device.write(ENDPOINT_OUT, connect_data) if result != len(connect_data): print(f"Error: transmitted {len(connect_data)} bytes but only sent {result}") else: print("Connect handshake successful") ``` -------------------------------- ### Initialize USB Connection (Python) Source: https://context7.com/raleighlittles/itosayde-msr-880/llms.txt Connects to the MSR-880 USB device using pyusb, detaching kernel drivers from interfaces 0 and 1 if active. Requires pyusb library. ```python import usb.core import usb.util # USB constants VENDOR_ID = 0x0802 PRODUCT_ID = 0x0005 ENDPOINT_OUT = 0x01 # Find and connect to the MSR-880 device msr880_usb_device = usb.core.find(idVendor=VENDOR_ID, idProduct=PRODUCT_ID) if msr880_usb_device is None: raise ValueError("Unable to find MSR-880 device!") else: print("[DEBUG] Connected to USB device") # Detach kernel driver from both interfaces if active if msr880_usb_device.is_kernel_driver_active(0): msr880_usb_device.detach_kernel_driver(0) if msr880_usb_device.is_kernel_driver_active(1): msr880_usb_device.detach_kernel_driver(1) print("Device ready for communication") ``` -------------------------------- ### Initialize USB Connection (C++) Source: https://context7.com/raleighlittles/itosayde-msr-880/llms.txt Initializes libusb, connects to the MSR-880 device using its vendor and product IDs, and claims the necessary interfaces for userspace communication. Requires libusb-1.0 and 'usb_wrapper.h'. ```cpp #include #include #include "usb_wrapper.h" int main() { libusb_context* lusb_context = nullptr; // Initialize libusb library int rc = libusb_init(&lusb_context); if (rc != LIBUSB_SUCCESS) { std::cerr << "ERROR: Failed to initialize libusb" << std::endl; return -1; } // Enable info-level logging libusb_set_option(lusb_context, LIBUSB_OPTION_LOG_LEVEL, LIBUSB_LOG_LEVEL_INFO); // Open device by vendor/product ID libusb_device_handle* lusb_dev_hndl = libusb_open_device_with_vid_pid( lusb_context, vendorID, productID); if (!lusb_dev_hndl) { std::cerr << "ERROR: Device not found or cannot open" << std::endl; return -1; } // Detach kernel driver and claim both interfaces (0 and 1) for (unsigned int interface_num = 0; interface_num < 2; interface_num++) { if (libusb_kernel_driver_active(lusb_dev_hndl, interface_num)) { if (libusb_detach_kernel_driver(lusb_dev_hndl, interface_num) != LIBUSB_SUCCESS) { std::cerr << "ERROR: Failed to detach kernel driver on interface #" << interface_num << std::endl; return -1; } } rc = libusb_claim_interface(lusb_dev_hndl, interface_num); if (rc != LIBUSB_SUCCESS) { std::cerr << "ERROR: Cannot claim interface " << interface_num << ", rc="<< rc << std::endl; return -1; } } std::cout << "Device connected successfully!" << std::endl; // Device is now ready for communication return 0; } ``` -------------------------------- ### Initiate Magnetic Stripe Card Read (C++) Source: https://context7.com/raleighlittles/itosayde-msr-880/llms.txt Sends two sequential command sequences to initiate reading a magnetic stripe card. Ensure the device is connected and initialized before sending these commands. ```cpp // Magstripe read command sequence (captured from Wireshark) std::array magstripeReadReq_1 = {0x1b, 0x61, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}; std::array magstripeReadReq_2 = {0x1b, 0x72, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}; // Send first magstripe read command rc = libusb_interrupt_transfer(lusb_dev_hndl, endpointOut, magstripeReadReq_1.data(), magstripeReadReq_1.size(), bytes_transferred_cnt, 0); if (rc != LIBUSB_SUCCESS) { std::cerr << "ERROR: Magstripe read initiation failed, rc=" << rc << std::endl; return -1; } // Send second magstripe read command rc = libusb_interrupt_transfer(lusb_dev_hndl, endpointOut, magstripeReadReq_2.data(), magstripeReadReq_2.size(), bytes_transferred_cnt, 0); if (rc != LIBUSB_SUCCESS) { std::cerr << "ERROR: Magstripe read request failed, rc=" << rc << std::endl; return -1; } std::cout << "Magstripe read initiated - swipe card now" << std::endl; ``` -------------------------------- ### Initiate Magnetic Stripe Card Read (Python) Source: https://context7.com/raleighlittles/itosayde-msr-880/llms.txt Python code to initiate a magnetic stripe card read by sending two specific command sequences. Verifies the number of bytes sent for each command. ```python # Python - initiate magnetic stripe read magstripe_read_req_1 = [0x1b, 0x61, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00] magstripe_read_req_2 = [0x1b, 0x72, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00] # Send first command result = msr880_usb_device.write(ENDPOINT_OUT, magstripe_read_req_1) if result != len(magstripe_read_req_1): print(f"Error with first command: expected {len(magstripe_read_req_1)}, sent {result}") # Send second command result = msr880_usb_device.write(ENDPOINT_OUT, magstripe_read_req_2) if result != len(magstripe_read_req_2): print(f"Error with second command: expected {len(magstripe_read_req_2)}, sent {result}") print("Magstripe read initiated - swipe card now") ``` -------------------------------- ### CMakeLists.txt Configuration Source: https://context7.com/raleighlittles/itosayde-msr-880/llms.txt CMake configuration file for the C++ application. Sets the C++ standard, build type, compiler flags, and links the executable against the usb-1.0 library. ```cmake # CMakeLists.txt configuration cmake_minimum_required(VERSION 3.20) project(itosayde_msr_880_driver_demo) set(CMAKE_CXX_STANDARD 23) set(CMAKE_BUILD_TYPE Debug) set(CMAKE_CXX_FLAGS "-g -O0 -Wall") add_executable(${PROJECT_NAME}.out main.cpp) target_link_libraries(${PROJECT_NAME}.out usb-1.0) ``` -------------------------------- ### Configure CMake for MSR-880 Driver Source: https://github.com/raleighlittles/itosayde-msr-880/blob/main/app/CMakeLists.txt Defines the project requirements, C++ standard, and links the necessary USB library. ```cmake cmake_minimum_required(VERSION 3.20) project(itosayde_msr_880_driver_demo) set(CMAKE_CXX_STANDARD 23) set(CMAKE_BUILD_TYPE Debug) set(CMAKE_CXX_FLAGS "-g -O0 -Wall") add_executable(${PROJECT_NAME}.out main.cpp) target_link_libraries(${PROJECT_NAME}.out usb-1.0) ``` -------------------------------- ### DOL Construction Source: https://github.com/raleighlittles/itosayde-msr-880/blob/main/sdk/VC DEMO/DemoCode/EmvDebugLog.txt Logs showing the construction of the Data Object List (DOL). ```text buildDOL() _gtDataDict[31].tag=8C nLen=33 9F 02 06 9F 03 06 9F 1A 02 95 05 5F 2A 02 9A 03 9C 01 9F 37 04 9F 35 01 9F 45 02 9F 4C 08 9F 34 03 ``` -------------------------------- ### Configure udev Rules (Bash) Source: https://context7.com/raleighlittles/itosayde-msr-880/llms.txt Configures udev rules to prevent the kernel from claiming the USB device, allowing userspace applications like libusb to access it. This is crucial for device operation. ```bash # File: /etc/udev/rules.d/101-itosayde-msr-880.rules # Unbind HID driver so libusb can claim the device SUBSYSTEM=="usb", DRIVER=="hidgeneric", ATTRS{idVendor}=="0801", ATTRS{idProduct}=="0005", RUN="/bin/sh -c 'echo -n $id:1.0 > /sys/bus/hid/drivers/hid-generic/unbind'" SUBSYSTEM=="usb", DRIVER=="hidgeneric", ATTRS{idVendor}=="0802", ATTRS{idProduct}=="0005", RUN="/bin/sh -c 'echo -n $id:1.0 > /sys/bus/hid/drivers/hid-generic/unbind'" ``` -------------------------------- ### IC Card / Smart Card Functions Source: https://context7.com/raleighlittles/itosayde-msr-880/llms.txt Functions for initializing, closing, sending commands to, and detecting IC/Smart Cards. ```APIDOC ## IC Card / Smart Card Functions ### IccInit Initializes an IC card in a specified slot and retrieves the ATR. ### Method `extern unsigned char __stdcall IccInit(uchar slot, uchar *ATR);` ### IccClose Closes the connection to an IC card in a specified slot. ### Method `extern void __stdcall IccClose(uchar slot);` ### IccIsoCommand Sends an APDU command to an IC card. ### Method `extern unsigned char __stdcall IccIsoCommand(uchar slot, APDU_SEND *ApduSend, APDU_RESP *ApduRecv);` ### IccDetect Detects the presence of a card in a specified slot. ### Method `extern unsigned char __stdcall IccDetect(uchar slot);` ``` -------------------------------- ### MSR-880 Windows SDK API Definitions Source: https://context7.com/raleighlittles/itosayde-msr-880/llms.txt Function signatures and data structures for interacting with the MSR-880 hardware via the Windows SDK. ```c // Magnetic Stripe Card Functions extern int _stdcall MSR_Init(void); // Initialize MSR module extern void _stdcall MSR_Exit(void); // Close MSR module extern int _stdcall MSR_Read(void); // Read magnetic stripe (raw) extern int _stdcall MSR_Read_ASCII(void); // Read magnetic stripe (ASCII) extern int _stdcall MSR_Write(unsigned char *TK1Dat, // Write to all 3 tracks unsigned char *TK2Dat, unsigned char *TK3Dat); extern int _stdcall MSR_GetTrackData(unsigned char *TK1Dat, // Get track data after read unsigned char *TK2Dat, unsigned char *TK3Dat); extern int _stdcall MSR_Erase(unsigned char mode); // Erase card tracks extern int _stdcall MSR_Set_HiCo(); // Set high coercivity mode extern int _stdcall MSR_Set_LoCo(); // Set low coercivity mode // IC Card / Smart Card Functions extern unsigned char __stdcall IccInit(uchar slot, uchar *ATR); // Initialize IC card extern void __stdcall IccClose(uchar slot); // Close IC card extern unsigned char __stdcall IccIsoCommand(uchar slot, // Send APDU command APDU_SEND *ApduSend, APDU_RESP *ApduRecv); extern unsigned char __stdcall IccDetect(uchar slot); // Detect card presence // RFID/M1 Card Functions extern unsigned char __stdcall M1Request(unsigned char type, unsigned char *rsp); extern unsigned char __stdcall M1Select(unsigned char *SerialNo); extern unsigned char __stdcall M1Authority(unsigned char type, unsigned char block, unsigned char *pwd); extern unsigned char __stdcall M1ReadBlock(unsigned char block, unsigned char *pck); extern unsigned char __stdcall M1WriteBlock(unsigned char block, unsigned char *pck); // Contactless/Ultralight Card Functions extern unsigned char __stdcall ULRequest(unsigned char type, unsigned char *temp, unsigned char *length); extern unsigned char __stdcall ULSelect(unsigned char *SerialNo); extern unsigned char __stdcall ULWrite(unsigned char block, unsigned char *pck); // APDU Data Structures typedef struct { unsigned char Command[4]; // APDU command bytes unsigned short Lc; // Command data length unsigned char DataIn[512]; // Command data unsigned short Le; // Expected response length } APDU_SEND; typedef struct { unsigned short LenOut; // Response data length unsigned char DataOut[512]; // Response data unsigned char SWA; // Status word A unsigned char SWB; // Status word B } APDU_RESP; ``` -------------------------------- ### TLV Database Storage Logs Source: https://github.com/raleighlittles/itosayde-msr-880/blob/main/sdk/VC DEMO/DemoCode/EmvDebugLog.txt Logs showing the parsing and storage of BER-TLV data structures during transaction processing. ```text T = 8E,L = 14,V = 00 00 00 00 00 00 00 00 1E 03 42 03 1F 03 Store TLV Database DataNum=33 T = 9F4A,L = 1,V = 82 Store TLV Database DataNum=107 ``` -------------------------------- ### USB Device Identification Constants (C++) Source: https://context7.com/raleighlittles/itosayde-msr-880/llms.txt Defines the vendor and product IDs for the MSR-880 device, along with USB endpoint addresses for communication. ```cpp // USB device identification constants (usb_wrapper.h) static const uint16_t vendorID = 0x0802; // Mako Technologies, LLC static const uint16_t productID = 0x0005; // STM32 QWERT HID // USB endpoint addresses static const unsigned char endpointIn = 0x82; // EP 2 IN - Receive data from device static const unsigned char endpointOut = 0x01; // EP 1 OUT - Send commands to device ``` -------------------------------- ### Contactless/Ultralight Card Functions Source: https://context7.com/raleighlittles/itosayde-msr-880/llms.txt Functions for interacting with Contactless/Ultralight cards, including requests, selection, and writing. ```APIDOC ## Contactless/Ultralight Card Functions ### ULRequest Sends a request to an Ultralight card. ### Method `extern unsigned char __stdcall ULRequest(unsigned char type, unsigned char *temp, unsigned char *length);` ### ULSelect Selects an Ultralight card using its serial number. ### Method `extern unsigned char __stdcall ULSelect(unsigned char *SerialNo);` ### ULWrite Writes data to a block on an Ultralight card. ### Method `extern unsigned char __stdcall ULWrite(unsigned char block, unsigned char *pck);` ``` -------------------------------- ### Magnetic Stripe Card Functions Source: https://context7.com/raleighlittles/itosayde-msr-880/llms.txt Functions for initializing, reading from, writing to, and erasing magnetic stripe cards. ```APIDOC ## Magnetic Stripe Card Functions ### MSR_Init Initializes the MSR module. ### Method `extern int _stdcall MSR_Init(void);` ### MSR_Exit Closes the MSR module. ### Method `extern void _stdcall MSR_Exit(void);` ### MSR_Read Reads magnetic stripe data in raw format. ### Method `extern int _stdcall MSR_Read(void);` ### MSR_Read_ASCII Reads magnetic stripe data in ASCII format. ### Method `extern int _stdcall MSR_Read_ASCII(void);` ### MSR_Write Writes data to all 3 tracks of a magnetic stripe card. ### Method `extern int _stdcall MSR_Write(unsigned char *TK1Dat, unsigned char *TK2Dat, unsigned char *TK3Dat);` ### MSR_GetTrackData Retrieves track data after a read operation. ### Method `extern int _stdcall MSR_GetTrackData(unsigned char *TK1Dat, unsigned char *TK2Dat, unsigned char *TK3Dat);` ### MSR_Erase Erases specified tracks of a card. ### Method `extern int _stdcall MSR_Erase(unsigned char mode);` ### MSR_Set_HiCo Sets the MSR module to high coercivity mode. ### Method `extern int _stdcall MSR_Set_HiCo();` ### MSR_Set_LoCo Sets the MSR module to low coercivity mode. ### Method `extern int _stdcall MSR_Set_LoCo();` ``` -------------------------------- ### EmvReadRecord Processing Source: https://github.com/raleighlittles/itosayde-msr-880/blob/main/sdk/VC DEMO/DemoCode/EmvDebugLog.txt Logs from the EmvReadRecord function indicating successful data retrieval and TLV construction. ```text EmvReadRecord() bRet=0x00 SFIValue[5] bOutLen[192] OutBuf[bOutLen-1]=0x03 ``` -------------------------------- ### APDU Exchange Logs Source: https://github.com/raleighlittles/itosayde-msr-880/blob/main/sdk/VC DEMO/DemoCode/EmvDebugLog.txt Logs representing the communication between the terminal and the IC card. ```text IC Send LEN : 5 00 B2 02 2C 00 in ExchangeApdu IC Resp LEN : 194 ``` -------------------------------- ### APDU Data Structures Source: https://context7.com/raleighlittles/itosayde-msr-880/llms.txt Data structures used for APDU (Application Protocol Data Unit) commands and responses. ```APIDOC ## APDU Data Structures ### APDU_SEND Structure for sending APDU commands. ### Fields - **Command** (unsigned char[4]) - APDU command bytes. - **Lc** (unsigned short) - Command data length. - **DataIn** (unsigned char[512]) - Command data. - **Le** (unsigned short) - Expected response length. ### APDU_RESP Structure for receiving APDU responses. ### Fields - **LenOut** (unsigned short) - Response data length. - **DataOut** (unsigned char[512]) - Response data. - **SWA** (unsigned char) - Status word A. - **SWB** (unsigned char) - Status word B. ``` -------------------------------- ### RFID/M1 Card Functions Source: https://context7.com/raleighlittles/itosayde-msr-880/llms.txt Functions for interacting with RFID/M1 cards, including requests, selection, authentication, reading, and writing. ```APIDOC ## RFID/M1 Card Functions ### M1Request Sends a request to an M1 card. ### Method `extern unsigned char __stdcall M1Request(unsigned char type, unsigned char *rsp);` ### M1Select Selects an M1 card using its serial number. ### Method `extern unsigned char __stdcall M1Select(unsigned char *SerialNo);` ### M1Authority Authenticates with an M1 card for a specific block. ### Method `extern unsigned char __stdcall M1Authority(unsigned char type, unsigned char block, unsigned char *pwd);` ### M1ReadBlock Reads a block of data from an M1 card. ### Method `extern unsigned char __stdcall M1ReadBlock(unsigned char block, unsigned char *pck);` ### M1WriteBlock Writes a block of data to an M1 card. ### Method `extern unsigned char __stdcall M1WriteBlock(unsigned char block, unsigned char *pck);` ``` -------------------------------- ### Terminal Risk Management and CVM Processing Source: https://github.com/raleighlittles/itosayde-msr-880/blob/main/sdk/VC DEMO/DemoCode/EmvDebugLog.txt Logs detailing terminal risk management, date validation, and Cardholder Verification Method (CVM) processing. ```text [Len=3]EFF_DATE_5F25= 17 09 04 Current Date[9A]:20 19 04 12 Effective Date[5F25]:20 17 09 04 Expiration Date[5F24]:20 20 08 31 PaypassTerminalRiskManagement ``` ```text CheckCVMCondition bRet=0x01 CVM Code:42 03 [Len=3]_gtEmvTermParam.ucTermCapa(9F33) = A0 08 88 CheckCVMCondition bRet=0x01 CVM Code:1F 03 [Len=3]_gtEmvTermParam.ucTermCapa(9F33) = A0 08 88 CheckCVMCondition bRet=0x00 CVM Code Process=0x1F ``` === COMPLETE CONTENT === This response contains all available snippets from this library. No additional content exists. Do not make further requests.