Arduino Resetting continuosly when it reads data from SoftwareSerial....

I have hardware which specification is

Protocol:- Asynchronous serial interface
Baud Rate:-9600 baud
#Start bits:-1
#Data bits:-8
#Stop bits: -1
Parity:-None

when I am communicating with this hardware with my Arduino Nano 's Software serial my Arduino resetting after every loop executes.

Here is my code...

#include<SoftwareSerial.h>
#define SoftSerialRx_pin 6
#define SoftSerialTx_pin 5

SoftwareSerial mySerial(SoftSerialRx_pin,SoftSerialTx_pin);

int c,i=0,d[50];
float voltage,current;
bool flg = 0;

void setup() {
  Serial.begin(9600);
  mySerial.begin(9600);
  Serial.println();
  Serial.println("Setup call#################################################################################################");
}

void loop() {
  Serial.println("Loop call____________________________@@@@@@@@@@@@@@@@");
  DataTest();
     
}

void DataTest()
{
  c =0;
  mySerial.write(0xDD); mySerial.write(0xA5); mySerial.write(0x03); mySerial.write((byte)0x00); mySerial.write(0xFF); mySerial.write(0xFD); mySerial.write(0x77);
  while(c != 0x77)
  { if(mySerial.available())    {
          if((c = mySerial.read()) != -1)      {
             d[i] = c;           i++;    
      }
    }
    
  }
  Serial.print(" data : - ");
  for(int j =0 ; j< i ; j++)
  {
    Serial.print(d[j], HEX);
    Serial.print("\t");
  }
  Serial.println();
}

and output is

Setup call#################################################################################################
14:03:28.513 -> Loop call____________________________@@@@@@@@@@@@@@@@
14:03:28.595 ->  data : - DD	3	0	1B	4	AB	0	0	5	3F	5	DC	0	9	26	81	0	0	0	0	0	0	17	5A	3	3	1	B	90	0	0	FC	4E	77	
14:03:28.695 -> Loop call_______________________
14:03:30.106 -> Setup call#################################################################################################
14:03:30.189 -> Loop call____________________________@@@@@@@@@@@@@@@@
14:03:30.282 ->  data : - DD	3	0	1B	4	AB	0	0	5	3F	5	DC	0	9	26	81	0	0	0	0	0	0	17	5A	3	3	1	B	90	0	0	FC	4E	77	
14:03:30.369 -> Loop call_______________________⸮
14:03:31.808 -> Setup call#################################################################################################
14:03:31.910 -> Loop call____________________________@@@@@@@@@@@@@@@@
14:03:31.977 ->  data : - DD	3	0	1B	4	AB	0	0	5	3F	5	DC	0	9	26	81	0	0	0	0	0	0	17	5A	3	3	1	B	90	0	0	FC	4E	77	
14:03:32.044 -> Loop call_______________________⸮
14:03:33.492 -> Setup call#################################################################################################
14:03:33.607 -> Loop call____________________________@@@@@@@@@@@@@@@@
14:03:33.643 ->  data : - DD	3	0	1B	4	AB	0	0	5	3F	5	DC	0	9	26	81	0	0	0	0	0	0	17	5A	3	3	1	B	90	0	0	FC	4E	77	
14:03:33.781 -> Loop call_______________________⸮

so anyone has an idea, why is my Arduino resetting?

First a comment, NOTHING follows a ;. New command = new line!

And short variable names might sound like a time-saver but really, the compiler gives 0 F*. They are an aid for you, pick names that make sense.

Next, are you sure you receive <50 bytes? For the fun of it, print what you read an the value of i every time you do a read.

Ahh, while editing your code to be more sensible, you never reset 'i' :wink: Aka, you WILL overflow your array.

#include<SoftwareSerial.h>
const byte SoftSerialRxPin = 6;
const byte SoftSerialTxPin = 5;

SoftwareSerial mySerial(SoftSerialRxPin,SoftSerialTxPin);

char dataArray[50];
const byte DataArrayLength = sizeof(dataArray);

void setup() {
  Serial.begin(9600);
  mySerial.begin(9600);
  Serial.println();
  Serial.println(F("Setup call#################################################################################################"));
}

void loop() {
  Serial.println(F("Loop call____________________________@@@@@@@@@@@@@@@@"));
  dataTest();
}

void dataTest() {
  byte bytesReceived = 0
  
  mySerial.write(0xDD); 
  mySerial.write(0xA5); 
  mySerial.write(0x03); 
  mySerial.write((byte)0x00); 
  mySerial.write(0xFF); 
  mySerial.write(0xFD); 
  mySerial.write(0x77);
  
  for(char c = 0; (c != 0x77) && (bytesReceived < DataArrayLength); ) {
    if(mySerial.available()) {
      c = mySerial.read();
      if(c != -1) {
        dataArray[bytesReceived++] = c;
      }
    }
  }
  
  Serial.print(F(" data : - "));
  for(byte i = 0 ; i < bytesReceived; i++) {
    Serial.print(dataArray[i], HEX);
    Serial.print("\t");
  }
  Serial.println();
}