When I flash this simple code (using Arduino-Makefile):
#include <avr/io.h>
#include <util/delay.h>
#include <Arduino.h>
void init_io(void) {
// open serial port
Serial.begin(9600);
while (!Serial);
Serial.println("Comm-link online");
}//END: init_io
int main(void) {
init_io();
while (1) {
// send data only when you receive data:
if (Serial.available() > 0) {
// read the incoming byte:
int incomingByte = Serial.read();
// say what you got:
Serial.print("I received: ");
Serial.println(incomingByte, DEC);
} else {
// Serial.println("No serial ");
}
}//END: loop
return 0;
}//END: main
I only see first two chars printed in the serial output:
~$> Co
The input also does not work as intended - tested on two independent microcontrolers, Mega and Uno. I'm not sure what's the cause of this behaviour. Here's the Makefile:
BOARD_TAG = uno # megaADK uno
MONITOR_PORT = /dev/ttyACM0
ARDUINO_LIBS =
include $(ARDMK_DIR)/Arduino.mk
It's definitely not a hardware problem, I've used serial i/o before in other projects.