Go Down

Topic: PString Example fails verify in Arduino 1.0 --ANSWERED-- (Read 3081 times) previous topic - next topic

BlitzerMalloy

Jan 19, 2012, 05:30 am Last Edit: Jan 27, 2012, 03:42 am by BlitzerMalloy Reason: 1
Hi,

I am trying to use Pstring.h in an Arduino project (my first one).  I have been able to fix some other library issues for Arduino 1.0, but I am not sure how to tackle this one.  I have added the PString2 library, but even the example project test_pstring fails the verification.  I get the following error:
Code: [Select]
In file included from test_pstring.cpp:1:
C:\arduino-1.0-windows\arduino-1.0\libraries\PString/PString.h:34: error: conflicting return type specified for 'virtual void PString::write(uint8_t)'
C:\arduino-1.0-windows\arduino-1.0\hardware\arduino\cores\arduino/Print.h:48: error:   overriding 'virtual size_t Print::write(uint8_t)'


Would someone be able to tell me what is going wrong?  I haven't been able to find an answer anywhere, and I am sure I am not the first person who is trying to use PString with 1.0 (should I be using something else?).

Thanks


---ANSWERED BELOW - Post #8---

technobabologist

Sorry cant really help at the moment but i can suggest going to the prev version and using that, v1.0 has changed the default header file from WProgram.h to Arduino.h, maybe that has something to do with it, iv found a few strange thing myself in 1.0 and also dont worry about using R3's in the older versions, as they work fine for me, just make sure you point to the driver folder in 1.0 for windows to install it, then go back to using the previous one.

hellonearthis

#2
Jan 19, 2012, 12:43 pm Last Edit: Jan 19, 2012, 12:54 pm by hellonearthis Reason: 1
I had a quick look at it.

The first problem I had was the example needed to be in it's own folder.
The file test_pstring.pde in examples should be in a sub folder called test_pstring

That didn't make it work.  I had a read of http://blog.makezine.com/2011/12/01/arduino-1-0-is-out-heres-what-you-need-to-know/
They say,  "New functionality has been added to Streams (the underlying class that anything that uses .print() statements), Ethernet, Wire (I2C), and low level input/output."

So now I get the same error.

Looks like you will have to go back to 0.22 or find another way to do your printing

PaulS

What functionality is in the old PString class that is not in the new String class?
The art of getting good answers lies in asking good questions.

BlitzerMalloy

hellonearthis,

The article helped somewhat, and ties into the error message, but it is beyond what I currently understand.  Essentially, it is stating that VOID statements must be replaced with SIZE_T statements, but being an idiot and just replacing the offending void in line 34 PString with size_t doesn't fix the issue.  But, I do get a different error message.  I believe the cpp file also needs to be adjusted, but a simple attempt to change the void Pstring::write to size_t (in conjunction with the other change) just brings about different error messages.

Obviously I am just changing things without any clue as to what I am doing.  :)

PaulS

Quote
Obviously I am just changing things without any clue as to what I am doing.

So, why are you doing them? Why do you thing you need the PString class? It has been superseded.
The art of getting good answers lies in asking good questions.

BlitzerMalloy

Because PString is referenced by a lot of other scripts, two of which I want to use right now.  So the choice is to modify every program that includes PSting or try to update PString.  Obvioulsy, if it is possible to fix just PString that would help everyone.

hellonearthis

Have you asked the author about this?

http://arduiniana.org/libraries/pstring/

BlitzerMalloy

My thanks to travist from the SparkFun forum for this answer:

Quote
Change line 34 of PString.h to:
Code: [Select]
virtual size_t write(uint8_t);

And line 29 of Pstring.cpp to:
Code: [Select]
size_t PString::write(uint8_t b)

And not neccessary but I believe its more correct, add these 2 return lines to Pstring.cpp
Code: [Select]
size_t PString::write(uint8_t b)
{
  if (_cur + 1 < _buf + _size)
  {
    *_cur++ = (char)b;
    *_cur = '\0';
   return 1;
  }
  return 0;
}

misk0

Thanksssssssss

I lost half of my day trying to find out how to fix this.

Go Up