Added change baudrate
This commit is contained in:
parent
f5c28f3c64
commit
99890dc48c
@ -49,8 +49,19 @@ void setup() {
|
||||
Serial2.begin(300, SERIAL_7E1, 36, 4);
|
||||
|
||||
Serial.println("Test ZPA elektro");
|
||||
|
||||
|
||||
Serial.println("================");
|
||||
Serial.println();
|
||||
Serial.println("R - Request (sends /?!<CR><LF>)");
|
||||
Serial.println("C - Change baudrate to 4800 (sends <ACK>040<CR><LF>)");
|
||||
Serial.println();
|
||||
Serial.println("Manual baudrate");
|
||||
Serial.println("1 - 300b");
|
||||
Serial.println("2 - 1200b");
|
||||
Serial.println("3 - 2400b");
|
||||
Serial.println("4 - 4800b");
|
||||
Serial.println("5 - 9600b");
|
||||
Serial.println();
|
||||
Serial.println();
|
||||
Serial.println("Ready");
|
||||
Serial.print("IP address: ");
|
||||
Serial.println(WiFi.localIP());
|
||||
@ -71,7 +82,12 @@ void loop() {
|
||||
}
|
||||
|
||||
if (r == 0x03) {
|
||||
Serial.print("<ETX>");
|
||||
Serial.println("<ETX>");
|
||||
Serial.print("Checksum <BCC>: ");
|
||||
Serial.println(Serial2.read());
|
||||
Serial.println();
|
||||
Serial.println("Changing back baudrate to 300");
|
||||
Serial2.updateBaudRate(300);
|
||||
return;
|
||||
}
|
||||
|
||||
@ -88,10 +104,37 @@ void loop() {
|
||||
return;
|
||||
}
|
||||
|
||||
if (r == '1') {
|
||||
Serial.println("Baudrate to 300");
|
||||
Serial2.updateBaudRate(300);
|
||||
}
|
||||
|
||||
if (r == '2') {
|
||||
Serial.println("Baudrate to 1200");
|
||||
Serial2.updateBaudRate(1200);
|
||||
}
|
||||
|
||||
if (r == '3') {
|
||||
Serial.println("Baudrate to 2400");
|
||||
Serial2.updateBaudRate(2400);
|
||||
}
|
||||
|
||||
if (r == '4') {
|
||||
Serial.println("Baudrate to 4800");
|
||||
Serial2.updateBaudRate(4800);
|
||||
}
|
||||
|
||||
if (r == '5') {
|
||||
Serial.println("Baudrate to 9600");
|
||||
Serial2.updateBaudRate(9600);
|
||||
}
|
||||
|
||||
if (r == 'C') {
|
||||
Serial.println("Trying change baudrate");
|
||||
Serial.println("Change baudrate");
|
||||
Serial2.write(0x06);
|
||||
Serial2.print("030\r\n");
|
||||
Serial2.print("040\r\n");
|
||||
Serial2.flush();
|
||||
Serial2.updateBaudRate(4800);
|
||||
return;
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user