Hey guys. Having a bit of trouble with the new arduino 1.0. I am trying to interface with a parallax rfid module (28440) and up until now I had been Using the following code:
//Code to read data from Parallax RFID reader/writer 28440 via Arduino //Program reads data from one of the 29 user-defined addresses (3-31) as define by whichSpace //Writen by vgrhcp based on codeby uberdude
#include <NewSoftSerial.h> #define RFID_READ 0x01 #define txPin 6 #define rxPin 8
#define whichSpace 4
NewSoftSerial mySerial(rxPin, txPin); int val; int runs = 0;
void setup() { Serial.begin(9600); Serial.println("RFID Read Test"); mySerial.begin(9600); pinMode(txPin, OUTPUT); pinMode(rxPin, INPUT); }
void suppressAll() //suppresses the "null result" frombeing printed if no RFID tag is present { if(mySerial.available() > 0) { mySerial.read(); suppressAll(); } }
void loop() { int val; mySerial.print("!RW"); mySerial.print(RFID_READ, BYTE); mySerial.print(whichSpace, BYTE);
if(mySerial.available() > 0) { val = mySerial.read(); //The mySerial.read()procedureiscalled,but theresult isnot printed becauseI don't want the "error message: 1" cluttering up the serial monitor if (val != 1) //If the errorcodeis not 1, then there has been an error and the RFID tag was not read correctly.In thiscasewedon't really careabout theresultant values,sothey can be suppressed {suppressAll();} }
if(mySerial.available() > 0) { val = mySerial.read(); Serial.print("1st:"); Serial.println(val, DEC); }
if(mySerial.available() > 0) { val = mySerial.read(); Serial.print("2nd:"); Serial.println(val, DEC); }
if(mySerial.available() > 0) { val = mySerial.read(); Serial.print("3rd:"); Serial.println(val, DEC); }
if(mySerial.available() > 0) { val = mySerial.read(); Serial.print("4th:"); Serial.println(val, DEC); Serial.println("-----------------"); }
delay(750); }
t
Hope the formatting worked on that one. Anyway, if you notice at the beginning of the loop is the keyword BYTE. According to the release notes BYTE no longer works, which would explain all the errors while compiling. Any suggestions for how to fix this? If I understood the release notes correctly they want me to use some different library or something like that.
In file included from sketch_dec25a.cpp:1:0:
/home/seb/arduino-1.0/libraries/NewSoftSerial/NewSoftSerial.h:71:16: error: conflicting return type specified for ‘virtual void NewSoftSerial::write(uint8_t)’
/home/seb/arduino-1.0/hardware/arduino/cores/arduino/Print.h:48:20: error: overriding ‘virtual size_t Print::write(uint8_t)’
/home/seb/arduino-1.0/libraries/NewSoftSerial/NewSoftSerial.h: In function ‘void loop()’:
/home/seb/arduino-1.0/libraries/NewSoftSerial/NewSoftSerial.h:71:16: error: ‘virtual void NewSoftSerial::write(uint8_t)’ is private
sketch_dec25a.cpp:31:23: error: within this context
sketch_dec25a.cpp:31:23: error: invalid conversion from ‘const char*’ to ‘uint8_t’
sketch_dec25a.cpp:31:23: error: initializing argument 1 of ‘virtual void NewSoftSerial::write(uint8_t)’
/home/seb/arduino-1.0/libraries/NewSoftSerial/NewSoftSerial.h:71:16: error: ‘virtual void NewSoftSerial::write(uint8_t)’ is private
sketch_dec25a.cpp:32:29: error: within this context
Could you maybe recommend a fix? I'm not proficient enough to be able to solve it. I now have a different paragraph of errors after feeding chars into myserial.write.
kinda got that far myself. here are all of the errors:
In file included from sketch_dec25a.cpp:1:0:
/home/seb/arduino-1.0/libraries/NewSoftSerial/NewSoftSerial.h:71:16: error: conflicting return type specified for ‘virtual void NewSoftSerial::write(uint8_t)’
/home/seb/arduino-1.0/hardware/arduino/cores/arduino/Print.h:48:20: error: overriding ‘virtual size_t Print::write(uint8_t)’
sketch_dec25a.cpp: In function ‘void loop()’:
sketch_dec25a.cpp:31:28: error: cast from ‘const char*’ to ‘byte’ loses precision //!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
/home/seb/arduino-1.0/libraries/NewSoftSerial/NewSoftSerial.h:71:16: error: ‘virtual void NewSoftSerial::write(uint8_t)’ is private
sketch_dec25a.cpp:31:29: error: within this context
/home/seb/arduino-1.0/libraries/NewSoftSerial/NewSoftSerial.h:71:16: error: ‘virtual void NewSoftSerial::write(uint8_t)’ is private
sketch_dec25a.cpp:32:35: error: within this context
I marked the one that seemed to be the most important. I assume this error is happening because it can't "byte(0x0F)", it can only "byte()" one char at a time.
sebflippers:
Could you maybe recommend a fix? I'm not proficient enough to be able to solve it. I now have a different paragraph of errors after feeding chars into myserial.write.
I can't seem to be able to access arduiniana.org where the NewSoftSerial library is hosted. But if it has not changed a bit, then you can't use write in that library cause it says clearly on the error message, write is a private method. I don't know why but that is the truth. You can only do:
newsoftserial.print((uint8_t)RFID_LEGACY);
In fact, I agree with PaulS on everything except the above. newsoftserial stuff should only make the above change.
guess i'll need to use a different library. In order to do that I would like to learn more about the serial connections,though. what kind of connection is it? could somebody give me a wikipedia link?
The SoftwareSerial class has been reimplemented, using the code originally
written for the NewSoftSerial library by Mikal Hart. This allows for
multiple simultaneous instances, although only one can receive at a time.
So I believe you can just change your code: (as originally posted):
//Code to read data from Parallax RFID reader/writer 28440 via Arduino //Program reads data from one of the 29 user-defined addresses (3-31) as define by whichSpace //Writen by vgrhcp based on codeby uberdude
#include <NewSoftSerial.h> #define RFID_READ 0x01 #define txPin 6 #define rxPin 8
#define whichSpace 4
NewSoftSerial mySerial(rxPin, txPin); int val; int runs = 0;
to
//Code to read data from Parallax RFID reader/writer 28440 via Arduino //Program reads data from one of the 29 user-defined addresses (3-31) as define by whichSpace //Writen by vgrhcp based on codeby uberdude
#define RFID_READ 0x01 #define txPin 6 #define rxPin 8
#define whichSpace 4
SoftwareSerial mySerial(rxPin, txPin); int val; int runs = 0;