Combining teensies with the Arduino Yun

First try USB-Bridge between teensy 3.1 and RPi (jessie)

I found some time to play: I installed the newest Bridge on my Arduino IDE 1.0.6, installed the bridgeclient on the RPi (running jessie) as described on github. I also connected a FTDI-cable to have at least some output from the teensy over Serial1 and connected the teensy 3.1 and the RPi using a standard USB cable. When running the following sketch
Code:
/*
  Running process using Process class.

 This sketch demonstrate how to run linux processes
 using a Teensy3.1 and a Raspberry Pi B (jessie) - much alike the setup an an Arduino Yún, but more powerful.

 created 5 Jun 2013
 by Cristian Maglie
 modified by Daniel Süsstrunk using a
 modified Bridge by Paul Stoffregen

 This example code is in the public domain.

 http://arduino.cc/en/Tutorial/Process

 */

#include <Process.h>

void setup() {
  Serial1.begin(57600);

  delay(3000);
  Serial1.println("Trying to start bridge...");

  // Initialize Bridge
  Bridge.begin(Serial);

  Serial1.println("Started up bridge.");
  // run various example processes
  runCurl();
  runCpuInfo();
}

void loop() {
  // Do nothing here.
}

void runCurl() {
  // Launch "curl" command and get Arduino ascii art logo from the network
  // curl is command line program for transferring data using different internet protocols
  Process p;		// Create a process and call it "p"
  p.begin("curl");	// Process that launch the "curl" command
  p.addParameter("http://arduino.cc/asciilogo.txt"); // Add the URL parameter to "curl"
  p.run();		// Run the process and wait for its termination

  // Print arduino logo over the Serial
  // A process output can be read with the stream methods
  while (p.available() > 0) {
    char c = p.read();
    Serial1.print(c);
  }
  // Ensure the last bit of data is sent.
  Serial1.flush();
}

void runCpuInfo() {
  // Launch "cat /proc/cpuinfo" command (shows info on Atheros CPU)
  // cat is a command line utility that shows the content of a file
  Process p;		// Create a process and call it "p"
  p.begin("cat");	// Process that launch the "cat" command
  p.addParameter("/proc/cpuinfo"); // Add the cpuifo file path as parameter to cut
  p.run();		// Run the process and wait for its termination

  // Print command output on the Serial.
  // A process output can be read with the stream methods
  while (p.available() > 0) {
    char c = p.read();
    Serial1.print(c);
  }
  // Ensure the last bit of data is sent.
  Serial1.flush();
}
the serial console says
Code:
Trying to start bridge...
but it never gets past this message.

On the RPi, when connecting the Teensy 3.1, /var/log/messages says
Code:
Dec  9 19:55:56 pi kernel: [   87.129442] usb 1-1.3: new full-speed USB device number 6 using dwc_otg
Dec  9 19:55:56 pi kernel: [   87.233030] usb 1-1.3: New USB device found, idVendor=16c0, idProduct=0483
Dec  9 19:55:56 pi kernel: [   87.233067] usb 1-1.3: New USB device strings: Mfr=1, Product=2, SerialNumber=3
Dec  9 19:55:56 pi kernel: [   87.233083] usb 1-1.3: Product: USB Serial
Dec  9 19:55:56 pi kernel: [   87.233097] usb 1-1.3: Manufacturer: Teensyduino
Dec  9 19:55:56 pi kernel: [   87.233110] usb 1-1.3: SerialNumber: 506980
Dec  9 19:55:56 pi kernel: [   87.242840] cdc_acm 1-1.3:1.0: This device cannot do calls on its own. It is not a modem.
Dec  9 19:55:56 pi kernel: [   87.242960] cdc_acm 1-1.3:1.0: ttyACM0: USB ACM device


And when running
Code:
ps aux | grep -i bridge
I get
Code:
root      2372  0.0  0.0   1844   224 ?        S    19:55   0:00 /bin/sh /usr/bin/run-bridge-udev

