Javelin Serial Read using UART
Hey guys,
I'm running into a problem trying to read from the RFID Reader (parallax). The code available for the reader is written in PBasic for the Basic Stamps, but I didnt think it would be a problem convverting it to Java.
Here's the basic code that supposedly works (havent tested it, but its in the manual so I figured it works)
and this is how I am doing it in Java
this code is also from the javelin manual, so it should work, the only thing is the parameters I'm using for the Uart object I'm creating.
According to the RFID Readers·documents it says
Pin SOUT function: Serial Out. TTL-level interface, 2400bps, 8 data bits, no parity, 1 stop bit, true.
I dont know what the true means, but the rest of it should be the same as I've put in the code. No?
Anyway, here are some links to the documents I am talking about. Any help/suggestions would be greatly appreciated.
Doc Links:
RFID Reader: http://www.parallax.com/dl/docs/prod/audiovis/RFID-Reader-v1.1.pdf· (page 2)
Reader Basic Stamp Code: http://www.parallax.com/dl/src/prod/RFID1.BS2
Javelin Stamp Manual (section about Uart):
http://www.parallax.com/dl/docs/prod/javelin/JavelinStampMan1-0.pdf
Thanks alot.
·
I'm running into a problem trying to read from the RFID Reader (parallax). The code available for the reader is written in PBasic for the Basic Stamps, but I didnt think it would be a problem convverting it to Java.
Here's the basic code that supposedly works (havent tested it, but its in the manual so I figured it works)
RX PIN 4 T2400 CON 396 SERIN RX, T2400, [noparse][[/noparse]WAIT($0A), STR buf\10]
and this is how I am doing it in Java
final static int RX_PIN = CPU.pin7; static Uart rxUart = new Uart(Uart.dirReceive, RX_PIN, Uart.dontInvert, Uart.speed2400,Uart.stop1); public static void main(){ if(rxUart.byteAvailable()){ System.out.println("here1"); c = (char)rxUart.receiveByte(); buffer.append(c); }
this code is also from the javelin manual, so it should work, the only thing is the parameters I'm using for the Uart object I'm creating.
According to the RFID Readers·documents it says
Pin SOUT function: Serial Out. TTL-level interface, 2400bps, 8 data bits, no parity, 1 stop bit, true.
I dont know what the true means, but the rest of it should be the same as I've put in the code. No?
Anyway, here are some links to the documents I am talking about. Any help/suggestions would be greatly appreciated.
Doc Links:
RFID Reader: http://www.parallax.com/dl/docs/prod/audiovis/RFID-Reader-v1.1.pdf· (page 2)
Reader Basic Stamp Code: http://www.parallax.com/dl/src/prod/RFID1.BS2
Javelin Stamp Manual (section about Uart):
http://www.parallax.com/dl/docs/prod/javelin/JavelinStampMan1-0.pdf
Thanks alot.
·
Comments
static boolean start = false;
public static void main(){ · while (true) { //wait for multiple bytes to receive
··· if (rxUart.byteAvailable()) {
····· c = (char)rxUart.receiveByte();
····· if (!start) {
······· if (c == '\n') start = true; //WAIT($0A)
······}
····· else {
······· buffer.append(c); //STR buf\10
······· index++;
······· if (index == 10) {
········· for (int j=0; j<10; j++) {
··········· System.out.print(buffer.charAt(j)); //print received bytes
········· }
········· System.out.print('\n'); //print newline
········· index =0; //reset buf index
········· start = false; //wait for $0A again
······· }
····· }
··· }
· }
}
regards peter
Thanks again.
Which ID's did you read with your javelin program?
regards peter