Tourneur:
In first Sirs ,
Many thanks for your help ,
In first sterretje, the data return converted in ASCII format concern uniquely the version of reader format ,the first fonction ,I was test.
After, all the data from the this reader, are in hex fomat.
Thats works ,but I'm trying to reduce the total data received from a Tag ID .
You have ,the mode ,the type of tag ,the CRC ,and the ID ,I would like to remove few of these frame and display them on the IDE monitor ,before display it on a little oled display.
The reader is Nano US, from Netronix ,it's a multiprotocol reader .
I let here the sheets .
And my complete code.
Last version
/*
<> RFID Reading / Writting
<> Nano-US v10 and Higher
<> v 0.0.5
NEW > Software serial bus use for communication and harware for monitoring
> L112 or L113 antenna
> Firmware selecting mode
> Reading hardware version
> Custom shield used
# Hardware Custom shield pins assignement :
- Mode INTER1 > DO4
INTER2 > DO5
INTER3 > DO6
- Uart Tx > D012
Rx > DO11
*/
// ########### Library added ###########
#include <SoftwareSerial.h>
// ########### Variable ################
// Software serial used
SoftwareSerial ss(12, 11);
void monitoring_asc ()
{
ss.listen(); // Listen is frames presents
delay(200); // let a delay of 200 ms before reading
while(ss.available() >0) //
{
String inbyte = ss.readString(); // Use string function
inbyte.remove(2,1); // Remove at position 2 of the frame one byte
inbyte.remove(14,2); // Remove at position 14 of the frame two bytes
Serial.print(inbyte); // Print the result on serial monitor
delay(50); // Let a delay between frame
}
}
void monitoring_hex ()
{
ss.listen(); // Listen is frames presents
delay(200); // let a delay of 200 ms before reading
while(ss.available() >0) //
{
int inbyte = ss.read();
// String inbyte = ss.readString(); // Use string function
//inbyte.remove(2,1); // Remove at position 2 of the frame one byte
// inbyte.remove(14,2); // Remove at position 14 of the frame two bytes
Serial.print(inbyte,HEX); // Print the result on serial monitor
delay(50); // Let a delay between frame
}
}
void setup()
{
// Serials (Hard and soft)
Serial.begin(19200);
ss.begin(9600);
// Mode (UART mode used here, all Inter at high)
pinMode(4, OUTPUT);
pinMode(5, OUTPUT);
pinMode(6, OUTPUT);
digitalWrite (4, HIGH);
digitalWrite (5, HIGH);
digitalWrite (6, HIGH);
// ********* Command control *********
// ########### Show version of module #############
// Header
ss.write(0x01); // Module adress ,default is 1
ss.write(0x05); // Frame length
// Command
ss.write(0xFE); // Call version command
// CRC(xModem calculation)
ss.write(0xC6); // CRCH
ss.write(0x14); // CRCL
monitoring_asc();
// ########### Select transponder type #############
delay(500); // Let a delay of 0,5 s before call a new command
// Header
ss.write(0x01); // Module adress ,default is 1
ss.write(0x05); // Frame length
// Command
ss.write(0x02); // Select transponder type changing
ss.write(0x03); // Type unique
ss.write(0x01); // With a gain of 0x1
// CRC(xModem calculation)
ss.write(0xE8); // CRCH
ss.write(0x87); // CRCL
Serial.println();
monitoring_asc();
// ########### Turn on antenna #############
delay(500); // Let a delay of 0,5 s before call a new command
// Header
ss.write(0x01); // Module adress ,default is 1
ss.write(0x05); // Frame length
// Command
ss.write(0x10); // Select transponder type changing
ss.write(0x01); // Type unique
// CRC(xModem calculation)
ss.write(0xDA); // CRCH
ss.write(0xF4); // CRCL
Serial.println();
monitoring_asc();
// Header
ss.write(0x01); // Module adress ,default is 1
ss.write(0x05); // Frame length
// Command
ss.write(0x12); // Select transponder type changing
// CRC(xModem calculation)
ss.write(0xFA); // CRCH
ss.write(0xB6); // CRCL
delay(1000); // Let a delay of 0,5 s before call a new command
Serial.println();
}
void loop()
{
// ########### Read transponder ID #############
monitoring_hex();
delay(500);
}
jremington
"The easiest way to do that is to avoid use of unreliable Strings, and read all the bytes into a C-string, a zero terminated character array."
I 'm sure you have reason, but it's why I posted my question in this forum ...
Like I explained before ,I kept the little serial communication code from an web thread ,cause I was not arrive to realize a serial communication by myself ,even it's not my first program .
Possibilities ,thats I copied a bad and unadapted code are great possible .
I thinked this RFID system ,could not be very difficult ,and I realized my error ....
[
I am trying to do the same thing as above with a laser but I'm using a micro and the laser is on Serial1 how do I write that since listen wont work