Errno 6

goalJJB

Member
Hi there,

I am having an issue when trying to run the serial monitor in PlatformIO with my Teensy 4.1. I have written a simple piece of code to list all the folders within an SD card. However, when I try to run the serial monitor all it says is: Reconnecting error.png This repeats over and over. I have tried rebooting the Teensy loader as well as checking that the file .hex is readable.

Here is my code:

Code:
#include <SD.h>
#include <SPI.h>
#include <string>

String fileExtension = ".wav";

File myPresets;

#define MOSI_PIN 11
#define SCK_PIN 13
#define CS_PIN = BUILTIN_SDCARD

void setup()
{

 Serial.begin(9600);
 SPI.setMOSI(MOSI_PIN);
 SPI.setSCK(SCK_PIN);
 if (!(SD.begin(BUILTIN_SDCARD)))
 {
  // stop here if no SD card, but print a message
  while (1)
  {
   Serial.println("Unable to access the SD card");
   delay(500);
  }
 }
}

int main()
{
 int arr[5] = {5, 2, 9, 4, 1};
 int *ptr = &arr[2];
 printf("The value in the second index of the array is: %d\n", *ptr);
 return 0;
}

void loop()
{

 // nothing happens after setup finishes.
}

void printDirectory(File dir, int numTabs)
{

 while (true)
 {

  File entry = dir.openNextFile();

  if (!entry)
  {

   // no more files

   break;
  }

  for (uint8_t i = 0; i < numTabs; i++)
  {

   Serial.print('\t');
  }

  Serial.print(entry.name());

  if (entry.isDirectory())
  {

   Serial.println("/");

   printDirectory(entry, numTabs + 1);
  }
  else
  {

   // files have sizes, directories do not

   Serial.print("\t\t");

   Serial.println(entry.size(), DEC);
  }

  entry.close();
 }
}

Any help would be appreciated, Thanks!
 
Seems to be linux? Are the current '00-teensy.rules' properly installed?

pjrc.com/teensy/td_download.html
see:
Code:
Linux Installation
Download the Linux udev rules (link at the top of this page) and copy the file to /etc/udev/rules.d.
sudo cp 00-teensy.rules /etc/udev/rules.d/
 
Last edited:
Is this MacOS? Kinda looks like MacOS, but not a lot of info given so difficult to tell. Of course the Linux udev rules won't help if it really is a Mac running Apple's operating system.

What might help is testing with Arduino + Teensyduino. If using MacOS Ventura, best to use Arduino 2.0.3 and install the latest beta, which appears is "0.58.3" in the Boards Manager drop-down menu (we name the betas as version 0 so the software won't prompt people to upgrade from stable to beta). The latest beta has some fixes for Ventua-specific issues that have come up recently.

As for PlatformIO, sorry, I really don't know. It might be a bug or it might be something misconfigured. We see that a lot with PlatformIO. If it really is a PlatformIO, to have any chance of reporting it, you're probably going to need to demonstrate the same code works properly with Arduino IDE but fails when used with PlatformIO. So you might as well at least install the Arduino IDE and give it a quick try, just to figure out if the problem is specific to PlatformIO.
 
goalJJB:
As defraster and Paul have both commented, What system are you using, Mac, Windows, or Linux?
Since I also use PlatformIO on my Mac (OS Monterey 12.6.3) perhaps I could help?
Please show us your platformio.ini file as that has very important info for debugging.
Does the build finish without any warnings, if not show the build output.

As it says at the top of each and every post on this forum: Forum Rule: Always post complete source code & details to reproduce any issue!

We can not help without all the necessary details to reproduce what you have done.

Regards,
Ed
 
Hi everyone,

Thank you for your replies. I am using macOS Ventura. When I have access to my laptop later today I will try using the Arduino beta version to see if it outputs anything. If not I will post any update here. As well as posting the .ini file.

Thank you again for getting back to me so quickly.

J
 
Hi Paul,

After uploading the code to Arduino 2.0.3 with the latest beta version installed. This error flashes in the serial monitor:

arduino serial monitor error.png

Does this mean there may be an issue with the Teensy itself? I have tried 2 different usb cables (both I'm sure are not for charging but for microcontrollers)?

Thanks

(here is the code):

Code:
#include <SD.h>
#include <Audio.h>

#define MOSI_PIN 11
#define SCK_PIN 13
#define CS_PIN = BUILTIN_SDCARD

void setup()
{

 Serial.begin(9600);
 SPI.setMOSI(MOSI_PIN);
 SPI.setSCK(SCK_PIN);
 if (!(SD.begin(BUILTIN_SDCARD)))
 {
  // stop here if no SD card, but print a message
  while (1)
  {
   Serial.println("Unable to access the SD card");
   delay(500);
  }
 }
}

int main()
{
 int arr[5] = {5, 2, 9, 4, 1};
 int *ptr = &arr[2];
 printf("The value in the second index of the array is: %d\n", *ptr);
 return 0;
}

void printDirectory(File dir, int numTabs)
{

 Serial.begin(9600);

 while (true)
 {

  File entry = dir.openNextFile();

  if (!entry)
  {

   // no more files

   break;
  }

  for (uint8_t i = 0; i < numTabs; i++)
  {

   Serial.print('\t');
  }

  Serial.print(entry.name());

  if (entry.isDirectory())
  {

   Serial.println("/");

   printDirectory(entry, numTabs + 1);
  }
  else
  {

   // files have sizes, directories do not

   Serial.print("\t\t");

   Serial.println(entry.size(), DEC);
  }

  entry.close();
 }
}

void loop()
{
  //nothing
}


Interestingly after testing the serial monitor with the arduino 'print' example program, the serial monitor responded to this program.


Update: I have got the program to work in Arduino.
 
Last edited:
Back
Top