Recent

Author Topic: RFID Reader  (Read 17971 times)

rvk

  • Hero Member
  • *****
  • Posts: 6885
Re: RFID Reader
« Reply #15 on: June 15, 2016, 01:36:31 pm »
So, let's say Elvis has entered the building and John Lennon wants it too? And John should be prevented to enter the building before Elvis has left the building?
That should be done in code, not by the reader.
And how would you detect Elvis has left the building and I (without a RFID) entered. You can't just do that in code. You would need to periodically scan if the RFID of Elvis is still present. Otherwise I would have the same privileges as Elvis (or the system would still think I'm Elvis :)).

(If a RFID reader can't be made to trigger a read of the nearby cards this whole scheme doesn't work with a RFID-reader).
« Last Edit: June 15, 2016, 01:38:31 pm by rvk »

Thaddy

  • Hero Member
  • *****
  • Posts: 18300
  • Here stood a man who saw the Elbe and jumped it.
Re: RFID Reader
« Reply #16 on: June 15, 2016, 01:41:49 pm »
I assume that Elvis needs to scan on exit too. Like the bullshit implementation "somebody"wrote for the Dutch public transport system and refused to follow up on my recommendations to make it right. From the start... Is my answer, or something along these lines... ;) (Can't go into detail)

Basically the building should be rid of Elvis before John can enter. But that is only half the story.
« Last Edit: June 15, 2016, 01:46:23 pm by Thaddy »
Due to censorship, I changed this to "Nelly the Elephant". Keeps the message clear.

rvk

  • Hero Member
  • *****
  • Posts: 6885
Re: RFID Reader
« Reply #17 on: June 15, 2016, 01:44:23 pm »
I assume that Elvis needs to scan on exit too.
My guess is that xinyiman doesn't want that Elvis needs to scan himself out. If Elvis leaves he takes his RFID with him and he wants the RFID-reader to detect this so the system is logged out automatically.

And if the RFID-reader has the ability to trigger a rescan of nearby cards this should be possible.
« Last Edit: June 15, 2016, 01:46:15 pm by rvk »

Thaddy

  • Hero Member
  • *****
  • Posts: 18300
  • Here stood a man who saw the Elbe and jumped it.
Re: RFID Reader
« Reply #18 on: June 15, 2016, 01:47:08 pm »
You are on the right track... :) But basically this is only possible with a geo solution and the fact that Elvis appears somewhere else. Inn that case there should be an automatic reset about the plausability that Elvis is at two places at once. Other options are not viable, unless scanned without approval. Which violates most countries laws.
« Last Edit: June 15, 2016, 01:50:04 pm by Thaddy »
Due to censorship, I changed this to "Nelly the Elephant". Keeps the message clear.

Thaddy

  • Hero Member
  • *****
  • Posts: 18300
  • Here stood a man who saw the Elbe and jumped it.
Re: RFID Reader
« Reply #19 on: June 15, 2016, 01:50:35 pm »
You are on the right track... :) But basically this is only possible with a geo solution and the fact that Elvis appears somewhere else by scanning in again. In that case there should be an automatic reset about the plausability that Elvis is at two places at once. Other options are not viable, unless scanned without approval. Which violates most countries laws. The suggestion I was referring to comes very close but has  some intricacies that I am not allowed to share. (And it was before the final introduction, note). It was about time and place, for good measure. And an architectural review.

Right now, manual intervention is in place to determine time and place and refunds, which is, frankly, plain stupid in most cases. And I told them so...
« Last Edit: June 15, 2016, 01:57:40 pm by Thaddy »
Due to censorship, I changed this to "Nelly the Elephant". Keeps the message clear.

ahiggins

  • Jr. Member
  • **
  • Posts: 92
Re: RFID Reader
« Reply #20 on: June 16, 2016, 04:47:17 pm »
Not sure if this will be any help to anybody but I also purchased the same RFID reader/writer as Xinyiman yesterday and whilst low cost (£15/18 euros) I must say I expected more information/software. I use Windows 7 at work and straight away had to find/download a working driver!
Anyway I found that the supplied software was not suitable for my needs, it’s a bit clunky and won’t start as a service or even minimise to the system tray. So I decided to have a go at writing a proof of concept application to see is I could come up with anything better. Now there is a good chance I’ve reinvented the wheel and I confess my programming skills are not up to much (so go easy on me folks) but maybe what I have found will be of some help to somebody.
I found the Manufactures web site to be of little use.
The RFID reader is a serial device that connects to the USB using the Prolific USB to Serial chipset.
I had to use a port sniffer to decode the information being passed back and forth.

Ok, first off you need to configure your serial port to the following 38400,8,1
Code: Pascal  [Select][+][-]
  1. RFID:=SerOpen('COM9');
  2. Sleep(1000);
  3. SerSetParams(RFID,38400,8,NoneParity,1,[]);
  4.  

To initialize the reader ready for use you need to write to HEX to the port AA DD 00 03 01 02 03 then read the port, wait, and write AA DD 00 04 01 03 0A 08 to the port and then read the port again. If all is well the device should beep and the ID string returned.