root@pi:/usr/bin# cat /tmp/env.txt gives
Code:
ID_BUS=usb
UDEV_LOG=3
DEVNAME=/dev/ttyACM0
ACTION=add
ID_VENDOR_FROM_DATABASE=Van Ooijen Technische Informatica
ID_SERIAL_SHORT=506980
SEQNUM=898
USEC_INITIALIZED=4299514133
ID_USB_DRIVER=cdc_acm
ID_TYPE=generic
MAJOR=166
MTP_NO_PROBE=1
DEVPATH=/devices/platform/bcm2708_usb/usb1/1-1/1-1.3/1-1.3:1.0/tty/ttyACM0
ID_MODEL_ENC=USB\x20Serial
ID_USB_INTERFACES=:020201:0a0000:
ID_MODEL=USB_Serial
DEVLINKS=/dev/serial/by-id/usb-Teensyduino_USB_Serial_506980-if00 /dev/serial/by-path/platform-bcm2708_usb-usb-0:1.3:1.0
ID_MM_DEVICE_IGNORE=1
ID_SERIAL=Teensyduino_USB_Serial_506980
SUBSYSTEM=tty
ID_MODEL_ID=0483
MINOR=0
ID_MODEL_FROM_DATABASE=Teensyduino Serial
ID_PATH=platform-bcm2708_usb-usb-0:1.3:1.0
ID_VENDOR_ENC=Teensyduino
ID_PATH_TAG=platform-bcm2708_usb-usb-0_1_3_1_0
ID_VENDOR=Teensyduino
PWD=/
ID_USB_INTERFACE_NUM=00
ID_VENDOR_ID=16c0
ID_REVISION=0100


Do you see anything I've missed doing?
 

Attachments

  • cpu.jpg
    cpu.jpg
    49.7 KB · Views: 184
Last edited:
Could there be something wrong with the code of /usr/bin/run-bridge-udev towards it's end:

