Go Down

Topic: PROGMEM problem in PTP library (Read 417 times) previous topic - next topic

_Mark_H

Hi,

I want to use the PTP library to use a camera with the USB host shield 2.0. First step was to build the example PTPDevInfo with Arduino 1.6.5 ide. But the compiler stops with an error
Code: [Select]

devinfoparser.cpp:145:38: error: variable 'DevInfoParser::imNames' must be const
in order to be put into read-only section by means of '__attribute__((progmem))'
const char* DevInfoParser::imNames[] PROGMEM =
 


In the source I can see that an array is filled with values out of the flash.

Code: [Select]

const char msgEXIF_JPEG [] PROGMEM = "EXIF_JPEG";
const char msgTIFF_EP [] PROGMEM = "TIFF_EP";
const char msgFlashPix [] PROGMEM = "FlashPix";
const char msgBMP [] PROGMEM = "BMP";
const char msgCIFF [] PROGMEM = "CIFF";
const char msgUndefined_0x3806 [] PROGMEM = "Undefined_0x3806";
const char msgGIF [] PROGMEM = "GIF";
const char msgJFIF [] PROGMEM = "JFIF";
const char msgPCD [] PROGMEM = "PCD";
const char msgPICT [] PROGMEM = "PICT";
const char msgPNG [] PROGMEM = "PNG";
const char msgUndefined_0x380C [] PROGMEM = "Undefined_0x380C";
const char msgTIFF [] PROGMEM = "TIFF";
const char msgTIFF_IT [] PROGMEM = "TIFF_IT";
const char msgJP2 [] PROGMEM = "JP2";
const char msgJPX [] PROGMEM = "JPX";

...
...

const char* DevInfoParser::imNames[] PROGMEM =
{
msgUndefined,
msgEXIF_JPEG,
msgTIFF_EP,
msgFlashPix,
msgBMP,
msgCIFF,
msgUndefined_0x3806,
msgGIF,
msgJFIF,
msgPCD,
msgPICT,
msgPNG,
msgUndefined_0x380C,
msgTIFF,
msgTIFF_IT,
msgJP2,
msgJPX,
};



I try to fix the problem with the help of PROGMEM reference. But I got no luck

Code: [Select]
const char* const DevInfoParser::imNames[] PROGMEM =
{
msgUndefined,
...


results in 

Code: [Select]
devinfoparser.cpp:145:44: error: declaration of 'const char* DevInfoParser::imNames []'
outside of class is not definition [-fpermissive] const char* const DevInfoParser::imNames[] PROGMEM =


Has someone an idea how to fix it?

Thanks

Mark

PaulS

Quote
Has someone an idea how to fix it?
The array appears to be a class member. In the header file, it is defined one way. You changed the source file to declare it differently. The definition needs to be the same in both files.

_Mark_H

#2
Aug 20, 2015, 09:36 am Last Edit: Aug 20, 2015, 09:37 am by _Mark_H
Hello Paul,

thanks for help. :smiley-red: you are so right. I did not think on the declaration. If I change
Code: [Select]
class DevInfoParser : public PTPReadParser
{
static const char* ptpopNames[];
static const char* mtpopNames[];
static const char* ptpevNames[];
static const char* mtpevNames[];
static const char* acNames[];
static const char* imNames[];
...


to

Code: [Select]
class DevInfoParser : public PTPReadParser
{
static const char* const ptpopNames[];
static const char* const mtpopNames[];
static const char* const ptpevNames[];
static const char* const mtpevNames[];
static const char* const acNames[];
static const char* const imNames[];
...


the compiler is happy.

Thanks

Mark

Go Up