Show Posts

This section allows you to view all posts made by this member. Note that you can only see posts made in areas you currently have access to.

Messages - TeslaFan

Pages: [1]
Programming Questions / Re: Cannot compile existing Arduino project.
« on: November 05, 2011, 05:30:39 PM »
Back to the original issue, looking at avr/pgmspace.h in both Arduino and Wiring, I notice that you're using a newer one, but the implementation for strcpy_P is the same. But I also noted that pgm_read_word() returns a variable cast as const.

So, changing:
Code: [Select]
strcpy_P(pstr_text,(char*)pgm_read_word(&(s_table[38]))); //"com%dtype"
in each instance where I used it to:

Code: [Select]
strcpy_P(pstr_text,(const char*)pgm_read_word(&(s_table[38]))); //"com%dtype"
fixed the issue nicely. This project is a library for a custom board based on the Arduino, so I want it to be compilable with any AVR environment, not just Wiring.

I also notice that my program is bigger (14K) with Wiring as opposed to 12.9K under Arduino. The available RAM is also lower, 697 bytes after the library is initialized in Wiring, as opposed to 752 bytes remaining after the same in Arduino.

Keep up the good work!

Programming Questions / Re: Cannot compile existing Arduino project.
« on: November 04, 2011, 06:36:15 PM »
thanks! That worked fine.

I like how the string definition gets placed where it's used, but I don't like that it's probably instantiating and destroying the wrapper object for the string every time it executes that function. Please tell me that ConstantString is totally static and doesn't dynamically construct anything.

I like how one IDE can support multiple architectures, but it seems to compile a lot slower. That might be an issue with 3rd party boards that have large libraries to support the board's unique features.
Programming Questions / Re: Cannot compile existing Arduino project.
« on: November 04, 2011, 01:09:12 PM »
Ok, I replaced all the calls to strcpy_P to use the Constant data type.

That worked great with Serial.println(Constant("text to Print");

but fails with any form of strcpy() or sprintf()

Apparently, casting the Constant() as a (const char*) just returns a pointer to the object, not to the string it references.

If I can't use strcpy() or sprintf() with a text string stored in FLASH, then I'm dead in the water.

How do I use Constant() with strcpy() and sprintf()?
Programming Questions / Cannot compile existing Arduino project.
« on: November 03, 2011, 03:39:14 PM »

Saw "Wiring" at Sparkfun and thought I'd see if I could switch to it from Arduino 22.

It tanks on this line of code, there's nothing special about it... I call strcpy_P dozens of times. This time is neither the first nor last. s_table[38] exists and will fit into pstr_text.

Code: [Select]
strcpy_P(pstr_text,(char*)pgm_read_word(&(s_table[38]))); //"com%dtype"

The error I get is:

Code: [Select]
CommManager.cpp:921: error: error: can't find a register in class 'BASE_POINTER_REGS' while reloading 'asm'
Then I get a list of:
Code: [Select]
CommManager.cpp:921: error: error: 'asm' operand has impossible constraints
that correspond to subsequent calls to strcpy_P but... not to ALL of them. And there are no syntax errors that I can see.

I could post more code, or even the entire program, but it's fairly large. The problem seems centered around PROGMEM, but doesn't start until after about 32 calls to strcpy_P.
Pages: [1]