This commit is contained in:
topicchi
2024-09-24 16:54:39 +00:00
parent e3ca99e4db
commit c7a68c0205
332 changed files with 6098 additions and 4139 deletions

View File

@@ -1,17 +1,48 @@
#include <ESP8266WiFi.h>
#include "SoftwareSerial.h"
SoftwareSerial swSer1;
SoftwareSerial swSer2;
#ifndef D5
#if defined(ESP8266)
#define D5 (14)
#define D6 (12)
#elif defined(ESP32)
#define D5 (18)
#define D6 (19)
#endif
#endif
EspSoftwareSerial::UART swSer1;
EspSoftwareSerial::UART swSer2;
void checkSwSerial(EspSoftwareSerial::UART* ss) {
byte ch;
while (!Serial.available());
ss->enableTx(true);
while (Serial.available()) {
ch = Serial.read();
ss->write(ch);
}
ss->enableTx(false);
// wait 1 second for the reply from EspSoftwareSerial if any
delay(1000);
if (ss->available()) {
Serial.print(PSTR("\nResult:"));
while (ss->available()) {
ch = (byte)ss->read();
Serial.print(ch < 0x10 ? PSTR(" 0") : PSTR(" "));
Serial.print(ch, HEX);
}
Serial.println();
}
}
void setup() {
delay(2000);
Serial.begin(115200);
Serial.println(PSTR("\nOne Wire Half Duplex Serial Tester"));
swSer1.begin(115200, SWSERIAL_8N1, 12, 12, false, 256);
swSer1.begin(115200, EspSoftwareSerial::SWSERIAL_8N1, D6, D6, false, 256);
// high speed half duplex, turn off interrupts during tx
swSer1.enableIntTx(false);
swSer2.begin(115200, SWSERIAL_8N1, 14, 14, false, 256);
swSer2.begin(115200, EspSoftwareSerial::SWSERIAL_8N1, D5, D5, false, 256);
// high speed half duplex, turn off interrupts during tx
swSer2.enableIntTx(false);
}
@@ -26,25 +57,3 @@ void loop() {
checkSwSerial(&swSer2);
}
void checkSwSerial(SoftwareSerial* ss) {
byte ch;
while (!Serial.available());
ss->enableTx(true);
while (Serial.available()) {
ch = Serial.read();
ss->write(ch);
}
ss->enableTx(false);
// wait 1 second for the reply from SOftwareSerial if any
delay(1000);
if (ss->available()) {
Serial.print(PSTR("\nResult:"));
while (ss->available()) {
ch = (byte)ss->read();
Serial.print(ch < 0x10 ? PSTR(" 0") : PSTR(" "));
Serial.print(ch, HEX);
}
Serial.println();
}
}