Hi everybody,
I need some help concerning a conflict between librairies. I work on an Arduino Uno R3.
Currently, my project consists on receiving data from a sensor, and control a motor with a Roboclaw 2x5A.
My main code with the control of the motor works great, using the BMSerial.h library.
Nevertheless, I need to integrate another code, which asks my sensor with the command “MSV?\r\n” to receive the data. This code worked great with the SoftwareSerial.h library but now, it’s not possible to send the command “MSV?\r\n”. And I need to make it works with BMSerial to include it in my main code.
My code with SoftwareSerial is :
[code]#include <SoftwareSerial.h>
String chaine1;
String test;
int data;
int i = 0;
SoftwareSerial Poids(7, 6); // RX, TX
void setup()
{
Poids.begin(38400);
Serial.begin(38400);
Serial.println(“Test AD104C - Initialisation”);
delay(5);
}
int HBM()
{ chaine1 = “”;
test = “”;
data = 0;
Poids.write("MSV?\r\n");
while (Poids.available() == 0) {} // bloque si pas de DATA / 0 = NULL
while (Poids.available() != 0) // on rentre dans la boucle si on a des DATA (10 = LF et 13 = CR)
{
data = Poids.read();
chaine1 += data;
}
test = chaine1.substring(16, 20); // on repere les erreurs rencontrées
if (test.equals(“1310”)) // taille trame conforme = on affiche pas si
{ chaine1 = chaine1.substring(0, 20); // on enleve les CR LF de fin de trame
int poids = 0;
poids = 1000000 * ((chaine1.substring(2, 4)).toInt() - 48) + 100000 * ((chaine1.substring(4, 6)).toInt() - 48) + 10000 * ((chaine1.substring(6, 8)).toInt() - 48) + 1000 * ((chaine1.substring(8, 10)).toInt() - 48) + 100 * ((chaine1.substring(10, 12)).toInt() - 48) + 10 * ((chaine1.substring(12, 14)).toInt() - 48) + 1 * ((chaine1.substring(14, 16)).toInt() - 48);
return poids;
}
}
void loop()
{
Serial.println(HBM());
}[/code]
My error is :
[code]
final_AD104C.ino: In function ‘float HBM()’:
final_AD104C:24: error: invalid conversion from ‘const char*’ to ‘uint8_t {aka unsigned char}’ [-fpermissive]
In file included from final_AD104C.ino:1:0:
/Users/coste/Documents/Arduino/libraries/BMSerial/BMSerial.h:110:17: error: initializing argument 1 of ‘virtual size_t BMSerial::write(uint8_t)’ [-fpermissive]
virtual size_t write(uint8_t byte);
^
invalid conversion from ‘const char*’ to ‘uint8_t {aka unsigned char}’ [-fpermissive][/code]
Thank you in advance for your help