Code: Pascal  [Select][+][-]
  1.  RFID:=SerOpen('COM9');
  2.      Sleep(1000);
  3.      SerSetParams(RFID,38400,8,NoneParity,1,[]);
  4.  
  5.      Buf[0]:=$AA;
  6.      Buf[1]:=$DD;
  7.      Buf[2]:=$00;
  8.      Buf[3]:=$03;
  9.      Buf[4]:=$01;
  10.      Buf[5]:=$02;
  11.      Buf[6]:=$03;
  12.  
  13.  
  14.      SerWrite(RFID,Buf[0],7);
  15.  
  16.      Sleep(100);
  17.      SerRead(RFID,Buf[0],31);
  18.  
  19.      Str:='';
  20.      For X:=7 to 31 do
  21.      begin
  22.           Str:=Str+Char(Buf[X]);
  23.      end;
  24.      Memo1.Append(Str);
  25.  
  26.  
  27.      Buf[0]:=$AA;
  28.      Buf[1]:=$DD;
  29.      Buf[2]:=$00;
  30.      Buf[3]:=$04;
  31.      Buf[4]:=$01;
  32.      Buf[5]:=$03;
  33.      Buf[6]:=$0A;
  34.      Buf[7]:=$08;
  35.  
  36.      Sleep(100);
  37.  
  38.      SerWrite(RFID,Buf[0],8);
  39.      Sleep(100);
  40.      SerRead(RFID,Buf[0],8);
  41.  

To Read from the device is a similar affair, this time writing AA DD 00 03 01 0C 0D then read the port and terminate the command with AA DD 00 04 01 03 0A 08 this will cause the device to beep. The return string is found at bytes 7 - 11.
Code: Pascal  [Select][+][-]
  1.  Buf[0]:=$AA;
  2.      Buf[1]:=$DD;
  3.      Buf[2]:=$00;
  4.      Buf[3]:=$03;
  5.      Buf[4]:=$01;
  6.      Buf[5]:=$0C;
  7.      Buf[6]:=$0D;
  8.  
  9.      SerWrite(RFID,Buf[0],7);
  10.      Sleep(100);
  11.  
  12.  
  13.  
  14.      SerRead(RFID,Buf[0],13);
  15.  
  16.      Str:='';
  17.      For X:=7 to 11 do
  18.      begin
  19.           Str:=Str+IntToHex(Buf[X],2);
  20.      end;
  21.      Memo1.Append(Str);
  22.  
  23.  
  24.      Buf[0]:=$AA;
  25.      Buf[1]:=$DD;
  26.      Buf[2]:=$00;
  27.      Buf[3]:=$04;
  28.      Buf[4]:=$01;
  29.      Buf[5]:=$03;
  30.      Buf[6]:=$0A;
  31.      Buf[7]:=$08;
  32.      Sleep(100);
  33.      SerWrite(RFID,Buf[0],8);
  34.      Sleep(100);
  35.      SerRead(RFID,Buf[0],8);
  36.  


That’s as far as I have got, not much granted but a start and not possible without FPC/Lazarus and this most helpful of forums.

Tony 
« Last Edit: June 16, 2016, 06:24:33 pm by ahiggins »

rvk

  • Hero Member
  • *****
  • Posts: 6885
Re: RFID Reader
« Reply #21 on: June 16, 2016, 07:23:46 pm »
AA DD 00 03 01 0C 0D
And searching for this string in Google will result in at least two pdf documents with a lot more information about the protocol.

ahiggins

  • Jr. Member
  • **
  • Posts: 92
Re: RFID Reader
« Reply #22 on: June 16, 2016, 08:30:57 pm »
thank you for tip rvk, should be a great help.

avra

  • Hero Member
  • *****
  • Posts: 2566
    • Additional info
Re: RFID Reader
« Reply #23 on: June 17, 2016, 10:45:24 am »
Maybe I have not explained.

1. The user leaves the card to the reader
2. The user uses a program, when you click on a button, the program asks the reader of the code contained in the card and checks in the database if it is enabled to continue.
3. The user walks away from the station by removing his card (without exiting the program), so if another user can not get to click the button if it does not insert his card.

For this I need the player is called up by the program. I know that some readers allow it and I was hoping that too!

What you have initially written (in my understanding) is that you have a RFID reader that emulates keyboard presses. So scanned card number goes to whatever form has focus at that moment. That's why I have described the solution for that case. Now, I think that for your problem you need a different RFID card reader type - you need a reader that sends card number through serial connection (or USB connection with virtual serial COM port). When you have a serial connection you have much more control that you might just need in your application, and your form does not need to be active for your application to receive RFID card info.
ct2laz - Conversion between Lazarus and CodeTyphon
bithelpers - Bit manipulation for standard types
pasettimino - Siemens S7 PLC lib

Thaddy

  • Hero Member
  • *****
  • Posts: 18300
  • Here stood a man who saw the Elbe and jumped it.
