0

i have a phg ADMITTO100 RFID Reader to read Legic and i try to send some CMD´s to this one but it doesn´t answer.

I follow this example Serial Port

what have I forgotten? Do I have something to install before using a COM-Port?

The CMD is not right because of the LRC byte but shouldn´t the reader say "no, that was wrong"?

Here my code:

        var serialPort = new SerialPort
        {
            PortName = "COM1",
            BaudRate = 9600,
            DataBits = 8,
            Parity = Parity.None,
            StopBits = StopBits.One,
            Handshake = Handshake.None,

            ReadTimeout = 500,
            WriteTimeout = 500,
        };

        serialPort.Open();

        serialPort.DataReceived += new SerialDataReceivedEventHandler((s, e) => 
        {
            var message = ((SerialPort)s).ReadExisting();
            Console.WriteLine(message);
        });

        serialPort.ErrorReceived += new SerialErrorReceivedEventHandler((s, e) =>
        {
            Console.WriteLine(e.EventType);
        });

        var buffer = new byte[] { 0x02, 0x36, 0x00 };
        serialPort.Write(buffer, 0, buffer.Length);
Felix Arnold
  • 839
  • 7
  • 35
  • try this question maybe it helps i had similar problems https://stackoverflow.com/questions/13539869/serial-port-read-c-sharp-console – Combinu Sep 25 '17 at 09:09
  • Do you use a proper Serial port or a USB <-> Serial port? I have had a lot of problems with the drivers for the USB ones to work properly.. usually solved by trying a different brand – StefanE Sep 25 '17 at 09:13
  • have you treied to change the timeout to A beeger value? and try to use the ReadLine and WriteLine functions to handle the communication – Michael Gabbay Sep 25 '17 at 09:19
  • It may not say anything The point of an LRC is to know that the packet is complete, if it is wrong you have no way of knowing which part was wrong, it could just be random noise on the comms line (electrical noise does happen). I would suggest sending a properly formed command, the LRC is simple to work out by hand. – Kevin Ford Sep 25 '17 at 09:22
  • The other thing you could do is actually write a proper command builder (you are going to need it) and use that to send something - I just checked, the RFID tag reader I interfaced used a different protocol altogether. You may find it helpful to handle all comms directly because .NET serial can be rather fragile. – Kevin Ford Sep 25 '17 at 09:29
  • The Problem was: the device is not set to COM1, sorry – Felix Arnold Sep 27 '17 at 09:59

0 Answers0