• L'Assemblée Générale du Prius Touring Club aura lieu le 7 décembre 2024 du côté de Rennes. Si vous êtes adhérent renseignez-vous ici.

MBED, Arduino , STN1110 & BT

  • Initiateur de la discussion Initiateur de la discussion priusfan
  • Date de début Date de début
Impossible avec obdlink (stn1110)
dès que l'on passe en mode requête, le mode passif est neutralisé.
il y a bien un gugusse (2009Prius sur priuschat) qui tente de bidouiller mais qui plante invariablement son interface, d'ailleurs, il va dès que possible s'équiper comme moi.

le tactrix est mieux pour cela,

et mon machin est parfait :grin: du fait de:
a) pouvoir filtrer en amont.
b) s'occuper tout seul du lancement des requêtes
c) de la gestion (trame de relance) et de la consolidation des multitrames.

blague à part, on vient de procéder à un test avec thierryb et nous avons constaté que l'explication du 520 dans le document de kinetik est à revoir quant à sa fréquence. *
par contre, les (zotres) trames passives supervisées étaient bien dans la fourchette prévue.
la gestion des requêtes marche également comme prévue,
et une requête mal formée du type 7E0 21C4 au lieu de 7E2 21C4 ne plante ni la watture ni l'interface....

relevé fréquences:[table="head;width=60%"]|
025​
|
030​
|
038​
|
039​
|
03A​
|
0B4​
|
230​
|
244​
|
348​
|
3C8​
|
3CB​
|
3CF​
|
520​
|
526​
|
540​
|
5A4​
|
7EA​
|
Total​
|
|||||||||||||||||||
Total|
6672​
|
13649​
|
9949​
|
9744​
|
9663​
|
5254​
|
2460​
|
3023​
|
1836​
|
1180​
|
772​
|
608​
|
53​
|
159​
|
81​
|
25​
|
192​
|
65320​
|
FPS|
80,4
|
164,4
|
119,9
|
117,4
|
116,4
|
63,3
|
29,6
|
36,4
|
22,1
|
14,2
|
9,3
|
7,3
|
0,6
|
1,9
|
1,0
|
0,3
|
2,3
||
[/table]

* edit à propos du 520, ben non, 😳 c'est normal: pour effectuer 20 tours moteur, cela prend du temps...
 
Dernière édition:
Est-ce une coïncidence mais un 2009Prius se présente à l'instant comme nouvel inscrit ?
 
yes this is a "coincidence", in fact he has a direct access to this section.

welcome to 2009Prius,

he knows somebody able to build nice hardware, and I hope this guy will show up here, so we could make a nice interface....
 
on vient de procéder à un test avec thierryb et nous avons constaté que l'explication du 520 dans le document de kinetik est à revoir quant à sa fréquence.
Dites-m'en plus ! Sur une demi-heure, j'ai déterminé un écart de moins de 100 tours moteur !
edit à propos du 520, ben non, c'est normal: pour effectuer 20 tours moteur, cela prend du temps...
En effet, sur le trajet ci-joint, mon moteur a tourné en moyenne à 660 t/min, soit environ 20 tours toutes les 2 secondes. Pour asseoir définitivement votre nouvelle conviction, priusfan et thierryb, vous avez droit à ce relevé persuasif (cliquez pour mieux voir) :


et son détail


J'accumule le nombre de PID520, et je somme les valeurs des 3 autres PID.

J'en profite pour signaler que le PID 526 méconnu est rare mais précis : 0.8 t/min près deux fois par seconde. Vass et XGauge se trompent sur sa nature.
 
Dernière édition:
Bonjour everyone!

Est-ce une coïncidence mais un 2009Prius se présente à l'instant comme nouvel inscrit ?

Hello Planetaire nice to "see" you here.

yes this is a "coincidence", in fact he has a direct access to this section.

welcome to 2009Prius,

he knows somebody able to build nice hardware, and I hope this guy will show up here, so we could make a nice interface....

Thank you priusfan for inviting me to this forum. Sorry I don't know French and have to use English. This is really exciting opportunity for me to learn about this new device. I have been struggling with the STN based OBDLink devices locking up randomly. The original OBDLink, the SX and the MX all have the same problem. I hope with this new device I can finally get rid of the lockup problem. I will go contact the hardware guru now.

