Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
My program needs CDC.printf to work.
23-11-2012, 07:18 PM,
#1
My program needs CDC.printf to work.
It's so strange, but If I put a CDC.printf in my program, then it works. This is a problem since Pinguino needs USB connection in every moment. The program doesn't run If you don't connect Pinguino with the PC.

I suppose that CDC library checks the connection with the Computer. Could I do something to solve it?

Thanks again.
Reply
23-11-2012, 07:52 PM,
#2
RE: My program needs CDC.printf to work.
That doesn't seem to make sense. Please explain more carefully.

John
Reply
23-11-2012, 08:18 PM, (This post was last modified: 23-11-2012, 08:22 PM by Pelelalo.)
#3
RE: My program needs CDC.printf to work.
(23-11-2012, 07:52 PM)pingotg Wrote: That doesn't seem to make sense. Please explain more carefully.

John

OF Course John.

Last week I am trying to port PONG Game (http://blog.bsoares.com.br/arduino/ping-...on-arduino) on my Pinguino 18F2550. Finally It works. I am so happy.

BUT in Arduino code there is a line with it:

Serial.println(angle); //I though it was only a test BUT

I change it with: CDC.printf(angle). AND I noticed that without this line, program didn't work. I thought this instruction could be changed with a delay, but NOT. The instruction IS needed.

SO I thought: OK. The problem is that CDC library test the connection with the computer, so If I try to use Pinguino+PONG Game without being connected with the PC (that is, connected to a battery 9V), GAme doesn't work.

Finally, Game works, but only being connected with the USB of the computer I use to program (not any computer).

I don't know what to do. The best idea would be, avoid using CDC, but then program doesn't run.
Reply
23-11-2012, 09:58 PM,
#4
RE: My program needs CDC.printf to work.
So leaving the CDC line out means it doesn't run? Has to be a bug somewhere!

John
Reply
23-11-2012, 10:40 PM,
#5
RE: My program needs CDC.printf to work.
(23-11-2012, 09:58 PM)pingotg Wrote: So leaving the CDC line out means it doesn't run? Has to be a bug somewhere!

John

That's right.

I'm going to work in it tonight, but I doubt between studying CDC routine to see what it does to make my program work or looking for the bug in my code. Thanks again John.
Reply
24-11-2012, 11:29 AM,
#6
RE: My program needs CDC.printf to work.
SOLVED!. The problem was that "loop" function didn't run unless you put a CDC.printf. I think that the reason is that my Ontimer0 (1usec) interrupt avoid it. So my solution: I have defined another Ontimer1 interrupt that executes a loop2 function each 1usec.

Thanks for your support.
Reply
24-11-2012, 11:59 AM,
#7
RE: My program needs CDC.printf to work.
Hi Pelelalo,

what version of Pinguino are you running and under which operating system and also which Pinguino board are you using?

When you say the "program didn't work" without the CDC.printf() command do you mean that it did not compile or that it compiled, was uploaded OK but did not run. If it did not compile, were any errors reported in either the window at the bottom of the IDE or in source/stdout file. It may held to see what was in the source/stdout file after you compiled.

It may not be a bug in your program but rather a bug in one of the library files. I have seen a similar problem in the past due to a Pinguino library file not containing a necessary "#include" statement. Like your problem the program ran when I had a CDC function in my program, as the CDC library files had the necessary "include", but would not run without it. As the problem was with a library file rather than my program very few, if any errors, were reported by the IDE. The problem was solved by a modification to the library file that was missing the include statement. Depending on which version of Pinguino you are using there may be a later version that has already solved the issue. Sorry if I am being a bit vague but it is a while ago and I cannot remember the full details. If you can give some more details of your

For the 32bit boards the CDC.printf statement makes the Pinguino IDE include the _cdc.c library file (see p32/pdl/usb.pdl32). Near the start of the p32/include/core/_cdc.c file there is a series of #include statements. You could try including each of the #include statements near the start of your program in turn until your program runs OK. This will tell you which of library file is not being "included" by another library file but not which library file does not have all the necessary includes. To find that it will be necessary to look at your program and see what other library files are being used and then look at each of those files in turn. Again if you can identify which version of the IDE you are using (as per the Read This Before Posting post at the start of each section of this forum) it may be possible to check whether an updated version of the IDE has already dealt with it.

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


Forum Jump:


Users browsing this thread: 1 Guest(s)