RFID reader GP30 reader dont start with a STX. So I change the code so that it can read data from this reader and other that have the same protocol
Fork of ID12RFID by
The GP30 and other dont start with a STX. So therefore the change..
GP30-RFID.cpp@3:54393c961233, 2013-10-17 (annotated)
- Committer:
- gert_lauritsen
- Date:
- Thu Oct 17 14:12:24 2013 +0000
- Revision:
- 3:54393c961233
- Parent:
- 2:4fd9319c3ec3
updatede doc
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
gert_lauritsen | 2:4fd9319c3ec3 | 1 | /* mbed ID12 RFID Library |
gert_lauritsen | 2:4fd9319c3ec3 | 2 | * Copyright (c) 2007-2010, sford, http://mbed.org |
gert_lauritsen | 2:4fd9319c3ec3 | 3 | * |
gert_lauritsen | 2:4fd9319c3ec3 | 4 | * Permission is hereby granted, free of charge, to any person obtaining a copy |
gert_lauritsen | 2:4fd9319c3ec3 | 5 | * of this software and associated documentation files (the "Software"), to deal |
gert_lauritsen | 2:4fd9319c3ec3 | 6 | * in the Software without restriction, including without limitation the rights |
gert_lauritsen | 2:4fd9319c3ec3 | 7 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell |
gert_lauritsen | 2:4fd9319c3ec3 | 8 | * copies of the Software, and to permit persons to whom the Software is |
gert_lauritsen | 2:4fd9319c3ec3 | 9 | * furnished to do so, subject to the following conditions: |
gert_lauritsen | 2:4fd9319c3ec3 | 10 | * |
gert_lauritsen | 2:4fd9319c3ec3 | 11 | * The above copyright notice and this permission notice shall be included in |
gert_lauritsen | 2:4fd9319c3ec3 | 12 | * all copies or substantial portions of the Software. |
gert_lauritsen | 2:4fd9319c3ec3 | 13 | * |
gert_lauritsen | 2:4fd9319c3ec3 | 14 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR |
gert_lauritsen | 2:4fd9319c3ec3 | 15 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, |
gert_lauritsen | 2:4fd9319c3ec3 | 16 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE |
gert_lauritsen | 2:4fd9319c3ec3 | 17 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER |
gert_lauritsen | 2:4fd9319c3ec3 | 18 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, |
gert_lauritsen | 2:4fd9319c3ec3 | 19 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN |
gert_lauritsen | 2:4fd9319c3ec3 | 20 | * THE SOFTWARE. |
gert_lauritsen | 2:4fd9319c3ec3 | 21 | */ |
gert_lauritsen | 2:4fd9319c3ec3 | 22 | |
gert_lauritsen | 2:4fd9319c3ec3 | 23 | #include "GP30-RFID.h" |
gert_lauritsen | 2:4fd9319c3ec3 | 24 | |
gert_lauritsen | 2:4fd9319c3ec3 | 25 | #include "mbed.h" |
gert_lauritsen | 2:4fd9319c3ec3 | 26 | |
gert_lauritsen | 2:4fd9319c3ec3 | 27 | GP30RFID::GP30RFID(PinName rx) |
gert_lauritsen | 2:4fd9319c3ec3 | 28 | : _rfid(NC, rx) |
gert_lauritsen | 2:4fd9319c3ec3 | 29 | { |
gert_lauritsen | 2:4fd9319c3ec3 | 30 | } |
gert_lauritsen | 2:4fd9319c3ec3 | 31 | |
gert_lauritsen | 2:4fd9319c3ec3 | 32 | int GP30RFID::readable() |
gert_lauritsen | 2:4fd9319c3ec3 | 33 | { |
gert_lauritsen | 2:4fd9319c3ec3 | 34 | if (_rfid.readable()) { |
gert_lauritsen | 2:4fd9319c3ec3 | 35 | read(); |
gert_lauritsen | 2:4fd9319c3ec3 | 36 | return 1; |
gert_lauritsen | 2:4fd9319c3ec3 | 37 | } |
gert_lauritsen | 2:4fd9319c3ec3 | 38 | else |
gert_lauritsen | 2:4fd9319c3ec3 | 39 | return 0; |
gert_lauritsen | 2:4fd9319c3ec3 | 40 | } |
gert_lauritsen | 2:4fd9319c3ec3 | 41 | |
gert_lauritsen | 2:4fd9319c3ec3 | 42 | int GP30RFID::read() |
gert_lauritsen | 2:4fd9319c3ec3 | 43 | { |
gert_lauritsen | 2:4fd9319c3ec3 | 44 | char c=0; |
gert_lauritsen | 2:4fd9319c3ec3 | 45 | int v = 0; |
gert_lauritsen | 2:4fd9319c3ec3 | 46 | while (c!=CR) { |
gert_lauritsen | 2:4fd9319c3ec3 | 47 | c=_rfid.getc(); |
gert_lauritsen | 2:4fd9319c3ec3 | 48 | if (c>='0'){ |
gert_lauritsen | 2:4fd9319c3ec3 | 49 | TAG[v]=c; |
gert_lauritsen | 2:4fd9319c3ec3 | 50 | if (v<Taglength) v++; |
gert_lauritsen | 2:4fd9319c3ec3 | 51 | } |
gert_lauritsen | 2:4fd9319c3ec3 | 52 | } |
gert_lauritsen | 2:4fd9319c3ec3 | 53 | //TAG[Taglength]=0; //null termination |
gert_lauritsen | 2:4fd9319c3ec3 | 54 | |
gert_lauritsen | 2:4fd9319c3ec3 | 55 | return v; |
gert_lauritsen | 2:4fd9319c3ec3 | 56 | } |