Serial.print("s");//put here command to send to the device
int i=0;
while (Serial.available() > 0) {
if(i<30){
data=(char)Serial.read();
i++;
data='\0';
}
}
Do something, and report back within the next 62.5 nanoseconds. Does that seem like a reasonable duration to wait for the response?
Without the ethernet shield/code in the way, do you get valid data from the device?
How are you managing to talk to the device AND the serial port at the same time?
Finally, what kind of device is it? The data you are seeing looks like the device is NOT a TTL device.