To be fair to OBDLink it does do its job most of the time. ATMA mode works flawlessly and I am getting similar number of frames per second as listed above: for 030 (brake) I get 164.01 fps, for 039 (ICE T & torque) I get 121.67 fps. The problem happens when I use it to do queries. It's random and rare but frequent enough to be annoying.
 
Welcome, 2009Prius.
That is a nice surprise.
The priidash guru himself :-D
Now, I only goes on Priuschat in order to talk about plug-in. The 2004-2009 Prius is also an EV car.

You can of course use english here. :jap:
 
To be fair to OBDLink it does do its job most of the time. ATMA mode works flawlessly and I am getting similar number of frames per second as listed above: for 030 (brake) I get 164.01 fps, for 039 (ICE T & torque) I get 121.67 fps. The problem happens when I use it to do queries. It's random and rare but frequent enough to be annoying.

Hello 2009Prius,
Je suis d'accord avec toi (I agree with you), l'OBDLink en mode ATMA est parfait. J'ai probablement moins d'une erreur toutes les 10 heures !

Les PID sont tous parfaitement cadencés. Mais étrangement pas le 030 ! J'obtiens entre 161.3 et 165.6 fps.

Le PID 039 est parfaitement cadencé : 122.11 fps sur ma Prius.

Je ne suis pas d'accord avec toi, le PID 039 ne correspond pas au couple (that's not the torque). Je suppose que c'est le VVTi. Le couple est donné par le PID 348.
 
@Prius2009

Very happy and honored to see you here :jap:

I need your help:
I am a total Noob with C / C++

After a short discussion with thierryb, we agreed it would be interesting to use external files for filters & requests (instead of hard coding).

using mbed, it is possible to access to /local/ as long we respect 8.3 naming.
so could you help us to for writing the code to access & use efficiently "/local/filters.txt" and "/local/request.txt"
filters.txt would contain something like:
Code:
0x0025
0x0030
0x0038
0x0039
0x003A
0x0230
0x0244
0x0348
0x03C8
0x03CB
0x03CF
0x0520
0x0526
0x0540
0x05A4
and requests could contain something like:
Code:
0x7E0, 0x21, 0x01,  1, 0 ,
0x7E0, 0x21, 0x3C,  1, 0 ,
0x7E0, 0x21, 0x49,  1, 0 ,
0x7E2, 0x21, 0x61,  1, 0 ,
0x7E2, 0x21, 0x62,  1, 0 ,
0x7E2, 0x21, 0x67,  1, 0 ,
0x7E2, 0x21, 0x68,  1, 0 ,
0x7E2, 0x21, 0x74,  1, 0,
0x7E2, 0x21, 0x8A,  1, 0 ,
0x7E0, 0x01, 0x3C,  100, 0 ,
0x7E0, 0x01, 0x3E,  100, 0 ,
0x7E2, 0x21, 0x01,  100, 0,
0x7E2, 0x21, 0x70,  100, 0,
0x7E2, 0x21, 0x71,  100, 0,
0x7E2, 0x21, 0x87,  100, 0,
0x7E2, 0x21, 0x98,  100, 0,
the idea is to prepare externally the parm files, so the program, in the init sequence (in the program I sent you) would:
a) install the fillters.
d) store in the the struct array the requests sequence.
 
Thank you everyone for the warm welcome!

I don't remember where I got the info about ICE torque at 039 from. Maybe Planetaire? He helped me on many PIDs.

Wow priusfan you are putting me to work already!? 😎 I am not that good at C/C++, just an amateur, but I will start working on it. I have to first study your code in more detail. Please give me a few days. Thanks!
 
Thank you everyone for the warm welcome!

I don't remember where I got the info about ICE torque at 039 from. Maybe Planetaire? He helped me on many PIDs....

Probably yes, I don't remember exactly.
But last year Kinetik discovered on the pid 348 a better value.
Both looks like but not at low rpm, not when engine is cold...

Did you remember that you need also the odometer value ?
And kinetik found it too.

And back to mbed
 
Welcome, 2009Prius.
That is a nice surprise.
The priidash guru himself :-D
....
Hello everyone. :coucou:

Before I understood the meaning I thought "priidash" was an Hindi or Sanskrit word... priidash guru sounds as natural as "fromage d'Auvergne" !

Just hanging around, of course I don't understand much of your foreign language... :wink:

Keep on your brilliant research, friends !
 
OMG ! How is it possible today that somebody on earth don't know what is Priidash ! :horreur: (tm)

(ndt, using french paradox language): Oh mon dieu. Comment est-il possible aujourd'hui que quelqu'un ici sur terre ne connaisse pas Priidash ?
 
