Hello world.
I wanna ask about how to convert arduino code possible for mbed compiler for arduino. first of all, I have tried to use this guy program knn arduino code..
this is the general code from him..
Fullscreen
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
#include "dataset.h"
#include "funcionesKNN.h"
#define FI 100 // filas de la base de datos
#define CO 4 // numero de caracteristicas
// variables
/*char* clasesSt[3]; // strings con las clases
char* nomAtr[CO]; // strings con los nombres de atributos
double atributos[FI][CO]; // atributos
int clasesNo[FI]; // clases
*/
double dato[CO]; // dato a clasificar
long actual = 0, previo = 0;
//-----------------------------------------------------------------------
// Extrae caracteres dados los identificadores y los convierte a double
//-----------------------------------------------------------------------
void extraeDatos(String str, double dato[], char dlm[]){
String auxstr = "";
in arduino looks like this one..
and then after that, I tried to code using mbed compiler like this one.
Fullscreen
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
#include "mbed.h"
#include "dataset.h"
#include "funcionesKNN.h"
#include <string>
Serial pc(USBTX, USBRX);
#define FI 100 // filas de la base de datos
#define CO 4 // numero de caracteristicas
// variables
/*char* clasesSt[3]; // strings con las clases
char* nomAtr[CO]; // strings con los nombres de atributos
double atributos[FI][CO]; // atributos
int clasesNo[FI]; // clases
*/
double dato[CO]; // dato a clasificar
long actual = 0, previo = 0;
//-----------------------------------------------------------------------
// Extrae caracteres dados los identificadores y los convierte a double
//-----------------------------------------------------------------------
void extraeDatos(string str, double dato[], char dlm[]){
but there's error message that show like this one..
Fullscreen
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
Error: Class "std::basic_string<char, std::char_traits<char>, std::allocator<char>>" has no member "indexOf" in "main.cpp", Line: 28, Col: 20
Error: Class "std::basic_string<char, std::char_traits<char>, std::allocator<char>>" has no member "indexOf" in "main.cpp", Line: 29, Col: 20
Error: Class "std::basic_string<char, std::char_traits<char>, std::allocator<char>>" has no member "indexOf" in "main.cpp", Line: 30, Col: 20
Error: Class "std::basic_string<char, std::char_traits<char>, std::allocator<char>>" has no member "indexOf" in "main.cpp", Line: 31, Col: 20
Error: Class "std::basic_string<char, std::char_traits<char>, std::allocator<char>>" has no member "indexOf" in "main.cpp", Line: 32, Col: 20
Error: Class "std::basic_string<char, std::char_traits<char>, std::allocator<char>>" has no member "toCharArray" in "main.cpp", Line: 43, Col: 13
Warning: Variable "tamstr" was declared but never referenced in "main.cpp", Line: 24, Col: 19
Warning: Conversion from pointer to smaller integer in "main.cpp", Line: 57, Col: 19
Warning: Conversion from pointer to smaller integer in "main.cpp", Line: 58, Col: 19
Warning: Conversion from pointer to smaller integer in "main.cpp", Line: 59, Col: 19
Warning: Conversion from pointer to smaller integer in "main.cpp", Line: 60, Col: 19
Warning: Conversion from pointer to smaller integer in "main.cpp", Line: 61, Col: 47
Error: Expected a declarator in condition declaration in "main.cpp", Line: 84, Col: 19
Error: Type name is not allowed in "main.cpp", Line: 88, Col: 27
and also from this library funcionesKNN.cpp, there was error too that show like this after I have change my code
Fullscreen
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
//#include <HardwareSerial.h> // solo para Debug
/*------------------------------------------
funciones para el computo del algoritmo KNN
--------------------------------------------*/
//#include "dataset.h"
#include "funcionesKNN.h"
#include <math.h>
/*----------------------------------------------
calculo de distancia euclidiana entre dos puntos
------------------------------------------------*/
double distanciaEuclidiana(double pt1[], double pt2[], int co){
int i;
double suma = 0;
for(i=0; i<co; i++){
suma = pow(pt1[i] - pt2[i], 2) + suma;
}
return sqrt(suma);
}
and error message show like this one..
Fullscreen
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
Error: Class "std::basic_string<char, std::char_traits<char>, std::allocator<char>>" has no member "indexOf" in "main.cpp", Line: 28, Col: 20
Error: Class "std::basic_string<char, std::char_traits<char>, std::allocator<char>>" has no member "indexOf" in "main.cpp", Line: 29, Col: 20
Error: Class "std::basic_string<char, std::char_traits<char>, std::allocator<char>>" has no member "indexOf" in "main.cpp", Line: 30, Col: 20
Error: Class "std::basic_string<char, std::char_traits<char>, std::allocator<char>>" has no member "indexOf" in "main.cpp", Line: 31, Col: 20
Error: Class "std::basic_string<char, std::char_traits<char>, std::allocator<char>>" has no member "indexOf" in "main.cpp", Line: 32, Col: 20
Error: Class "std::basic_string<char, std::char_traits<char>, std::allocator<char>>" has no member "toCharArray" in "main.cpp", Line: 43, Col: 13
Warning: Variable "tamstr" was declared but never referenced in "main.cpp", Line: 24, Col: 19
Warning: Conversion from pointer to smaller integer in "main.cpp", Line: 57, Col: 19
Warning: Conversion from pointer to smaller integer in "main.cpp", Line: 58, Col: 19
Warning: Conversion from pointer to smaller integer in "main.cpp", Line: 59, Col: 19
Warning: Conversion from pointer to smaller integer in "main.cpp", Line: 60, Col: 19
Warning: Conversion from pointer to smaller integer in "main.cpp", Line: 61, Col: 47
Error: Expected a declarator in condition declaration in "main.cpp", Line: 84, Col: 19
Error: Type name is not allowed in "main.cpp", Line: 88, Col: 27
here's my full code from mbed online compiler, KNN mbed
please how to solve this problem.. please to help me soon..
thanks..