Hello all,
I'm using a Mega2560 to communicate with the serial port on a Moates Demon board (for Honda obd1 ecus). I'm hoping you folks can help me out. I have a list of commands that I can send to the device and get assorted responses. Specifically, if I send an ascii 'd', I should get a data laden hex string that looks like this:
4F(edited)4F9B
So far, I've been able to
- Communicate with the device through RealTerm at 921.6k with an FTDI cable
- Communicate with the device through RealTerm and its native USB port (which is just using another FTDI, so kind of redundant there)
- Get the Mega to send the packet to itself at 921.6k (from Serial3 to Serial1 and then out Serial0 to the monitor)
- Expand the Serial buffer to 128 bytes so I have room for the whole packet.
- Capture and decode most of the serial protocol by watching the data while manipulating the ecu with an engine simulator that I built.
but I'm stuck now. With a logic analyzer I can see the signal going out every other second, but I'm not getting any responses... not sure where I've gone wrong in my noobishness. All I'm trying to do right now is to get the data to the buffer so I can grab bytes and send them to the monitor.
The code:
/*
Serial Practice
Two Ports
Moates Demon Communication
*/
int trigByte= 0x64;
int demonByte = 0;
int delayTime = 1000;
void setup()
{
//Initialize Ports 0 & 1
Serial.begin(115200);
Serial3.begin(921600);
}
void loop()
{
//Pause, then send request to Port 3
delay(delayTime);
Serial3.write(trigByte);
//Pause, then read incoming data from port 3. Send to port 0
delay(delayTime);
if (Serial3.available() > 0)
{
int demonByte = Serial3.read(); //read byte from port 3
Serial.write(demonByte); //send to port 0
}
}