console-bridge.ino
The Console library replaces Serial on the network side: from an ssh session on the board, the console command shows what the sketch prints and sends keystrokes back. Debugging without a USB cable, remotely.
Hardware
An Arduino Tian (Microchip SAM3X8E + TianOS Linux on an Atheros AR9344, dual USB, Ethernet and Wi-Fi). None; ssh access to the board (distribution root password).
Wiring
Nothing to wire. The board must be on the network to be reachable over ssh.
How it works
Console.begin() opens a channel to the bridge daemon; Console.available/read receive characters typed on the Linux side, println goes back. The physical link is the internal MCU↔SoC serial port.
Running it
Arduino IDE with the Arduino Tian board: upload over the « Native » USB port. Linux side: ssh root@arduino.local. The Bridge library is identical to the Yun's.
Variants
Expose the same commands over REST (YunServer) for dual console + HTTP access, or log to /tmp via Process.
console-bridge.ino
// Console sur le pont : taper des commandes depuis ssh/telnet.
#include <Bridge.h>
#include <Console.h>
int compteur = 0;
void setup() {
Bridge.begin();
Console.begin(); // console = port serie "reseau"
while (!Console); // attend qu'un client se branche
Console.println("Console pont prete : 'c' compte, 'x' reinitialise");
}
void loop() {
if (Console.available() > 0) {
char c = Console.read();
switch (c) {
case 'c':
compteur++;
Console.print("compteur = ");
Console.println(compteur);
break;
case 'x':
compteur = 0;
Console.println("reinitialise");
break;
default:
Console.print("inconnu: ");
Console.println(c);
}
}
// Cote Linux : la commande "console" (Yun) ou telnet localhost 5555 pour
// voir cette sortie sans ouvrir l'IDE.
delay(50);
}