|
||||||
| Electronics | Audio | NAV | Infotainment Anything related to in-car electronics, navigation, and infotainment. |
![]() |
|
|
Thread Tools | Search this Thread |
|
|
#71 | |
|
There are now 2 carseats!
Join Date: Nov 2012
Drives: 2013 DGM BRZ
Location: The Emerald City
Posts: 434
Thanks: 21
Thanked 166 Times in 75 Posts
Mentioned: 7 Post(s)
Tagged: 0 Thread(s)
|
Quote:
Code:
if (whichSensor.indexOf("obdbrzoiltempf") >= 0){
Serial1.println("2101");
getResponse2();
Serial.println("brz oil temp");
delay(40);
value = ((float)strtol(&rxData[109],0,16) - 40) * 1.8 + 32;
Serial.println(value);
Serial is just a usb serial monitor (standard arduino stuff) There are two versions of getResponse() that I've been toying with. One of which uses peek in a nice way. I think that's the right one to work on. I need to modify it to pick up multiple lines in the return of a CAN message. Code:
void getResponse(void){
char obdIn=0;
int i=0;
int start=millis();
//If nothing is currently available do nothing and break after 3 seconds
while(Serial1.available()==0){if(millis()-start>3000){break;}}
while(Serial1.available()){
//check to see if end of line/message
if (Serial1.peek()=='\r'){
obdIn=Serial1.read();
rxData[i]='\0';
Serial.println(rxData);
i=0;
}
// The prompt is sometimes the only thing recieved so this needs to be taken care of
else if(Serial1.peek()=='>'){
obdIn=Serial1.read();
//Serial.write(obdIn);
}
// Add next character to string
else{
obdIn=Serial1.read();
rxData[i++]=obdIn;
}
}
Serial.print("rxData(in getResponse): ");
Serial.println(rxData);
rxIndex=0;
}
This is the other one: Code:
//from: https://forum.sparkfun.com/viewtopic.php?f=14&t=32457&start=60 and https://forum.sparkfun.com/viewtopic.php?f=14&t=38253
void getResponse2(void){
char c;
int start=millis();
//If nothing is currently available do nothing and break after 3 seconds
while(Serial1.available()==0){if(millis()-start>3000){break;}}
do {
if (Serial1.available() > 0)
{
c = Serial1.read();
if ((c != '>') && (c != '\r') && (c != '\n')) //Keep these out of our buffer
{
rxData[rxIndex++] = c; //Add whatever we receive to the buffer
}
}
}
while (c != '>'); //The ELM327 ends its response with this char so when we get it we exit out.
rxData[rxIndex++] = '\0'; //Converts the array into a string
Serial.print("rxData(in getResponse2): ");
Serial.println(rxData);
rxIndex = 0; //Set this to 0 so next time we call the read we get a "clean" buffer
}
I can use a basic program to send typed commands directly to the device and it seems to work, which leads me to believe that this is timing related. At the moment after doing an ATZ and ATE0 the first display page/sensor reading is water temp and it just returns "?". If I stick entirely to using the second getResponse (without the peek). Everything works, except the water temp...this is what really has me stumped. |
|
|
|
|
|
|
#72 |
|
There are now 2 carseats!
Join Date: Nov 2012
Drives: 2013 DGM BRZ
Location: The Emerald City
Posts: 434
Thanks: 21
Thanked 166 Times in 75 Posts
Mentioned: 7 Post(s)
Tagged: 0 Thread(s)
|
So, using the getResponse() without the peek I added a reading of water temp in my initial setup routines. It reads correctly there, but screws up in the actual display code.
I must be close to solving it, right .Sleep, or code, hmmm.... |
|
|
|
|
|
#73 |
|
There are now 2 carseats!
Join Date: Nov 2012
Drives: 2013 DGM BRZ
Location: The Emerald City
Posts: 434
Thanks: 21
Thanked 166 Times in 75 Posts
Mentioned: 7 Post(s)
Tagged: 0 Thread(s)
|
I chose sleep: https://github.com/stirobot/arduinoM...6fd00e4247274e is where i left off. Maybe fresh eyes can figure out why all normal PID's and oil temp work but the !#$!@# coolant temp won't show up.
(yet it shows up in that initial setup if I put it there FFS) |
|
|
|
|
|
|
|
|
|
Similar Threads
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| EGT gauge | SubBrZ | Engine, Exhaust, Transmission | 23 | 11-10-2015 10:31 PM |
| Gauge pod | ikeryder13 | Want-To-Buy Requests | 4 | 03-30-2014 02:02 PM |
| WTB DCW gauge pod | mikepaul21 | Want-To-Buy Requests | 1 | 03-26-2014 09:28 PM |
| FS DCW Gauge Pod | whitefrs | Interior Parts (Incl. Lighting) | 7 | 03-26-2014 03:39 PM |
| Temperature Gauge a dummy gauge? | bambbrose | BRZ First-Gen (2012+) — General Topics | 40 | 08-19-2012 05:29 PM |