Concatenate 2 doubles in Serial output for Arduino
1 次查看(过去 30 天)
显示 更早的评论
I want to concatenate 2 doubles in Serial driver for Arduino, which I created using : http://www.mathworks.com/matlabcentral/fileexchange/39354-device-drivers
The reason is that I want to reduce the time taken by using multiple serial.print commands, and use only one serial.print for all the writing. I used this link as reference: http://letsmakerobots.com/content/arduino-fix-serialprint-used-diagnose-can-adversely-affect-timing
I have been unable to concatenate properly. This is what I want to do.
if true
outData = "";
outData += " Bot_no: "; outData += out_botnumber[0];
outData += " Waypt: "; outData += out_current_waypt[0];
outData += " Dist2Waypt: "; outData += out_dist_2_waypt[0];
Serial1.println(outData);
end
I get the following error:
if true
In file included from ./sfunc_separate_9dof_wrapper.cpp:17:
C:/MATLAB/SupportPackages/R2014b/arduino-1.0.5/hardware/arduino/cores/arduino/Arduino.h:28:1: warning: this is the location of the previous definition
./sfunc_separate_9dof_wrapper.cpp: In function 'void sfunc_separate_9dof_Update_wrapper(const real_T*, const real_T*, const real_T*, const real_T*, const real_T*, const real_T*, const real_T*, const real_T*, const real_T*, const real_T*, const real_T*, const real_T*, const real_T*, const real_T*, const real_T*, const real_T*, real_T*)':
./sfunc_separate_9dof_wrapper.cpp:247: warning: only initialized variables can be placed into program memory area
./sfunc_separate_9dof_wrapper.cpp:263: warning: only initialized variables can be placed into program memory area
cc1plus.exe: warning: command line option "-Wstrict-prototypes" is valid for Ada/C/ObjC but not for C++
cc1plus.exe: warning: command line option "-std=gnu99" is valid for C/ObjC but not for C++
./sfunc_separate_GPS_V2_wrapper.cpp: In function 'void sfunc_separate_GPS_V2_Update_wrapper(const real_T*, const real_T*, const real_T*, const real_T*, const real_T*, const real_T*, const real_T*, real_T*)':
./sfunc_separate_GPS_V2_wrapper.cpp:237: warning: only initialized variables can be placed into program memory area
cc1plus.exe: warning: command line option "-Wstrict-prototypes" is valid for Ada/C/ObjC but not for C++
cc1plus.exe: warning: command line option "-std=gnu99" is valid for C/ObjC but not for C++
./sfunc_separate_serial_out_wrapper.cpp:20: error: 'long' or 'short' specified with char for 'bufSerialOut'
./sfunc_separate_serial_out_wrapper.cpp: In function 'void sfunc_separate_serial_out_Outputs_wrapper(const real_T*, const real_T*, const real_T*, const real_T*, const real_T*, const real_T*, const real_T*, const real_T*, const real_T*, const real_T*, const real_T*, const real_T*, const real_T*, const real_T*, const real_T*)':
./sfunc_separate_serial_out_wrapper.cpp:59: error: ambiguous overload for 'operator+=' in 'outData += * out_botnumber'
C:/MATLAB/SupportPackages/R2014b/arduino-1.0.5/hardware/arduino/cores/arduino/WString.h:108: note: candidates are: String& String::operator+=(char)
C:/MATLAB/SupportPackages/R2014b/arduino-1.0.5/hardware/arduino/cores/arduino/WString.h:109: note: String& String::operator+=(unsigned char)
C:/MATLAB/SupportPackages/R2014b/arduino-1.0.5/hardware/arduino/cores/arduino/WString.h:110: note: String& String::operator+=(int)
C:/MATLAB/SupportPackages/R2014b/arduino-1.0.5/hardware/arduino/cores/arduino/WString.h:111: note: String& String::operator+=(unsigned int)
C:/MATLAB/SupportPackages/R2014b/arduino-1.0.5/hardware/arduino/cores/arduino/WString.h:112: note: String& String::operator+=(long int)
C:/MATLAB/SupportPackages/R2014b/arduino-1.0.5/hardware/arduino/cores/arduino/WString.h:113: note: String& String::operator+=(long unsigned int)
./sfunc_separate_serial_out_wrapper.cpp:60: error: ambiguous overload for 'operator+=' in 'outData += * out_current_waypt'
C:/MATLAB/SupportPackages/R2014b/arduino-1.0.5/hardware/arduino/cores/arduino/WString.h:108: note: candidates are: String& String::operator+=(char)
C:/MATLAB/SupportPackages/R2014b/arduino-1.0.5/hardware/arduino/cores/arduino/WString.h:109: note: String& String::operator+=(unsigned char)
C:/MATLAB/SupportPackages/R2014b/arduino-1.0.5/hardware/arduino/cores/arduino/WString.h:110: note: String& String::operator+=(int)
C:/MATLAB/SupportPackages/R2014b/arduino-1.0.5/hardware/arduino/cores/arduino/WString.h:111: note: String& String::operator+=(unsigned int)
C:/MATLAB/SupportPackages/R2014b/arduino-1.0.5/hardware/arduino/cores/arduino/WString.h:112: note: String& String::operator+=(long int)
C:/MATLAB/SupportPackages/R2014b/arduino-1.0.5/hardware/arduino/cores/arduino/WString.h:113: note: String& String::operator+=(long unsigned int)
./sfunc_separate_serial_out_wrapper.cpp:61: error: ambiguous overload for 'operator+=' in 'outData += * out_dist_2_waypt'
C:/MATLAB/SupportPackages/R2014b/arduino-1.0.5/hardware/arduino/cores/arduino/WString.h:108: note: candidates are: String& String::operator+=(char)
C:/MATLAB/SupportPackages/R2014b/arduino-1.0.5/hardware/arduino/cores/arduino/WString.h:109: note: String& String::operator+=(unsigned char)
C:/MATLAB/SupportPackages/R2014b/arduino-1.0.5/hardware/arduino/cores/arduino/WString.h:110: note: String& String::operator+=(int)
C:/MATLAB/SupportPackages/R2014b/arduino-1.0.5/hardware/arduino/cores/arduino/WString.h:111: note: String& String::operator+=(unsigned int)
C:/MATLAB/SupportPackages/R2014b/arduino-1.0.5/hardware/arduino/cores/arduino/WString.h:112: note: String& String::operator+=(long int)
C:/MATLAB/SupportPackages/R2014b/arduino-1.0.5/hardware/arduino/cores/arduino/WString.h:113: note: String& String::operator+=(long unsigned int)
./sfunc_separate_serial_out_wrapper.cpp: In function 'void sfunc_separate_serial_out_Update_wrapper(const real_T*, const real_T*, const real_T*, const real_T*, const real_T*, const real_T*, const real_T*, const real_T*, const real_T*, const real_T*, const real_T*, const real_T*, const real_T*, const real_T*, real_T*)':
./sfunc_separate_serial_out_wrapper.cpp:158: warning: only initialized variables can be placed into program memory area
make: *** [HardwareSerial.o] Error 1
end
Can anyone please show me how to concatenate the two doubles as a single string in the device driver. I have attached my S-function driver block along with question.
0 个评论
回答(1 个)
Sreeram Mohan
2015-4-24
Hi Abhishek,
Just some high level thoughts by just looking at the build logs !
Before this could you please check if the string library is added rightly to the build while you are trying to build ?
Looks like from the error is telling me that something is wrong with the way you are using the string library:
String& String::operator+=(long unsigned int) ./sfunc_separate_serial_out_wrapper.cpp:61: error: ambiguous overload for 'operator+=' in 'outData += * out_dist_2_waypt' C:/MATLAB/SupportPackages/R2014b/arduino-1.0.5/hardware/arduino/cores/arduino/WString.h:108: note: candidates are: String& String::operator+=(char)
Or look at if you have missed to extern the methods on the string class !
Thanks, Sreeram Mohan
0 个评论
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Debugging and Analysis 的更多信息
产品
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!