/*LeerTodaMemoria * Se leeran sectores y bloques * */ //Revisado Prof: Bolaņos 2018 - Ensayado #include #include #define RST_PIN 9 // Configurable, see typical pin layout above #define SS_PIN 10 // Configurable, see typical pin layout above MFRC522 mfrc522(SS_PIN, RST_PIN); // Create MFRC522 instance. MFRC522::MIFARE_Key key; /** * Initialize. */ void setup() { Serial.begin(9600); // Initialize serial communications with the PC while (!Serial); // Do nothing if no serial port is opened (added for Arduinos based on ATMEGA32U4) SPI.begin(); // Init SPI bus mfrc522.PCD_Init(); // Init MFRC522 card // using FFFFFFFFFFFFh which is the default at chip delivery from the factory for (byte i = 0; i < 6; i++) { key.keyByte[i] = 0xFF; } Serial.println(F("Ingrese Tarjeta")); } /** * Main loop. */ //----------------------------------------- void(* resetFunc) (void) = 0; // esta es la funcion de reset //----------------------------------------- void loop() { // Look for new cards if ( ! mfrc522.PICC_IsNewCardPresent()) return; // Select one of the cards if ( ! mfrc522.PICC_ReadCardSerial()) return; //---Leo sector 0-------------- byte sector = 0; byte dataBlock[] = { 0x01, 0x02, 0x03, 0x04, // 1, 2, 3, 4, 0x05, 0x06, 0x07, 0x08, // 5, 6, 7, 8, 0x08, 0x09, 0xff, 0x0b, // 9, 10, 255, 12, 0x0c, 0x0d, 0x0e, 0x0f // 13, 14, 15, 16 }; MFRC522::StatusCode status; byte buffer[18]; byte size = sizeof(buffer); Serial.println(F("Datos actuales en el sector:")); mfrc522.PICC_DumpMifareClassicSectorToSerial(&(mfrc522.uid), &key, sector); Serial.println(); if (status != MFRC522::STATUS_OK) { Serial.print(F("MIFARE_Read() failed: ")); Serial.println(mfrc522.GetStatusCodeName(status)); } Serial.println(); //------Fin leer sector 0------------------ //---------------leo el sector1----------- sector = 1; buffer[18]; size = sizeof(buffer); Serial.println(F("Datos actuales en el sector:")); mfrc522.PICC_DumpMifareClassicSectorToSerial(&(mfrc522.uid), &key, sector); Serial.println(); if (status != MFRC522::STATUS_OK) { Serial.print(F("MIFARE_Read() failed: ")); Serial.println(mfrc522.GetStatusCodeName(status)); } Serial.println(); //------------Fin lectura del sector 1-------------- /* Ahora leemos desde el sector 2 * Solo se hace asi para mostras las opciones * que tenemos para leer sectores. */ //---------------leo el sector n----------- for (int a=2; a<16; a++) // declara i y prueba si es menor //que 16, incrementa i. { sector = a; //carga numero de sector a mostrar buffer[18]; size = sizeof(buffer); Serial.println(F("Datos actuales en el sector:")); mfrc522.PICC_DumpMifareClassicSectorToSerial(&(mfrc522.uid), &key, sector); Serial.println(); if (status != MFRC522::STATUS_OK) { Serial.print(F("MIFARE_Read() failed: ")); Serial.println(mfrc522.GetStatusCodeName(status)); } Serial.println(); //------------Fin lectura del sector n-------------- delay(50); } //del FOR Serial.println(F("Espere para colocar otra tarjeta.....")); Serial.println(F("******************************************")); Serial.println(F("******************************************")); //Reinicio luego de un tiempo delay(3000); resetFunc(); // reseteo el Arduino }