Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
CDC.printf does not appear to be working properly
04-03-2012, 12:43 AM,
#1
CDC.printf does not appear to be working properly
Hi - just got a few new Pinguinos from Olimex, and installed X.3 from SVN

I am having a little trouble getting something as simple as CDC.printf() to work.

The code:

Code:
void setup()
{                
  // initialize the digital pin 13 as an output.
  pinMode(13, OUTPUT);    
}

void loop()
{
    
    while (true)
    {
        
    
        toggle(13);            // alternate ON and OFF
        delay(500);            // wait for 500 ms
        CDC.printf("%d\n",100);
        
    }
}

...and the output:


devuser@work-SM40S:/dev$ cat <ttyACM0
-1610580020
-1610580020
-1610580020
-1610580020
-1610580020
-1610580020
-1610580020
-1610580020


Have I totally lost it - i.e. what is going on - is there a bug in the implementation of printf (same happens with float, double, anything passed on as a parameter to char *format..)[/quote].?

Also, the reason why I'm doing a cat above is I can't seem to get the Pinguino IDE to attach to the CDC tty (/dev/ttyACM0).

This is under Lubuntu (Oneiric) and Pinguino IDE X.3 r249
The board is an Olimex PIC32 Pinguino OTG
Can anyone help out?
Reply
04-03-2012, 11:17 AM, (This post was last modified: 04-03-2012, 11:23 AM by mf01.)
#2
RE: CDC.printf does not appear to be working properly
Hi acmbc68

Firstly could you confirm which version of x.3 you are currently running as your post said r249 but that seems rather old.

That having been said I have compiled and attempted to run your program in X.3 r294 and there does appear to be a bug in x.3 as I get the same output as you.

Is there any particular reason you are using x.3 rather than trunk/x.2. x.3 is very much under active development and is not necessarily fully debugged - a lot of the "commits" for x.3 on Google code have warnings that they are not intended for use.

I suggest that, unless there are particular features of x.3 that you need to use and possibly even then (see below), you download and use the latest version of x.2 (trunk). There is a full package of x.2 r293 on the Google code downloads page (http://code.google.com/p/pinguino32/downloads/list) or alternatively you could checkout the latest version - r294 at the time of posting (see http://code.google.com/p/pinguino32/source/checkout).

In Ubuntu/linux it is possible to have multiple versions of the IDE on the computer at the same time, provided that each is in a separate folder - I currently have about 12 different versions or variants partly so that I can do regression testing if I suddenly find a problem with the latest version but mainly because I am just lousy at housekeeping ;-). Once you have got used to the overall structure of the Pinguino IDE it is possible to "transplant" parts of x.3 into x.2 to use particular x.3 features that have not been included in x.2.

I have compiled and run your program using x.2 (trunk) r290 and the program runs OK giving an output of 100 as expected. I used "cat /dev/ttyACM0" to list the output in a terminal window.

One final comment - I suggest changing the CDC.printf line to read :-

Code:
CDC.printf("%d\r\n",100);

so that the output does not scroll off the right hand side of the terminal window.

Regards
Board = PIC32-Pinguino-OTG Rev C
OS = Linux Unbuntu 11.10 till 26 Apr 2012
OS = Linux Unbuntu 12:04 from 27 Apr 2012
Reply
04-03-2012, 11:57 AM,
#3
RE: CDC.printf does not appear to be working properly
Sorry - typo - I'm using 294

Don't bother with the code - I just pasted a full code block. The code is actually quite meaningless.

I am going to start porting a lot of Arduino stuff over, but want to know what works/doesnt before I start so as to not go down wild goose chases.

I also have the last X.2 release installed. Ill keep to that for the time being.

Thanks,

Augusto

(04-03-2012, 11:17 AM)mf01 Wrote: Hi acmbc68

Firstly could you confirm which version of x.3 you are currently running as your post said r249 but that seems rather old.

That having been said I have compiled and attempted to run your program in X.3 r294 and there does appear to be a bug in x.3 as I get the same output as you.

Is there any particular reason you are using x.3 rather than trunk/x.2. x.3 is very much under active development and is not necessarily fully debugged - a lot of the "commits" for x.3 on Google code have warnings that they are not intended for use.

I suggest that, unless there are particular features of x.3 that you need to use and possibly even then (see below), you download and use the latest version of x.2 (trunk). There is a full package of x.2 r293 on the Google code downloads page (http://code.google.com/p/pinguino32/downloads/list) or alternatively you could checkout the latest version - r294 at the time of posting (see http://code.google.com/p/pinguino32/source/checkout).

In Ubuntu/linux it is possible to have multiple versions of the IDE on the computer at the same time, provided that each is in a separate folder - I currently have about 12 different versions or variants partly so that I can do regression testing if I suddenly find a problem with the latest version but mainly because I am just lousy at housekeeping ;-). Once you have got used to the overall structure of the Pinguino IDE it is possible to "transplant" parts of x.3 into x.2 to use particular x.3 features that have not been included in x.2.

I have compiled and run your program using x.2 (trunk) r290 and the program runs OK giving an output of 100 as expected. I used "cat /dev/ttyACM0" to list the output in a terminal window.

One final comment - I suggest changing the CDC.printf line to read :-

Code:
CDC.printf("%d\r\n",100);

so that the output does not scroll off the right hand side of the terminal window.

Regards

Reply
04-03-2012, 01:06 PM,
#4
RE: CDC.printf does not appear to be working properly
My fault !
In function CDCprintf (__cdc.c) replace :
length = psprintf(buffer, fmt, args);
by this one :
length = psprintf2(buffer, fmt, args);


It is easier to complain than it is to do, but it is better to do than it is to complain.
Reply
04-03-2012, 04:57 PM,
#5
RE: CDC.printf does not appear to be working properly
Updated from SVN. Tested here. Working!


(04-03-2012, 01:06 PM)regis Wrote: My fault !
In function CDCprintf (__cdc.c) replace :
length = psprintf(buffer, fmt, args);
by this one :
length = psprintf2(buffer, fmt, args);

Reply
06-03-2012, 01:14 AM,
#6
RE: CDC.printf does not appear to be working properly
Indeed it is... I appear to have some sort of quirky issue with CDC.write - writing out 1 byte at a time with CDC.write seems to hang the pinguino, but not with printf. But I will have to investigate this further....

(04-03-2012, 04:57 PM)acmbc68 Wrote: Updated from SVN. Tested here. Working!


(04-03-2012, 01:06 PM)regis Wrote: My fault !
In function CDCprintf (__cdc.c) replace :
length = psprintf(buffer, fmt, args);
by this one :
length = psprintf2(buffer, fmt, args);

Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)