This is my problem
I can't make the write method works and this is my code
Code: Select all
namespace Prueba
{
class Program
{
static void printError(ErrorCode number, String description)
{
Console.WriteLine("Error en llamar a la funcion "+number+" - "+description+"!");
}
// Aparte
static void manager_Attach(object sender, ManagerAttachEventArgs e) {
int serialNumber;
String name;
try
{
serialNumber = e.Channel.DeviceSerialNumber;
name = e.Channel.DeviceName;
Console.WriteLine("Hola dispositivo "+name+"' Con numero Serial: "+serialNumber );
}
catch (PhidgetException ex)
{
printError(ex.ErrorCode, ex.Description);
}
}
static void manager_Detach(object sender, ManagerDetachEventArgs e) {
int serialNumber;
String name;
try
{
name = e.Channel.DeviceName;
serialNumber = e.Channel.DeviceSerialNumber;
Console.WriteLine("Adios dispositivo " + name + ", con numero serial: "+serialNumber);
}
catch(PhidgetException ex) {
printError(ex.ErrorCode, ex.Description);
}
}
static void RfidTag(object sender, RFIDTagEventArgs e)
{
try
{
Console.WriteLine("Tag: " + e.Tag+ " "+e.Protocol);
}
catch (PhidgetException ex)
{
printError(ex.ErrorCode, ex.Description);
}
}
static void TagLost(object sender, RFIDTagLostEventArgs e) {
try
{
Console.WriteLine("Se ingreso Tag: " + e.Tag + " con protocolo " + e.Protocol);
}
catch (PhidgetException ex)
{
printError(ex.ErrorCode, ex.Description);
}
}
static void RfidWrite(object sender, EventArgs re) {
RFID holas = new RFID();
try
{
holas.Write("Cheves y desmadre", RFIDProtocol.PhidgetTAG, false);
}
catch (PhidgetException ex)
{
printError(ex.ErrorCode, ex.Description);
}
}
static void Main(string[] args)
{
Manager manager = new Manager();
RFID holas = new RFID();
RFID Guardar = new RFID();
RFID demiLobato = new RFID();
int var;
String tagText = "I CAN FLAY";
RFIDProtocol protocol = RFIDProtocol.PhidgetTAG;
bool f = false;
try
{
holas.Tag += new RFIDTagEventHandler(RfidTag);
holas.Write(tagText,protocol,f); // <--- this
}
catch(PhidgetException ex)
{
printError(ex.ErrorCode, ex.Description);
}
try
{
holas.AntennaEnabled = false; //it doesn't work
}
catch (PhidgetException ex) { Console.WriteLine("Error enabling antenna: " + ex.Message); }
holas.Open();
try
{
holas.TagLost += new RFIDTagLostEventHandler(TagLost);
}
catch (PhidgetException ex)
{
printError(ex.ErrorCode, ex.Description);
}
try {
manager.Attach += new ManagerAttachEventHandler(manager_Attach);
manager.Detach += new ManagerDetachEventHandler(manager_Detach);
}
catch (PhidgetException ex)
{
printError(ex.ErrorCode,ex.Description);
}
try
{
}
catch (PhidgetException ex)
{
printError(ex.ErrorCode, ex.Description);
}
manager.Open();
Console.WriteLine("Phidget Simple Playground (plug and unplug devices)");
Console.WriteLine("Press Enter to end anytime");
Console.ReadLine();
Console.WriteLine("Closing....");
try
{
manager.Attach -= new ManagerAttachEventHandler(manager_Attach);
manager.Detach -= new ManagerDetachEventHandler(manager_Detach);
manager.Close();
}
catch (PhidgetException ex)
{
printError(ex.ErrorCode, ex.Description);
}
manager = null;
}
}
}