Sending byte array over Serial1 in Mega

Hi everyone.

I have a Mega and a RFID reader which have usb connector. I want to send byte array to that reader with using Serial1 pins. The most basic of the reader is "Reset". And it is my first target to successfully send that code. But i am bricked. The message format for resetting the reader is that:

Head | Length | Address | Command | Checksum

Each cell is one byte long. And "head" cell must be 0xA0.

I debugged its .net code step by step, program sends reader 0xA0, 0x03, 0x01, 0x70 and 0xEE.

I convert them into a byte array in Arduino and send over serial1. But reader did not response.

The code I am using is attached and also placed in following lines;

//byte my_serial_bytes[5]={0xA0, 0x03, 0xFF, 0x70, 0xEE };
byte my_serial_bytes[5]={
160, 3, 1, 112, 236 };

void setup()
{
Serial2.begin(115200);
Serial.begin(9600);

}

void loop()
{
// Serial1.write(my_serial_bytes,sizeof(my_serial_bytes));
while(Serial.available())
{
Serial.print((char)Serial2.read());
}
for(int i=0;i<sizeof(my_serial_bytes);i++)
{
Serial1.write(my_serial_bytes*);*

  • }*
    }
    I am newbie so thanks in advance for your help.
    Best regards,
    Gokay
    rfidMega.ino (454 Bytes)

I have a Mega and a RFID reader which have usb connector. I want to send byte array to that reader with using Serial1 pins.

You can not send data to a USB device using serial, the two are totally different things.

Sorry for flood. I did send byte array to RFID reader via max232. But how can i get response packet ? I did not get over it yet.

Sorry no idea what you mean by this.

How about reading the rules and correcting that first post.
How to use this forum