I’m working with an Ardupilot Mega (described as an arduino mega compatible UAV controller) and I’m having trouble getting it to print data to the serial port in a readable manner. I uploaded the accompanying Ardupilot Mega code and it appeared to just print out gibberish so I tried the following the test program, that was designed to mimic the manner in which the APM code sends data in that it has to populate a message buffer with sensor readings and send them out:
byte mess_buffer[2];
void setup(){
Serial.begin(115200);
# define SendSer Serial.print
mess_buffer[0] = 0x01;
mess_buffer[1] = 0x02;
}
void loop() {
if (true){
SendSer("4D");
for (int i = 0; i < 2; i++){
SendSer(mess_buffer[i]);
}
SendSer("testing\n");
delay(3000);
}
}
basically this code should print 4D12testing to the serial port every 3 seconds, but the output actually looks like this in the arduino IDE serial read window:
(it won’t let me post images in my first post, I’ll reply to this post with the pictures)
and if I copy/paste it into something like gedit, you see that those two unrecognizable blocks are actually little 2x2 matrices that are populated by zeros except for in the lower right where my desired number appears:
(see my reply)
I’ve tried different serial methods (write, send, and not assigning the methods to SendSer), different baud rates, and different ways of populating mess_buffer (mess_buffer[0]= 0x01 | 0x01 & 0xff | declaring ‘byte tmp0 = 1’, and assigning to that). I have also reproduced the mini-matrix output on two linux machines: the arduino IDE on one, and using pyserial tools on both.
So, my question is: what’s going on here? Is this normal, do I just need some python or C code that I can use to make it readable? Am I not configuring my serial connection correctly? Any help would be greatly appreciated.
thanks,
robert