Viewing USB Serial on raspberry Pi

Good morning!

I want to build a Raspberry Pi - based logger to log data off a Teensy that is sent over USB Serial. However, I can't seem to open the Serial stream in terminal with any tools I have used for classic Arduino boards before (e.g. screen). The same was an issue on a Ubuntu machine, too.

Is Teensyduino needed to view a port on Linux machines? If not, what would be the correct way to write messages from the port to a terminal?

Thanks a lot in advance!
 
It will depend on how your code on the Teensy, in particular, what USB type you are building with. If it is Serial or one of the other ones with name like: Serial + <XYZ> then it is using standard Serial stream stuff.
If however you choose one of the other USB types it typically adds another stream called Serial Emulated (SEREMU) which only few pieces of code understand, like Arduino Serial monitor (after Teensyduino is installed), TyCommander, ....

Also if you look at the download and install page: https://www.pjrc.com/teensy/td_download.html
For Linux based boards, you typically need to install udev rules:

The later Teensyduino installs, has one in it, that you can copy in, else you can download it from the download page.

You then typically need to copy it into the right place, like: sudo cp 00-teensy.rules /etc/udev/rules.d/


You need to make sure you are talking to the correct Serial device. Some Arduino boards (that use FTDI) are like: /dev/ttyUSB0 where Teensy and other boards will have different names,
like I believe: /dev/ttyACM0 but may depend on which linux... Also the 0 at end could be 1 or 2 or ...
 
Thanks a lot for the advice KurtE!

I have tried setting up all of this, however the only way I was able to get any data in serial monitors on Linux is by compiling and flashing code from PlatformIO. If I do that, the monitor (either of them, the PlatformIO built-in one, screen or Arduino's monitor) works as intended until I unplug the USB cable. I need to flash code again after that to read anything.

What do you mean by "USB type"? I am using the USB Serial, so would that make it the SEREMU thing you refer to?

I did not have this problem on Windows, so this must be a linux-specific issue?

Thanks in advance!
 
Interestingly, if I use my Linux machine to flash this code:

Code:
int i = 0;

void setup() {
  // put your setup code here, to run once:
  Serial.begin(115200);
}

void loop() {
  // put your main code here, to run repeatedly:
  Serial.print(i);
  Serial.println(" yeet");
  //delay();
  i++;
}

onto another Teensy 3.2 (same model as the one I use in the project), everything works as intended :confused:

Here's how I declare the Serial on my main project:

Code:
void setup() {
  // put your setup code here, to run once:
  Serial.begin(115200);
  while (!Serial && millis() < 3000);
  //delay(1000);
  Serial.println("hello");
  aClass.setSerial(&Serial);

aClass uses a pointer to print to this Serial from its functions.

Edit: the different behaviour makes sense, because the second Teensy is powered from USB, whereas the original has its own supply and so doesn't get power cycled...
 
Sorry for the spam. I think I have narrowed down the problem.

If I reset (through the reset and not program pin) the Teensy while the USB is plugged in, the Serial starts working. However, if I plug the device in after the program has started, nothing works. Is it then possible to open serial at any point of the program on Linux?
 
Back
Top