Board : Arduino DUE
Serial2 connect some device.
I want to send BREAK signal to Serial2.
Following code make hardware break signal to Serial2.
Working good~!
But,
After Send Break Just One Time,
Serial2 Tx Pin can’t send any data.
So, After Send Break, can’t communicate Serial2 device;
What’s wrong this code ?
void SendBreak(int ms);
char c;
//////////////////////////////////////////////////////////////////////////////////////////
void setup() {
Serial.begin(9600);
Serial2.begin(9600);
Serial.println("Ready...");
}
//////////////////////////////////////////////////////////////////////////////////////////
void loop() {
SendBreak(500); // Send BREAK Signal to Serial2 .. Wake up Serial2 Device
for ( int i = 0 ; i < 50 ; i++ ) { // 5 second waiting..
delay(100); // Serial2 device reset, and print banner
while (Serial2.available()) { // Company, Device Name, Version, etc..
c = Serial2.read();
Serial.print(c);
}
}
Serial2.write("C?\r",3); // Request Device status
for ( int i = 0 ; i < 50 ; i++ ) { // not responding in 5 second.
delay(100);
while (Serial2.available()) {
c = Serial2.read();
Serial.print(c);
}
}
}
//////////////////////////////////////////////////////////////////////////////////////////
void SendBreak(int ms)
{
Serial2.end(); // Release Serial Mode
pinMode(16, OUTPUT); // Setup Output mode
digitalWrite(16, HIGH); // Send BREAK Signal
delay(ms); // 500 ms
digitalWrite(16, LOW); // Set Idle Status
Serial2.begin(9600); // Serial Mode Begin
}