Post by rayman on Aug 17, 2014 12:44:04 GMT -8
i read data from serial and write to serial-logger, that works fine without gd2 display
with gd i lose >90% serial data
i not understand the problem
#include <EEPROM.h>
#include <Wire.h>
#include <SPI.h>
#define SIN Serial1
#define Logger Serial3
unsigned int OpenLogResetPin = 6;
void setup() {
pinMode(OpenLogResetPin, OUTPUT);
Serial.begin(115200);
Logger.begin(38400);
SIN.begin(19200, SERIAL_8N2);
delay(100);
LoggerInit();
}
void loop() {
static boolean startByte;
static int count;
if ( SIN.available() ) {
int inByte = SIN.read();
if(startByte == false && inByte == 105) {
startByte = true;
count = 0;
Logger.write(inByte); // write 105 to logger
} else {
Logger.write(inByte);
count++;
if(count == 124)
startByte = false;
}
}
}
with gd i lose >90% serial data
#include <EEPROM.h>
#include <Wire.h>
#include <SPI.h>
#include <GD2.h>
#define SIN Serial1
#define Logger Serial3
unsigned int OpenLogResetPin = 6;
void setup() {
pinMode(OpenLogResetPin, OUTPUT);
Serial.begin(115200);
Logger.begin(38400);
SIN.begin(19200, SERIAL_8N2);
GD.begin();
GD.ClearColorRGB(0xff0000);
GD.Clear();
GD.swap();
delay(100);
LoggerInit();
}
void loop() {
GD.ClearColorRGB(0x0000ff);
GD.Clear();
GD.cmd_number(240, 136, 30, 10|OPT_CENTER, millis());
GD.swap();
static boolean startByte;
static int count;
if ( SIN.available() ) {
int inByte = SIN.read();
if(startByte == false && inByte == 105) {
startByte = true;
count = 0;
Logger.write(inByte); // write 105 to logger
} else {
Logger.write(inByte);
count++;
if(count == 124)
startByte = false;
}
}
}
i not understand the problem