When adding a write-out to:
Code:
DEV=${DEVNAME##*/}
echo DEV > /tmp/dev.txt

(while test -w $DEVNAME; do 
    /sbin/getty -8 -c -L -a root $baud $DEV
done) &

All it says in /tmp/dev.txt is «DEV». And then in the following line there is a reference to $DEV, which has not been used so far ... Shouldn't DEV be $DEV in the first of the referenced lines? However - if I try
Code:
$DEV=${DEVNAME##*/}
echo $DEV > /tmp/dev.txt

(while test -w $DEVNAME; do 
    /sbin/getty -8 -c -L -a root $baud $DEV
done) &

There is nothing at all in /tmp/dev.txt (I suspect ${DEVNAME##*/} to be faulty (please correct me if I'm wrong, it's just that I haven't seen the ##*/ syntax so far in shell scripts).

I can't connect to the bridge either.

And there is also no content of /tmp/dev.txt if I try
Code:
$DEV=${DEVNAME}
echo $DEV > /tmp/dev.txt

(while test -w $DEVNAME; do 
    /sbin/getty -8 -c -L -a root $baud $DEV
done) &
nor does the bridge connect.

Even if I try
Code:
(while test -w $DEVNAME; do 
    /sbin/getty -8 -c -L -a root $baud /dev/ttyACM0
done) &
nothing changes ...

Any ideas.
Have you had a running bridge with your code? Best regards, Dani
 
I tried

root@pi:~# /sbin/getty -8 -c -L -a root 9600 ttyACM0
and
root@pi:~# /sbin/getty -8 -c -L -a root 9600 /dev/ttyACM0

No difference on the teensy 3.1 side: Hanging at «Trying to start bridge».

Is there a way to output what's happening over Serial on the Serial1-Arduino-IDE-Serial-Monitor?
 
Last edited:
Listening to SerialUSB of teensy connected to RPi (with bridge) over USB.

I'm a step further. When I use the following script to see what happens at Serial (USB), I get the response below.
Script:
Code:
void setup() {
  // put your setup code here, to run once:
  Serial.begin(9600);
  Serial1.begin(57600);
  delay(3000);
  Serial1.println("Started...");
}

void loop() {
  static int count = 0;
  if (Serial.available()){
    Serial1.print(Serial.read(), HEX);
    Serial1.print(" ");
    if (count++ == 16){
      Serial1.println();
      count = 0;
    }
  }
}

Output:
Code:
Started...
D A 52 61 73 70 62 69 61 6E 20 47 4E 55 2F 4C 69 
6E 75 78 20 6A 65 73 73 69 65 2F 73 69 64 20 70 69 
20 74 74 79 41 43 4D 30 D A D A 70 69 20 6C 6F 
67 69 6E 3A 20 72 6F 6F 74 20 28 61 75 74 6F 6D 61 
74 69 63 20 6C 6F 67 69 6E 29 A D D A 4C 61 73 
74 20 6C 6F 67 69 6E 3A 20 54 68 75 20 44 65 63 20 
31 31 20 32 33 3A 33 31 3A 34 35 20 43 45 54 20 32 
30 31 34 20 6F 6E 20 74 74 79 41 43 4D 30 D A 4C 
69 6E 75 78 20 70 69 20 33 2E 31 32 2E 32 38 2B 20 
23 37 30 39 20 50 52 45 45 4D 50 54 20 4D 6F 6E 20 
53 65 70 20 38 20 31 35 3A 32 38 3A 30 30 20 42 53 
54 20 32 30 31 34 20 61 72 6D 76 36 6C D A D A 
54 68 65 20 70 72 6F 67 72 61 6D 73 20 69 6E 63 6C 
75 64 65 64 20 77 69 74 68 20 74 68 65 20 44 65 62 
69 61 6E 20 47 4E 55 2F 4C 69 6E 75 78 20 73 79 73 
74 65 6D 20 61 72 65 20 66 72 65 65 20 73 6F 66 74 
77 61 72 65 3B D A 74 68 65 20 65 78 61 63 74 20 
64 69 73 74 72 69 62 75 74 69 6F 6E 20 74 65 72 6D 
73 20 66 6F 72 20 65 61 63 68 20 70 72 6F 67 72 61 
6D 20 61 72 65 20 64 65 73 63 72 69 62 65 64 20 69 
6E 20 74 68 65 D A 69 6E 64 69 76 69 64 75 61 6C 
20 66 69 6C 65 73 20 69 6E 20 2F 75 73 72 2F 73 68 
61 72 65 2F 64 6F 63 2F 2A 2F 63 6F 70 79 72 69 67 
68 74 2E D A D A 44 65 62 69 61 6E 20 47 4E 55 
2F 4C 69 6E 75 78 20 63 6F 6D 65 73 20 77 69 74 68 
20 41 42 53 4F 4C 55 54 45 4C 59 20 4E 4F 20 57 41 
52 52 41 4E 54 59 2C 20 74 6F 20 74 68 65 20 65 78 
74 65 6E 74 D A 70 65 72 6D 69 74 74 65 64 20 62 
79 20 61 70 70 6C 69 63 61 62 6C 65 20 6C 61 77 2E 
D A 2D 62 61 73 68 3A 20 4B 61 6E 6E 20 64 69 65 
20 50 72 6F 7A 65 73 73 67 72 75 70 70 65 20 64 65 
73 20 54 65 72 6D 69 6E 61 6C 73 20 6E 69 63 68 74 
20 73 65 74 7A 65 6E 20 28 31 35 31 29 2E 3A 20 55 
6E 70 61 73 73 65 6E 64 65 72 20 49 4F 43 54 4C 20 
28 49 2F 4F 2D 43 6F 6E 74 72 6F 6C 29 20 66 C3 BC 
72 20 64 61 73 20 47 65 72 C3 A4 74 D A 2D 62 61 
73 68 3A 20 4B 65 69 6E 65 20 4A 6F 62 20 53 74 65 
75 65 72 75 6E 67 20 69 6E 20 64 69 65 73 65 72 20 
53 68 65 6C 6C 2E D A 72 6F 6F 74 40 70 69 3A 7E 
23 20

When I look at it in my hex editor, I get the following:
hex_response.jpg.

So it seems, as if the RPi has trouble, setting a few things:

(-bash: Kann die Prozessgruppe des Terminals nicht setzen (151).: Unpassender IOCTL (I/O-Control) für das Gerät
-bash: Keine Job Steuerung in dieser Shell.)

that means in english
(bash: cannot set terminal process group (151): Inappropriate ioctl for device
bash: no job control in this shell)

Does anyone know, what bash might mean by that?
 
Last edited:
Hi Paul! Have you, by any chance, had a moment to let the teensy 3.1 try to talk to your new raspberry pi? Best regards, Dani
 
Today, I connected the teensy 3.1 to a «real» debian (running an a laptop called ibm). Again connecting the devices over USB. The debian has Paul's Bridge running. This system however gave more information over syslog when connecting:
Code:
Dec 28 00:27:27 ibm kernel: [ 6510.824074] usb 3-1: new full-speed USB device number 5 using uhci_hcd
Dec 28 00:27:27 ibm kernel: [ 6511.206142] usb 3-1: New USB device found, idVendor=16c0, idProduct=0483
Dec 28 00:27:27 ibm kernel: [ 6511.206156] usb 3-1: New USB device strings: Mfr=1, Product=2, SerialNumber=3
Dec 28 00:27:27 ibm kernel: [ 6511.206166] usb 3-1: Product: USB Serial
Dec 28 00:27:27 ibm kernel: [ 6511.206174] usb 3-1: Manufacturer: Teensyduino
Dec 28 00:27:27 ibm kernel: [ 6511.206183] usb 3-1: SerialNumber: 506980
Dec 28 00:27:27 ibm kernel: [ 6511.210805] cdc_acm 3-1:1.0: This device cannot do calls on its own. It is not a modem.
Dec 28 00:27:27 ibm kernel: [ 6511.216641] cdc_acm 3-1:1.0: ttyACM0: USB ACM device
Dec 28 00:27:27 ibm mtp-probe: checking bus 3, device 5: "/sys/devices/pci0000:00/0000:00:1d.1/usb3/3-1"
Dec 28 00:27:27 ibm mtp-probe: bus: 3, device: 5 was not an MTP device
Dec 28 00:27:57 ibm systemd-udevd[22822]: worker [23892] /devices/pci0000:00/0000:00:1d.1/usb3/3-1/3-1:1.0/tty/ttyACM0 timeout; kill it
Dec 28 00:27:57 ibm systemd-udevd[22822]: seq 1446 '/devices/pci0000:00/0000:00:1d.1/usb3/3-1/3-1:1.0/tty/ttyACM0' killed
Dec 28 00:27:57 ibm systemd-udevd[22822]: worker [23892] terminated by signal 9 (Killed)
Dec 28 00:32:48 ibm kernel: [ 6831.576136] usb 3-1: USB disconnect, device number 5
Dec 28 00:32:48 ibm kernel: [ 6831.584084] cdc_acm 3-1:1.0: failed to set dtr/rts

Listening (using a FTDI-Cable on teensy's Serial1-port) to what the teensy 3.1 gets, I read (as before):
Code:
Debian GNU/Linux 8 ibm ttyACM0

ibm login: root (automatic login)


Last login: Sat Dec 27 23:10:45 CET 2014 on tty2
Linux ibm 3.16-3-486 #1 Debian 3.16.5-1 (2014-10-10) i686

The programs included with the Debian GNU/Linux system are free software;
the exact distribution terms for each program are described in the
individual files in /usr/share/doc/*/copyright.

Debian GNU/Linux comes with ABSOLUTELY NO WARRANTY, to the extent
permitted by applicable law.
-bash: cannot set terminal process group (137): Inappropriate ioctl for device
-bash: no job control in this shell
root@ibm:~# ATE1 E0
ATE1 E0
ATE1 E0
~

Does anyone know what that MTP device problem might have to do with the teensy not being able to connect to ibm's bridge?
Regards, Dani
 
Last edited:
Connecting a Teensy 3.1 to an Arduino YUN using USB and the bridge

I tried to connect the teensy 3.1 over USB to an Arduino Yun. I thought that maybe that would make for a faster bridge than over UART. Therefore I replaced the original run-bridge with Paul's run-bridge from Github (https://github.com/PaulStoffregen/BridgeUSB).

When running the following script I get nothing but «Starting...» from the Serial1 connection of the teensy.
Code:
void setup() {
  // put your setup code here, to run once:
  Serial.begin(9600);
  Serial1.begin(57600);
  delay(3000);
  Serial1.println("Started...");
}

void loop() {
  static int count = 0;
  if (Serial.available()){
    Serial1.print(Serial.read(), HEX);
    Serial1.print(" ");
    if (count++ == 16){
      Serial1.println();
      count = 0; 
    }
  }
}
I installed udev and kmod-usb-acm (to get ACM-devices)
Code:
opkg update; opkg install udev
opkg update; opkg install kmod-usb-acm
and all of Paul's files (from Github, see above) as described in the readme.

When plugging in the teensy, it is recognized as /dev/ttyACM0 but it seems as if /usr/bin/run-bridge-udev isn't called and can I see nothing going on between the linino and the teensy as seen in the Serial1-monitor of the teensy.

Code:
# dmesg:
[   97.590000] usb 1-1.1: new full-speed USB device number 4 using ehci-platform
[   97.720000] usb 1-1.1: New USB device found, idVendor=16c0, idProduct=0483
[   97.720000] usb 1-1.1: New USB device strings: Mfr=1, Product=2, SerialNumber=3
[   97.720000] usb 1-1.1: Product: USB Serial
[   97.720000] usb 1-1.1: Manufacturer: Teensyduino
[   97.730000] usb 1-1.1: SerialNumber: 506980
[   97.730000] cdc_acm 1-1.1:1.0: This device cannot do calls on its own. It is not a modem.
[   97.740000] cdc_acm 1-1.1:1.0: ttyACM0: USB ACM device

udev however realizes something:
Code:
#udevadm monitor
KERNEL[358.095142] add      /devices/platform/ehci-platform/usb1/1-1/1-1.1 (usb)
KERNEL[358.110290] add      /devices/platform/ehci-platform/usb1/1-1/1-1.1/1-1.1:1.0 (usb)
KERNEL[358.111350] add      /devices/platform/ehci-platform/usb1/1-1/1-1.1/1-1.1:1.0/tty/ttyACM0 (tty)
KERNEL[358.112410] add      /devices/platform/ehci-platform/usb1/1-1/1-1.1/1-1.1:1.1 (usb)

I also installed agetty since there is no getty on openwrt
Code:
opkg update; opkg install agetty
and replaced getty with agetty in /usr/bin/run-bridge-udev.

Has anyone gotten further? Cheers, Dani
 
Last edited:
Nuage works quite well with a Raspberry Pi 3 and a teensy 3.1 using Serial1. Of course teensy 3.1 cannot be (re)programmed over Serial1. Would it maybe be possible to reprogram one of the newer Teensies (3.5/3.6) over serial, so that the combination of the two systems would be a real alternative to an Arduino Yun?
Thanks, Dani

nuage_setup_rpi3_teensy31_steckplatine.jpg
This code works well:
Code:
/*
  Yún HTTP Client

 This example for the YunShield/Yún shows how create a basic
 HTTP client that connects to the internet and downloads
 content. In this case, you'll connect to the Arduino
 website and download a version of the logo as ASCII text.

 created by Tom igoe
 May 2013
 modified by Daniel Süsstrunk, January 2017 using Paul Stoffregens Bridge, a Raspberry Pi 3 and a teensy 3.1 over Serial 1 as shown in the picture.

 This example code is in the public domain.

 http://www.arduino.cc/en/Tutorial/HttpClient

 */

#include <Bridge.h>
#include <HttpClient.h>

void setup() {
  // Bridge takes about two seconds to start up
  // it can be helpful to use the on-board LED
  // as an indicator for when it has initialized
  pinMode(13, OUTPUT);
  digitalWrite(13, HIGH);
  Serial.begin(57600);
  Serial.println("Hi");

  digitalWrite(13, LOW);
  
  Bridge.begin(Serial1, 19200);
  digitalWrite(13, HIGH);


}

void loop() {
  // Initialize the client library
  HttpClient client;

  // Make a HTTP request:
  client.get("https://www.arduino.cc/asciilogo.txt");

  // if there are incoming bytes available
  // from the server, read them and print them:
  while (client.available()) {
    static long long counter = 0;
    char c = client.read();
    Serial.print(c);
    if (counter++ % 30 == 0){
      digitalWrite(13,!digitalRead(13));
    }
  }
  Serial.flush();
  digitalWrite(13, HIGH);

  delay(5000);
}
 
Back
Top