Well, I used your code, and it partially worked. I now get a full 107 byte buffer, however, every byte past byte 67 is 0, including the checksum, so I know I am still not reading the data correctly
here is my current code:
/*
This program is used for an Arduino to request and retrieve
data from an 07 Buell XB9SX Lightning ECM DDFI-2,
EEPROM Version: BUEIB
Currently the Arduino successfully sends a request code and
receives only 67 bytes of the run-time response, and displays
on the LCD screen and via serial monitor.
Created by Michael Blaylock
*/
// include the library code:
#include <LiquidCrystal.h>
#include <SoftwareSerial.h>
//new serial pins for ECM, 0 and 1 caused interferance from PC
#define rxPin 2
#define txPin 3
// set up a new serial port
SoftwareSerial mySerial = SoftwareSerial(rxPin, txPin);
// initialize the library with the numbers of the interface pins
LiquidCrystal lcd(7, 8, 9, 10, 11, 12);
byte inArray[9]; //request code for real-time data
byte outArray[107]; //real-time data series from ECM
byte long Value;
int First = 0;
int q;
int j;
void setup(){
lcd.begin(16, 2); // set up the LCD's number of columns and rows:
mySerial.begin(9600); // baud rate for the ECM is 9600
Serial.begin(9600);
q=0;
inArray[0]=0x01; //SOH
inArray[1]=0x00; //Emittend
inArray[2]=0x42; //Recipient
inArray[3]=0x02; //Data Size
inArray[4]=0xFF; //EOH
inArray[5]=0x02; //SOT
inArray[6]=0x43; //Data 1 //0x56 = Get version, 0x43 = Get runttime data
inArray[7]=0x03; //EOT
inArray[8]=0xFD; //Checksum
lcd.setCursor(0,0);
//Stream request data series to ECM as HEX
for (int i = 0; i<9; i+=1){
mySerial.write(inArray[i]);
lcd.print(inArray[i],HEX); //print sent HEX code
}
}
void processIncomingByte (const byte c){
q++;
outArray[q] = c;
Serial.println(outArray[q],HEX);
if(q > 107){
q = 0;
}
}
//display the array in serial monitor one time
void display(){
if(First < 1){
if(j<107){
Serial.println(outArray[j],HEX);
j++;
}
else{
First++;
j=0;
}
}
}
//void loop() {
// //read the incoming data
// if (mySerial.available())
// processIncomingByte (mySerial.read());
//
// //concatenate 2 byte RPM data
// // unsigned Value = outArray[31] << 8 | outArray[30];
// // lcd.setCursor(0,1);
// // lcd.print("temp: ");
// // lcd.print((Value*0.18-40));
// // display();
//}
void loop() {
// fill buffer
if (mySerial.available () > 0)
outArray[q++] = mySerial.read ();
if(mySerial.overflow())
Serial.print("overflow");
if (q >= 107){
// process it
q = 0; // ready for next time
} // end if full
display();
} // end of loop
and this is the response I got from the ECM:
1
42
0
overflow64
overflowFF
2
6
7B
E
0
0
0
0
0
0
0
0
BB
20
BB
20
B5
35
B5
35
33
0
F
A6
4
65
2
93
2
0
0
6B
2
1F
6
E8
3
0
0
E8
3
E8
3
E8
3
E8
3
30
4
30
4
0
80
0
0
0
0
0
0
0
FC
10
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
I noticed that when I tried to read more than 107 bytes (up to 500) the code began to repeat after about 116 bytes (but no header), then after that repeat, it was just a bunch of random Hex mess.
Any ideas?