Salut,
J'essaye de lire un fichier binaire créé à partir du morceau de code java (pour android) ci-dessous (il s'agit d'un accelerometer log):
J'ai trouvé ça:
Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34 ... private void open_files() throws FileNotFoundException { CSensorStates lSenStates=mSenStates; CLocProvStates lLPStates=mLPStates; DataOutputStream[] lfout=fout; //Open the files and register the listeners if (lSenStates.getNumAct()>0) { lfout[0]=new DataOutputStream(new BufferedOutputStream(new FileOutputStream(file_location("_sensors.bin")))); } else lfout[0]=null; } ... public void onSensorChanged(SensorEvent ev) { DataOutputStream file=fout[0]; long tim=System.currentTimeMillis(); int len=ev.values.length; try { file.writeInt(ev.sensor.getType()); file.writeLong(tim); file.writeLong(ev.timestamp); file.writeInt(len); for (int i=0;i<len;i++) file.writeFloat(ev.values[i]); } catch (IOException e) { e.printStackTrace(); } }
En utilisant Matlab, j'ai essayé :
Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5 writeInt (Writes the specified 32-bit int in big-endian order) : ev.sensor.getType() (value 1 for accelerometer) writeLong (Writes the specified 64-bit long in big-endian order) : tim (13 digits ~ 1309943772097) writeLong : timestamp (?) writeInt : len (3 ?) writeFloat (Writes the specified 32-bit float in big-endian order) : Ax, Ay, Az (i=3) (should be ~ +/- 0.1, ~ +/- 0.1, ~ - 9.81)
Ce qui donne ..
Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15 SO = fopen('sensors.bin','r', 'b', 'UTF-8'); SF = fread(SO, 1, 'ubit32=>int', 'b' ) % fread(fileID, sizeA, precision, skip, machineformat) fseek(SO, 3, 'bof'); % using fseek to try to find each 'split' of the raw data SF = fread(SO, 1, 'ubit64=>long', 'b' ) fseek(SO, 11, 'bof'); SF = fread(SO, 1, 'ubit64=>long', 'b' ) fseek(SO, 19, 'bof'); SF = fread(SO, 1, 'ubit32=>int', 'b' ) fseek(SO, 23, 'bof'); SF = fread(SO, 1, 'ubit32=>float', 'b' ) fseek(SO, 27, 'bof'); SF = fread(SO, 1, 'ubit32=>float', 'b' ) fseek(SO, 31, 'bof'); SF = fread(SO, 1, 'ubit32=>float', 'b' )
Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
10
11
12
13
14 SF = 1 SF = 2147483647 SF = 2147483647 SF = 2147483647 SF = 54288168 SF = 3.7789724e+009 SF = 3.9804677e+009
Ce qui est faux vu les valeurs attendues..
J'ai passé un temps monstre à essayer différentes combinaisons mais je reste bloqué..
Si quelqu'un a une idée ..
Partager