Added serial data processing
This commit is contained in:
parent
18e6356df1
commit
db6e6b940d
|
@ -148,3 +148,38 @@ void Config::setDefaults() {
|
|||
setMode(ttl);
|
||||
setTimeout(thirtyseconds);
|
||||
}
|
||||
|
||||
void Config::processSerialData() {
|
||||
switch (currentMode) {
|
||||
case 1: // ttl
|
||||
if (Serial1.available()) {
|
||||
int inByte = Serial1.read();
|
||||
Serial.write(inByte);
|
||||
}
|
||||
if (Serial.available()) {
|
||||
int inByte = Serial.read();
|
||||
Serial1.write(inByte);
|
||||
}
|
||||
break;
|
||||
case 2: // db9_null
|
||||
if (Serial2.available()) {
|
||||
int inByte = Serial2.read();
|
||||
Serial.write(inByte);
|
||||
}
|
||||
if (Serial.available()) {
|
||||
int inByte = Serial.read();
|
||||
Serial2.write(inByte);
|
||||
}
|
||||
break;
|
||||
case 3: // cisco
|
||||
if (Serial3.available()) {
|
||||
int inByte = Serial3.read();
|
||||
Serial.write(inByte);
|
||||
}
|
||||
if (Serial.available()) {
|
||||
int inByte = Serial.read();
|
||||
Serial3.write(inByte);
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
|
@ -43,6 +43,7 @@ public:
|
|||
void disableUI();
|
||||
void enableUI();
|
||||
bool isUIEnabled();
|
||||
void processSerialData();
|
||||
};
|
||||
|
||||
#endif
|
||||
|
|
|
@ -33,7 +33,12 @@ void setup() {
|
|||
}
|
||||
|
||||
void loop() {
|
||||
// Serial data is processed at multiple points to prevent
|
||||
// UI code from interfering with communication
|
||||
config->processSerialData();
|
||||
ui->processInputEvents();
|
||||
config->processSerialData();
|
||||
ui->processTimeoutEvents();
|
||||
config->processSerialData();
|
||||
}
|
||||
|
||||
|
|
Reference in a new issue