Page 1 of 3

Unknown error

Posted: 15 Nov 2016 00:07
by A.Harrenberg
Hi,

I am trying to convert an Arduino library to the ZUNO, I have cleared a lot of error messages from the compiler but I am stuck... The compiler is throwing an "Unknown error":

Code: Select all

ZUNO_MFRC522_sdcpp_.cpp:2404:18:warning:conversion from string literal to 'char *' is deprecated
ZUNO_MFRC522_sdcpp_.cpp:2418:17:warning:conversion from string literal to 'char *' is deprecated
ZUNO_MFRC522_sdcpp_.cpp:2421:19:warning:conversion from string literal to 'char *' is deprecated
ZUNO_MFRC522_sdcpp_.cpp:2443:19:warning:conversion from string literal to 'char *' is deprecated
ZUNO_MFRC522_sdcpp_.cpp:2453:17:warning:conversion from string literal to 'char *' is deprecated
ZUNO_MFRC522_sdcpp_.cpp:2480:17:warning:conversion from string literal to 'char *' is deprecatedUnknown error:'enum MFRC522::StatusCode' uCxx returned error code:-1

Fehler beim Kompilieren.
The error message apprears without a newline direct after the last warning and is not preceeded by the filename, line-number... I have already enabled all compiler warnings and the extended reporting during compilation but there is no more information available.

Is there a way to find out what is causing this error?? There is no "enum MFRC522::StatusCode" in the code, only the below enumeration from the header file, so I guess it is something that the compiler creates when he is e.g. evaluating the constructor...

In the orignial code there was this enumeration with a forward reference to "byte", which is not allowed in C++, so I just removed the type defintion:

Code: Select all

	//enum StatusCode : byte {
	enum StatusCode {
		STATUS_OK							,	// Success
		STATUS_ERROR					,	// Error in communication
		STATUS_COLLISION			,	// Collission detected
		STATUS_TIMEOUT				,	// Timeout in communication.
		STATUS_NO_ROOM				,	// A buffer is not big enough.
		STATUS_INTERNAL_ERROR	,	// Internal error in the code. Should not happen ;-)
		STATUS_INVALID				,	// Invalid argument.
		STATUS_CRC_WRONG			,	// The CRC_A does not match
		STATUS_MIFARE_NACK		= 0xff	// A MIFARE PICC responded with NAK.
	};
There are several functions in the code which use StatusCode as their typedef. It is quite a long time ago that I programmed in C and I have not much experience in C++ at all, so I don't know if that is causing the problem or not...
Any hints are welcome here.

Thank you very much in advance,
Andreas.

Re: Unknown error

Posted: 15 Nov 2016 02:01
by p0lyg0n1
Try to use byte/int instead of StatusCode type in the function parameters

Re: Unknown error

Posted: 15 Nov 2016 09:42
by A.Harrenberg
Hi,

I tried that with byte before and run into a lot of other errors...
There were a lot of errors where it seems that StautusCode was not using byte, as there error messages complained about that byte is not the correct datatype. I will try to make some test code first to see if the enum is using byte or int.

Then I will change the functions to the used type and try to work on the new error messages.

The compiler option is already set to --verbose

Code: Select all

