I have a Channel
class which on instantiation receives a _type
via new Channel("type", ...)
. I can read the type back out via channelObject->getType()
which returns a string.
This has always worked fine until today. I have no idea what changed but if I Serial.print(channelObject->getType())
I get a nasty amount of garbage in the terminal:
���QQ���� 00@��������'����������������������(�����������b���������������������������������������H���E���������������������������������������������������������������uD��DESC initializedOoops, no LSM303 detected ... Check your wiring!Ooops, no BMP180 detected ... Check your wiring!Setting IMU ground: Setting front: !! set ground kalman initConnect Powerbooting up...SWATBOT SETUP COMPLETEtype_xelevatoraileronthrottlerudderaux1aux2serial in: DISARMED!E;1
B��LSM303(>.a+a+8L.�S2E/��BMP085.qL3GD20���T �4&�'�%�%�%&
naninfovf�!,�!H�!��!��!Њ!�D�s6/&������?)m((a&l1=#k2���_
X� +�����+����=� ��J�5�.d�6s'���z :����������-/�type_xtype_x elevatoraileron throttlerudderaux1aux2�F�OX4Vjx 7���2�?�xr����:~aileronaux1
�:~ elevator
~ throttle:):~rudder������=�@��>�̀?��=�=�@��>�����=�=�@��>�f�B��=�i�?�k��BMP085QF��D�C
�#<}D������D]v� ,B����^v�QF����P}D .?P���f�B.s�D2m .?�oIB��P��(=:@���A�A�@9�@ A@�@�?�A0SB0N�>dC9�@ A@�@�?�A ��A��dC��L?��L>s����C�B(��"� (� �"��
(�
"elevator", "aileron", "throttle", and "rudder" are types for objects that I know exist but why is it coming out like this? I'm also seeing other unrelated parts of my program being spit out too like "Ooops, no LSM303 detected ...". This is all so strange.
If I had to guess, there must be an awry pointer somewhere in my application but I'm having no luck finding it. Worst case I'll rollback my application and retrace my last implementations (a couple days worth of work).
Can anyone give me a clue as to what is going on here?
My broken application is online at: https://github.com/jacksonkr/SwatBotSpine/tree/master
Emphasis on Channel.h:68 which is where all the garbage is coming from.
Related code:
- RemoteControl.h:37
- RemoteControl::getChannel
1 Answer 1
You might be running out of RAM. I suggest you change all lines like this:
Serial.println("SWATBOT SETUP COMPLETE");
to use the F
macro like this:
Serial.println(F("SWATBOT SETUP COMPLETE"));
There seem to be a lot of places you could change.
Also I would not put code (implementation) into the .h files. That belongs in .cpp files. The .h files are for declarations.
Inside a class function, using this->
all the time just makes things look cluttered, eg.
StabilityController::StabilityController(RemoteControl* rc, ROSController* ros, IMUController *imu) {
this->_rc = rc;
this->_ros = ros;
this->_imu = imu;
-
The
F()
macro is a life saver and certainly thwarted these goofy lockups. I must have been lower on memory than I realized. Thanks for introducing me to this. Also, I usethis->
and other tactics to keep track (visually) of where my data is coming / going; everyone has their style.Jacksonkr– Jacksonkr2016年09月04日 13:50:57 +00:00Commented Sep 4, 2016 at 13:50