Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
serial comms
17-12-2013, 08:20 PM,
#1
serial comms
I don't understand something basic:
I use the following

#include <serial.c>
#include <__cdc.c>

When I examine serial.c, I see definitions like serial.begin, serial.getkey, etc.

In my program, I have borrowed lines from published programs like:
if (SerialAvailable(in_port));
do {c = SerialGetKey(uport); }while(c!='$');
SerialConfigure(biport, UART_ENABLE, UART_RX_TX_ENABLED, biport_baud);
and these calls compile and work.

Notice that there is no period after "serial" .
I've noticed these things before, but done nothing about it, since it worked.
I've just tried serial.printf and it doesn't work, so I guess that I now need to understand what script is running behind the scenes so that serial.c is not used; I need to use serial.printf.

Can anyone help.
Thanks.
Reply
17-12-2013, 10:08 PM, (This post was last modified: 17-12-2013, 10:08 PM by pingotg.)
#2
RE: serial comms
If you're writing a .pde file it gets pre-processed into a .c and you're expected to use the Arduino syntax (serial.thing). The various #includes are done by the IDE so don't do it as well.

If you're writing a .c then you're on your own.

Oh, OK, you're not - but you ARE expected to be able to figure out how the pre-processing works.

Now.... you failed to say which OS, p8 or p32 and so on, so what are you doing???

John
Reply
18-12-2013, 05:44 AM,
#3
RE: serial comms
Hi John,
I'm using p32 target and compiling on Windows 8.
I have modified PINGUINO_MODGPS_EXAMPLE_v1.1 which is a .pde written by Olimex in June 2012. Perhaps I have chosen the wrong supplier of open-source code, but this is what was prominently available on the website of the company selling my hardware. If I understand your comments, they have broken the Arduino/Pinguino rules. Let me apologize on their behalf.

Their file contains lines which compile perfectly such as
a) #include <serial.c>
b) SerialAvailable, SerialGetKey (no "." after "serial").

You are completely correct that I have no knowledge of the pre-processor converting .pde files into .c files. Perhaps you can supply a link; I had not understood the necessity of learning this relationship, so quickly darted past that step in my education. As things stand, I am awe-struck every time there is an error message referencing the line number in the .c program produced by the pre-processor, although I have never seen the .c program. Maybe there is a switch to print the .c program.

Anyway, in spite of lapses in my education, how do I solve my immediate problem? Thank you in advance.
Reply
18-12-2013, 09:52 AM,
#4
RE: serial comms
Hi Ashton,
There is no need to include any library in your program (.pde) as long as this library also have a keyword file associated (.pdl). The pre-processor will do it for you.
If you use the Pinguino IDE then I recommend you to use the Pinguino (Arduino-like) syntax.
So please replace SerialAvailable by Serial.available, SerialGetKey by Serial.getKey.
Serial.printf should also work.
Tell me if you need more information.
It is easier to complain than it is to do, but it is better to do than it is to complain.
Reply
18-12-2013, 11:37 AM,
#5
RE: serial comms
It sounds like you are editing a library file Ashton?

Pinguino libraries are written in C, while .pde files have a C++ syntax (e.g. Serial.printf).

You will need to copy the library routines (with the #include's) to your P32 library directory for them to work with your project.

Look in the Olimex archive for .pde files. This will be your project file.
Reply
18-12-2013, 12:27 PM, (This post was last modified: 18-12-2013, 12:28 PM by pingotg.)
#6
RE: serial comms
It doesn't sound a very good example but you know we're not psychic so no-one knew which code you were trying to use.

Perhaps it was written by someone who knows a lot more about hardware than this project!

If you look at the project's own examples and of course the documentation they should give you ideas.

John
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)