Probably yes, I don't remember exactly.
But last year Kinetik discovered on the pid 348 a better value.
Both looks like but not at low rpm, not when engine is cold...

Did you remember that you need also the odometer value ?
And kinetik found it too.

And back to mbed

Thank you planetaire for the links and thank you Kinetik for the great work!

I just checked the log from my US model 2009 Prius and was surprised to find the odometer value in miles, not km.
 
Thank you planetaire for the links and thank you Kinetik for the great work!

I just checked the log from my US model 2009 Prius and was surprised to find the odometer value in miles, not km.

Très intéressant mais pas surprenant : en conclusion le PID 53F transmet toutes les dix secondes la valeur légale de l'odomètre. Des kilomètres ou des miles, selon le pays.

Thank 2009Prius
 
mbed + BT

bonjour,
je viens de brancher le module DentBleue (BlueTooth) sur ma maquette.

je l'ai paramétré à 115200bps et testé avec mon tel android.

:shock::-D :-D cela marche parfaitement avec un programme de test.

je pourrai valider le bon fonctionnement avec la watture demain (mon épouse monopolise la watture aujourd'hui)...

ci-dessous photo de la maquette


14f7ffb8a86166.jpg
 
je pourrai valider le bon fonctionnement avec la watture demain (mon épouse monopolise la watture aujourd'hui)...
Pas le choix, faut que tu lui achètes une autre watture. Une vrai. La plug-in (mieux adaptée à son usage) :-D

Sinon, je dis des conneries car j'ai rien de plus intelligent à apporter au sujet. Mais vous m'impressionnez les mecs !!! :jap:
 
J'ai hâte d'en avoir un comme ça ... I can't wait to have one like that !
 
Et moi donc !
Et ma voiture est à ta disposition pour d'autres tests.
 
@Prius2009

Very happy and honored to see you here :jap:

I need your help:
I am a total Noob with C / C++

After a short discussion with thierryb, we agreed it would be interesting to use external files for filters & requests (instead of hard coding).

using mbed, it is possible to access to /local/ as long we respect 8.3 naming.
so could you help us to for writing the code to access & use efficiently "/local/filters.txt" and "/local/request.txt"
filters.txt would contain something like:
Code:
0x0025
0x0030
0x0038
0x0039
0x003A
0x0230
0x0244
0x0348
0x03C8
0x03CB
0x03CF
0x0520
0x0526
0x0540
0x05A4
and requests could contain something like:
Code:
0x7E0, 0x21, 0x01,  1, 0 ,
0x7E0, 0x21, 0x3C,  1, 0 ,
0x7E0, 0x21, 0x49,  1, 0 ,
0x7E2, 0x21, 0x61,  1, 0 ,
0x7E2, 0x21, 0x62,  1, 0 ,
0x7E2, 0x21, 0x67,  1, 0 ,
0x7E2, 0x21, 0x68,  1, 0 ,
0x7E2, 0x21, 0x74,  1, 0,
0x7E2, 0x21, 0x8A,  1, 0 ,
0x7E0, 0x01, 0x3C,  100, 0 ,
0x7E0, 0x01, 0x3E,  100, 0 ,
0x7E2, 0x21, 0x01,  100, 0,
0x7E2, 0x21, 0x70,  100, 0,
0x7E2, 0x21, 0x71,  100, 0,
0x7E2, 0x21, 0x87,  100, 0,
0x7E2, 0x21, 0x98,  100, 0,
the idea is to prepare externally the parm files, so the program, in the init sequence (in the program I sent you) would:
a) install the fillters.
d) store in the the struct array the requests sequence.

OK I have the first iteration of the code done. I think I will report in a few separate posts below so each post won't be too long.
 
filter code

I only have main.cpp and common.h in the test project. Here is the beginning of the main.cpp which defines a function to install the filters. I don't have the actual CAN function for installing the filter yet so the code just print to the screen. Please just replace that line with the CAN function.

Code:
/* 
 * File:   main.cpp
 * Author: teamprii
 *
 * Created on April 7, 2012, 10:53 PM
 */

//#include <cstdlib>
//#include <cstdio>
#include <iostream>
#include <fstream>
#include <vector>
//#include <string>
#include <sstream>
#include "common.h"
using namespace std;
/*
 * 
 */

