Added serial data processing

This commit is contained in:
Mike C 2013-04-09 18:11:08 -04:00
parent 18e6356df1
commit db6e6b940d
3 changed files with 41 additions and 0 deletions

View file

@ -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;
}
}

View file

@ -43,6 +43,7 @@ public:
void disableUI();
void enableUI();
bool isUIEnabled();
void processSerialData();
};
#endif

View file

@ -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();
}