compiler.sdccOptions = '-mmcs51 --out-fmt-ihx --model-large --verbose --debug --use-stdout --code-loc 0x8000 --xram-loc 0x3000' 
, so I guess the compiler error can not be tracked... ,-(

Regards,
Andreas.

Re: Unknown error

Posted: 15 Nov 2016 10:27
by PoltoS
Can you share the code so we can look on it?

Re: Unknown error

Posted: 15 Nov 2016 23:27
by A.Harrenberg
Hi,
PoltoS wrote:Can you share the code so we can look on it?
I attached the library code and an example code. I removed the doc and other examples from the library to save some space. It is the "standard" MFRC522 from the Arduino.

Regards,
Andreas.

Re: Unknown error

Posted: 16 Nov 2016 00:19
by A.Harrenberg
Hi,

I just created some sample code to find out what size an enum has with this compiler and in my case it is using 2byte = int, so I will try to change the all the reference to the enumeration to int...

I will be busy on the during the next days, so I might not answer until next week.

Regards,
Andreas.

Re: Unknown error

Posted: 16 Nov 2016 13:54
by p0lyg0n1
Hi, I just have the first "quick look" to your code.
And I have some recipes for you:
1. You have to define SS pin number. Z-Uno can use any IO pin for this.
Compiler said about it:

Code: Select all

Compiling /Users/alexander/Code/ZUno/compilerCXX/tests/Tests_Builds/MFRC522/ZUNO_MFRC522_sdcpp_.cpp ...
ZUNO_MFRC522_sdcpp_.cpp:827:23:error:use of undeclared identifier 'SS'
ZUNO_MFRC522_sdcpp_.cpp:1025:11:error:use of undeclared identifier 'SS'
2. Move all enums/structs outside the class-space. We use simplified C++ that called uC++ and it doesn't support embedded enums/structs/classes inside another class.
3. Replace all "StatusCode" in the names of function to "byte". For example:
StatusCode PCD_TransceiveData(byte *sendData, byte sendLen, byte *backData, byte *backLen, byte *validBits = NULL, byte rxAlign = 0, bool checkCRC = false);
will be:
byte PCD_TransceiveData(byte *sendData, byte sendLen, byte *backData, byte *backLen, byte *validBits = NULL, byte rxAlign = 0, bool checkCRC = false);
4. uCxx doesn't support static const fields inside class like this:

Code: Select all

static const byte FIFO_SIZE = 64;

Just use macro-style (

Code: Select all

#define FIFO_SIZE 64 
) .



We will try to make a list of deprecated C++ techniques for the next release.

Re: Unknown error

Posted: 16 Nov 2016 15:04
by A.Harrenberg
Hi p0lyg0n1,

thank you very much for all the hints!
p0lyg0n1 wrote: 3. Replace all "StatusCode" in the names of function to "byte". For example:
StatusCode PCD_TransceiveData(byte *sendData, byte sendLen, byte *backData, byte *backLen, byte *validBits = NULL, byte rxAlign = 0, bool checkCRC = false);
will be:
byte PCD_TransceiveData(byte *sendData, byte sendLen, byte *backData, byte *backLen, byte *validBits = NULL, byte rxAlign = 0, bool checkCRC = false);
As this is used in the context of the enumeration and the enumeration uses int, I guess I should then also use int for the function??
The compiler does not optimize the size for the enum to byte, even if the last element is defined as 0xff.
p0lyg0n1 wrote: We will try to make a list of deprecated C++ techniques for the next release.
Yes, I think a list will be very helpfull for all developments...

Regards,
Andreas.

Re: Unknown error

Posted: 18 Nov 2016 12:03
by A.Harrenberg
Hi p0lyg0n1,
p0lyg0n1 wrote: 1. You have to define SS pin number. Z-Uno can use any IO pin for this.
This was defined in my system, I added it in ZUNO_Definitions.h but forgot to give it to you. I moved the definition now to ZUNO_MFRC522.h
p0lyg0n1 wrote: 3. Replace all "StatusCode" in the names of function to "byte".
I did this now in several variations... First I tried with byte, there were a lot error saying that the enum can't be assign with a type of byte. Tried it with int, same result. The last two attempts with using StatusCode or using byte and casts to StatusCode for the assignments both end with another "unknown error"... :(

Code: Select all

Compiling C:\Users\andre\AppData\Local\Temp\build152256629544549265.tmp\ZUNO_MFRC522_sdcpp_.cpp ...Unknown error:list index out of range uCxx returned error code:-1
So I am back at square one, it seems that there is still some problem with the enumerations... But what is the problem and where...

Regards,
Andreas.

Re: Unknown error

Posted: 27 Nov 2016 12:21
by p0lyg0n1
Hi, Andreas.
I did this now in several variations... First I tried with byte, there were a lot error saying that the enum can't be assign with a type of byte
Please post the one of them. I need a whole source to understand this.