int install_filters(){
    const int maxlinelen=128; // max line length in filters.txt file; 128 should be plenty for things like "0B4 // comment for 0B4 ....... " etc.
    char str[maxlinelen];
    int filter;
    ifstream infile("/local/filters.txt"); // hard coded pathname for filter specification file
    if (infile.is_open()){
        while(infile.good()){
            infile.getline(str,maxlinelen);
            if (str[0]=='/' && str[1]=='/'){
                cout<<str<<", skip commented line."<<endl; // skip commented line
            } else {
                sscanf(str,"%x",&filter);
                cout<<str<<", install filter "<<hex<<filter<<endl; // to be replaced with CAN2_wrFilter(hex);
            }
        }
        infile.close();
        return 0;
    } else {
        cout<<"Unable to open filter spec file";
        return -1;
    }
}
The filter file (just for testing) looks like this:

Code:
// max line length 128
025 // comments can be added to note what this filter (025) is for
030
038
039
// 03A // comment out this line so this filter (03A) will not be installed
230
244
348
3C8
3CB
3CF
520
526
540
5A4

I removed "0x0" in front of each line for simplicity.
 
request code

The request is a bit more complicated and I made a few changes. I decided to keep the number of code bytes flexible. So instead of "cod1" and "cod2" I made it a vector "code". Also instead of struct I made it a class to initialize the "fcnt" to zero so it doesn't have to be stored in the file. The common.h now looks like this:

Code:
/* 
 * File:   common.h
 * Author: teamprii
 *
 * Created on April 8, 2012, 6:49 PM
 */

#ifndef COMMON_H
#define    COMMON_H

#include <vector>
using namespace std;

class reqTbl{
public:
    int id;   // PID
    int freq; // request frequency
    int fcnt; // frequency counter
    vector<int> code; // list of code; change from cod1, cod2 to a vector code and move to end of line in file for easier read
    reqTbl();
};

reqTbl::reqTbl(){
    fcnt = 0; // initialize frequency counter to 0
}

extern vector<reqTbl> reqTable;
extern int    reqNumTbl; // this will be just (int)reqTable.size()

#endif    /* COMMON_H */

The request file for testing:
Code:
// need a space after the last code, max line length 256
7E2 1 21 74 // add comments here
7E2 3 21 8A 
//7E0 50 01 3C 3D // comment out unwanted request
7E0 50 01 3C 3D 
7E0 100 01 3E
Note the need of a space at the end of each line to make the code work correctly.

In the main.cpp file I have the code to read in the request file:

vector<reqTbl> reqTable;
int reqNumTbl;

int read_reqTable(vector<reqTbl>& reqtable, int& reqnumtbl){
const int maxlinelen=256; // max line length in request.txt file; 256 should be plenty.
char str[maxlinelen];
int id; // PID
int freq; // request frequency
int codej; // to store read code temporarily
reqTbl tmp;
ifstream infile("/local/request.txt"); // hard coded pathname for request specification file
if (infile.is_open()){
while(infile.good()){
infile.getline(str,maxlinelen);
if (str[0]=='/' && str[1]=='/'){
cout<<str<<", skip commented line."<<endl; // skip commented line
} else {
cout<<str<<", add this request to reqTable."<<endl; // add request to reqTable
stringstream ss;
ss<<str;
ss>>hex>>id>>freq;
tmp.id=id;
tmp.freq=freq;
vector<int> code; // list of code
do{
ss>>hex>>codej;
if (ss.good()){
code.push_back(codej);
}
} while (ss.good());
tmp.code=code;
cout<<"PID="<<tmp.id<<", freq="<<tmp.freq<<", code=";
for (int j=0; j<(int)tmp.code.size(); j++){
cout<<" "<<tmp.code[j]<<", ";
}
cout<<endl;
reqtable.push_back(tmp);
}
}
reqnumtbl=reqtable.size();
infile.close();
return 0;
} else {
cout<<"Unable to open request spec file";
return -2;
}
}

Note the reqTable is now also a vector, though we can access the list of requests in the table the same way as with an array.
 
test code

Finally I test the code using the main() function in the main.cpp file:

Code:
int main(int argc, char** argv) {
    
    cout<<"test\n";
    int filterresult = install_filters();
    int reqtblresult = read_reqTable(reqTable, reqNumTbl);
    cout<<"number of queries="<<reqNumTbl<<":"<<endl;
    for (int j=0; j<reqNumTbl; j++){
        cout<<j<<":"<<reqTable[j].id<<","<<reqTable[j].freq<<","<<reqTable[j].fcnt;
        for (int k=0; k<reqTable[j].code.size(); k++){
            cout<<","<<reqTable[j].code[k];
        }
        cout<<endl;
    }

    return (filterresult+reqtblresult);
}