Re: RFID Reader
« Reply #24 on: June 17, 2016, 10:55:05 am »
@Avra
Your answers are always eloquent, but I beg to differ in that in this case there is someone with little if any experience in how an rfid card is actually used.
I suggest we focus on answers that fit best practice. That is given current standards. I always find it very difficult to give a solution - which I know that would work - that is actually not mainstream and therefor maybe at some point in time turns out to be the wrong choice. With due respect. We should guide OP in using standard solutions, not proprietary ones.
« Last Edit: June 17, 2016, 10:59:53 am by Thaddy »
Due to censorship, I changed this to "Nelly the Elephant". Keeps the message clear.

rvk

  • Hero Member
  • *****
  • Posts: 6885
Re: RFID Reader
« Reply #25 on: June 17, 2016, 11:12:39 am »
We should guide OP in using standard solutions, not proprietary ones.
And the communication @avra (and @ahiggins) were talking about (via USB/COM-port) is the ISO14443 protocol which is not really "proprietary" but standard for RFID-readers.

See also: http://nfc-tools.org/index.php?title=ISO14443
« Last Edit: June 17, 2016, 11:15:17 am by rvk »

Thaddy

  • Hero Member
  • *****
  • Posts: 18300
  • Here stood a man who saw the Elbe and jumped it.
Re: RFID Reader
« Reply #26 on: June 17, 2016, 11:24:13 am »
Yes. I know. but @Avra digressed a little. Too much knowledge can be a distraction to others. I know. You know. But OP doesn't know yet.
« Last Edit: June 17, 2016, 11:26:03 am by Thaddy »
Due to censorship, I changed this to "Nelly the Elephant". Keeps the message clear.

avra

  • Hero Member
  • *****
  • Posts: 2566
    • Additional info
Re: RFID Reader
« Reply #27 on: June 17, 2016, 12:55:42 pm »
And the communication @avra (and @ahiggins) were talking about (via USB/COM-port) is the ISO14443 protocol which is not really "proprietary" but standard for RFID-readers.
No, sorry. I was not talking about ISO14443. That standard only covers 13MHz cards, while his card may be 125kHz or some other. So I was in general recommending changing to RFID reader where card ID is sent to serial output. They are no more then 20-30 EUR in China so that shouldn't be a problem, and it would be much easier for OP to process data coming from the reader and to avoid missing reader output when his application is not in focus.

I beg to differ in that in this case there is someone with little if any experience in how an rfid card is actually used.
I used to read RFID tags directly with microcontroller chips using just copper wire coil/antenna at first, then for convenience in some cases I have used EM4100 chip which makes it much more easier to decode tag radio message response, and at some places I had to decode Wiegand protocol. This was all low level microcontroller programming. I also used serial, keyboard and usb readers from time to time so I am experienced with higher level access to RFID tag reading which is OP interested in. I am used to reading chip datasheets and other technical documents so that probably influence the way I write. So I am sorry if I sound sometimes more technical then necessary. I was just trying to help.
« Last Edit: June 17, 2016, 01:04:40 pm by avra »
ct2laz - Conversion between Lazarus and CodeTyphon
bithelpers - Bit manipulation for standard types
pasettimino - Siemens S7 PLC lib

rvk

  • Hero Member
  • *****
  • Posts: 6885
Re: RFID Reader
« Reply #28 on: June 17, 2016, 01:10:51 pm »
No, sorry. I was not talking about ISO14443. That standard only covers 13MHz cards, while his card may be 125kHz or some other.
That's why I asked for type and brand of the RFID reader (and cards), at the beginning of this topic, so we know what we're dealing with. Without it we can't know if the reader is capable of direct communications (because some are). If the RFID-reader in question only emulates keyboard and has no other capabilities, then another reader needs to be considered to do exactly what xinyiman wants. But if it can be controlled by the ISO14443-protocol there are other possibilities.

B.T.W. my understanding was that "contactless smart card" were usually 13.56MHz (close-range <10cm) and other RFID tags (like identification-types, in animals for example) were 125kHz. (But I could be wrong)

avra

  • Hero Member
  • *****
  • Posts: 2566
    • Additional info
Re: RFID Reader
« Reply #29 on: June 17, 2016, 02:05:50 pm »
B.T.W. my understanding was that "contactless smart card" were usually 13.56MHz (close-range <10cm) and other RFID tags (like identification-types, in animals for example) were 125kHz. (But I could be wrong)
There are other frequency rfid cards as you can see at http://www.databac.com/products/cards/card_technologies/rfid/uhf_2_45_ghz.php. I have intentionally written cards and not smart cards because I was talking in general, and not covering just smart ones. The difference is explained at http://www.idwholesaler.com/blog/whats-the-difference-between-a-prox-card-and-a-smart-card. It is an overkill to use smart card if only proximity ID card is needed. If we want to be complete, then we have to also mention active and passive rfid tags. The difference is explained at http://blog.atlasrfidstore.com/active-rfid-vs-passive-rfid. Mostly used are passive ones, but active ones are irreplaceable in some use cases.
ct2laz - Conversion between Lazarus and CodeTyphon
bithelpers - Bit manipulation for standard types
pasettimino - Siemens S7 PLC lib

 

TinyPortal © 2005-2018