Pinguino Forum
[SOLVED] println() doesn't print anything - Printable Version

+- Pinguino Forum (http://forum.pinguino.cc)
+-- Forum: Software (http://forum.pinguino.cc/forumdisplay.php?fid=7)
+--- Forum: Syntax & Programs (http://forum.pinguino.cc/forumdisplay.php?fid=19)
+--- Thread: [SOLVED] println() doesn't print anything (/showthread.php?tid=4138)



[SOLVED] println() doesn't print anything - FlacoDev - 03-11-2013

Hello guys,
I've got a problem with the Serial function println().
I don't know where it should be displayed but println() does not print anything in the terminal where the Pinguino IDE was launched or in the IDE's console.

I have tested my the current flow on my breadboard and everything seems okay (I did it with a led).

OS + distro: GNU/Linux Arch Linux (updated 2 days ago)
Board: PIC32-Pinguino-MX220 (from Olimex)
Additional info: The pins 7 & 8 are respectively the Trigger & Echo of my HC-SR04 ultrasonic module.

Here's the code :

main.pde :
Code:
#define trigPin 7
#define echoPin 8

long duration;
long distance;

void setup()
{
  Serial.begin(9600);
  pinMode(trigPin, OUTPUT);
  pinMode(echoPin, INPUT);
}

void loop()
{
  digitalWrite(trigPin, LOW);
  delayMicroseconds(2);

  digitalWrite(trigPin, HIGH);
  delayMicroseconds(10);

  digitalWrite(trigPin, LOW);
  duration = pulseIn(echoPin, HIGH, 1000);

  distance = duration/58.2;

  Serial.println(distance);

  delay(50);
}

(Based on this example)
Where did I failed ?

Thanks,
Flaco Smile


RE: println() doesn't print anything - iyahdub - 03-11-2013

Do you mean to debug, like the Arduino serial monitor ?!
http://dubworks.blogspot.co.uk/2013/03/pinguino-cdc-debugging.html


RE: println() doesn't print anything - FlacoDev - 03-11-2013

Hi (again)!

It's getting late here so I'll try tomorrow. Smile
Thanks for the link (and it seems to be an interesting blog Big Grin )

Do you know the differences between CDC & Serial ?

Flaco Smile


RE: println() doesn't print anything - pingotg - 03-11-2013

CDC should be over the USB cable. Serial is RS232 (COM port stuff).

I use CDC.printf all the time Smile

John


RE: println() doesn't print anything - FlacoDev - 03-11-2013

Hey pingotg; it's been quite a long time. I hope you're doing well. Big Grin
Thank you for the tip. I will use it errr'y time now. Smile

Thanks to you guys!


RE: println() doesn't print anything - pingotg - 03-11-2013

You're welcome.

I download to the board and then watch the debug CDC.printf data from my app.

It's /dev/ttyACM0 on Linux.

Easy to do with or without the IDE.

John


RE: println() doesn't print anything - FlacoDev - 03-11-2013

I'm back. Code tested, I've got some issues. :/

First: Nothing is displayed.

I have tested this code :

Code:
void setup() {
  // put your setup code here, to run once:

}

void loop() {
  // put your main code here, to run repeatedly:
  CDC.println("\n\r Hello World!!!");
}

Second: My code doesn't compile but since I'm not totally sober at this time. I'll try to debug it later, hahaha.

See you guys,
Flaco Smile

EDIT: I can't find the indicated path in your link :/

Quote:Step 4: Select Menu->Pinguino->Debug Mode->USB CDC And on the bottom section the port x on which the device is connected and there you go:

I just have "File" (Fichier) "Edit" (Editer) "View" (Vue) "Send to Pinguino" (Envoyer vers Pinguino) and "Help" (Aide)
I didn't find any "Pinguino" sub-menu. (I have taken a look at the "Configuration..." sub-window as well).


RE: println() doesn't print anything - pingotg - 04-11-2013

On mine it's under the Pinguino menu item, but I don't use it. I prefer to use a terminal emulator (as Linux calls them) in a separate window. (I use the "screen" command.)

I put a small delay in my pde after the first CDC.printf as that creates the ttyACM0 device and I like to have a moment to run screen.

The first bit of output tends to get lost as I suppose it's sent during the time I'm starting screen.

It's so convenient that I've never bothered to improve it. ("It ain't broke so don't fix it.")

John


RE: println() doesn't print anything - FlacoDev - 04-11-2013

Hello John,
I read more carefully your second answer and I see that CDC.printf() writes in /dev/TTYACM0. Right?

How can I access/read this file (preferably in real-time) ?
I have tried with Emacs but it tells me "File exists, but cannot be read". Any tip ?

Flaco

EDIT: Found it! sudo cat /dev/ttyACM0 works very well.
Thank you so much man! Smile


RE: println() doesn't print anything - pingotg - 04-11-2013

Well done!

Longer term, if you look at the owner of /dev/ttyACM0 (which will probably be dialout or plugdev or the like), you can add your login to the groups allowed to access it, then you won't need the sudo

Something like usermod -G plugdev -a loginname

(you need to log out and back in after that for the new group to be in force)

When that works, you should also be able to view the CDC prints from the IDE. I'm happy with screen, though.

John