Everything seems to be working and the output looks like this:

Code:
test
// max line length 128, skip commented line.
025 // comments can be added to note what this filter (025) is for, install filter 25
030, install filter 30
038, install filter 38
039, install filter 39
// 03A // comment out this line so this filter (03A) will not be installed, skip commented line.
230, install filter 230
244, install filter 244
348, install filter 348
3C8, install filter 3c8
3CB, install filter 3cb
3CF, install filter 3cf
520, install filter 520
526, install filter 526
540, install filter 540
5A4, install filter 5a4
// need a space after the last code, max line length 256, skip commented line.
7E2 1 21 74 // add comments here, add this request to reqTable.
PID=7e2, freq=1, code= 21,  74, 
7E2 3 21 8A , add this request to reqTable.
PID=7e2, freq=3, code= 21,  8a, 
//7E0 50 01 3C 3D // comment out unwanted request, skip commented line.
7E0 50 01 3C 3D , add this request to reqTable.
PID=7e0, freq=50, code= 1,  3c,  3d, 
7E0 100 01 3E , add this request to reqTable.
PID=7e0, freq=100, code= 1,  3e, 
number of queries=4:
0:7e2,1,0,21,74
1:7e2,3,0,21,8a
2:7e0,50,0,1,3c,3d
3:7e0,100,0,1,3e

Please give it a try and let me know if there are any problems. Thanks!
 
@2009Prius, I think you are a liar : you are not exactly an amateur :grin:

I will start testing now, with filters.


@everyboby
On my side, I played with:

  1. a program on mbed just for recording: no filters but management of multiframes
  2. a dev for analysing the log made by the previous
I tested on my gen3, it works well.

I met a problem with the BT interface (bluetoothbee & Uartsbee): it was working nicely @115kbps,
but since I tried 230k, it doesnot work any more.
it is no dead: I communicate thru the USB port, but as the doc is almost inexistent and the support forum is in bad chinglish I am just guessing how to find a solution.
I have some ideas to solve this:
a) use the usb port instead of uart
b) replace uartsbee by a standard support.


When using BT, because of speed limits, it is necessary bo be efficient and for instance avoid sending 100 times/sec the same passive frame.
Think about it and come back with suggestions....
 
external filters & requests

:champ::-D :lol: :-D It works perfectly......

congratulations to 2009Prius :jap::jap::jap:

I had to add a protection in read_reqTable() to avoid troubles with empty lines; it is not elegant, but it works:
Code:
                stringstream ss;
                ss<<str;
                if (ss.str().length() > 10) {        // use only real lines
here is the source for the complete app:
http://priusfan.info/canmonitor/CAN_hsd_bt.zip
here is the content for filters.txt:
Code:
// max line length 128
0B4 // this frame will give the exact speed
1C4 // ICE RPM
245 
3D3 
498 
4A6 
7E0 
7E2 
7E8 
7EA
and the content for request.txt
Code:
// need a space after the last code, max line length 256
// 1 pos is ECU , second is freq (careful :hex) and FULL Message
7E0 1 02 21 01 00 00 00 00 00 
7E0 1 02 21 3C 00 00 00 00 00 
7E0 1 02 21 49 00 00 00 00 00 
7E2 1 02 21 61 00 00 00 00 00 
7E2 1 02 21 62 00 00 00 00 00 
7E2 1 02 21 67 00 00 00 00 00 
7E2 1 02 21 68 00 00 00 00 00 
7E2 1 02 21 74 00 00 00 00 00 
7E2 1 02 21 8A 00 00 00 00 00 
7E0 100 03 01 3C 3E 00 00 00 00 // freq = 256 , combined request
7E2 84 02 21 01 00 00 00 00 00 // freq = 132 dec
7E2 84 02 21 70 00 00 00 00 00  
7E2 84 02 21 71 00 00 00 00 00  
7E2 84 02 21 87 00 00 00 00 00  

7E2 84 02 21 98 00 00 00 00 00
So the program can be used for gen2 or gen3, we just adapt the parm files for filters & requests...
 
glad to know, thanks to both of you

priusfan, you should probably put in a parameter file the communication speed.
 
Pages vues depuis le 20 Oct 2005: 316,289,043
Retour
Haut Bas