Go Down

Topic: [SOLVED] Arduino and Atmel Studio 7. (Read 2896 times) previous topic - next topic

PaulVdBergh

Jul 16, 2016, 01:48 pm Last Edit: Jul 25, 2016, 12:29 pm by PaulVdBergh
Hi All,

I'm traying to convert an .ino sketch to Atmel Studio 7.

The sketch compiles in Arduino IDE without errors and with the following messages:

Code: [Select]
d:\Users\Paul\Documents\Arduino\libraries\XpressNetMaster\XpressNetMaster.cpp: In member function 'void XpressNetMasterClass::SetLocoBusy(uint8_t, uint16_t)':

d:\Users\Paul\Documents\Arduino\libraries\XpressNetMaster\XpressNetMaster.cpp:342:38: warning: narrowing conversion of '(((int)UserOps) | 256)' from 'int' to 'unsigned int' inside { } [-Wnarrowing]

  unsigned int LocoInfo[] = { UserOps | 0x100, 0xE3, 0x40, Adr >> 8, Adr & 0xFF, 0x00 };

                                      ^

d:\Users\Paul\Documents\Arduino\libraries\XpressNetMaster\XpressNetMaster.cpp: In member function 'void XpressNetMasterClass::SetLocoInfo(uint8_t, uint8_t, uint8_t, uint8_t, uint8_t)':

d:\Users\Paul\Documents\Arduino\libraries\XpressNetMaster\XpressNetMaster.cpp:356:38: warning: narrowing conversion of '(((int)UserOps) | 256)' from 'int' to 'unsigned int' inside { } [-Wnarrowing]

  unsigned int LocoInfo[] = { UserOps | 0x100, 0xE4, B00001000 | Steps, Speed, F0, F1, 0x00 };

                                      ^

d:\Users\Paul\Documents\Arduino\libraries\XpressNetMaster\XpressNetMaster.cpp:356:63: warning: narrowing conversion of '(int)(Steps | 8u)' from 'int' to 'unsigned int' inside { } [-Wnarrowing]

  unsigned int LocoInfo[] = { UserOps | 0x100, 0xE4, B00001000 | Steps, Speed, F0, F1, 0x00 };

                                                               ^

d:\Users\Paul\Documents\Arduino\libraries\XpressNetMaster\XpressNetMaster.cpp: In member function 'void XpressNetMasterClass::SetFktStatus(uint8_t, uint8_t, uint8_t)':

d:\Users\Paul\Documents\Arduino\libraries\XpressNetMaster\XpressNetMaster.cpp:366:37: warning: narrowing conversion of '(((int)UserOps) | 256)' from 'int' to 'unsigned int' inside { } [-Wnarrowing]

  unsigned int LocoFkt[] = { UserOps | 0x100, 0xE3, 0x52, F4, F5, 0x00 };

                                     ^

d:\Users\Paul\Documents\Arduino\libraries\XpressNetMaster\XpressNetMaster.cpp: In member function 'void XpressNetMasterClass::SetTrntStatus(uint8_t, uint8_t, uint8_t)':

d:\Users\Paul\Documents\Arduino\libraries\XpressNetMaster\XpressNetMaster.cpp:380:38: warning: narrowing conversion of '(((int)UserOps) | 256)' from 'int' to 'unsigned int' inside { } [-Wnarrowing]

  unsigned int TrntInfo[] = { UserOps | 0x100, 0x42, Address, Data, 0x00 };

                                      ^

d:\Users\Paul\Documents\Arduino\libraries\DCCInterfaceMaster\DCCPacketScheduler.cpp: In member function 'bool DCCPacketScheduler::setBasicAccessoryPos(uint16_t, bool, bool)':

d:\Users\Paul\Documents\Arduino\libraries\DCCInterfaceMaster\DCCPacketScheduler.cpp:508:53: warning: narrowing conversion of '(((address + ((uint16_t)((DCCPacketScheduler*)this)->DCCPacketScheduler::TrntFormat)) & 3u) << 1)' from 'uint16_t {aka unsigned int}' to 'uint8_t {aka unsigned char}' inside { } [-Wnarrowing]

  uint8_t data[] = { ((address + TrntFormat) & 0x03) << 1 }; //0000-CDDX

                                                     ^


Sketch uses 37,130 bytes (14%) of program storage space. Maximum is 253,952 bytes.
Global variables use 2,703 bytes (32%) of dynamic memory, leaving 5,489 bytes for local variables. Maximum is 8,192 bytes.


Creating a new project in Atmel Studio 7 (File -> New -> Project -> C/C++ -> Create project from Arduino sketch -> Create C++ project from Arduino sketch -> filling Sketch File, Arduino IDE Path, Board and Device-> OK) gives an error "not enough arguments for format string"

A Simple sketch gives no problems.


The project's documentation and sketch files and necessary libraries can be found here : http://pgahtow.de/wiki/index.php?title=Zentrale

Any suggestions are very welcome !

Thanks in advance,

Paul


jmparatte

Daer Paul,

As you say yourself :
...
A Simple sketch gives no problems.
...
I think you must solve the numerous compilation warnings.

What is the declaration of UserOps ?

jmP

PaulVdBergh

Thanks for your reply, mjP.

Since I'm new to arduino and using Atmel studio for years, maybe this is a stupid question, but how can I find the declaration(s) of "UserOps" using the Arduino IDE ?  I suppose there are multiple declarations and even definitions or assignments (between #ifdef and #endif statements).  This is a feature I cannot find in Arduino's IDE.

Thanks;

Paul

P.S. sorry for being a newbie re Arduino IDE, but my ultimate goal is creating and modifying/debugging using Atmel Studio 7  (with Atmel ICE) on the Arduino MEGA 2560 R3 board and if everything is working (both software and hardware), creating my own boards for controlling my Fleischmann N model railroad.

jmparatte

Hi Paul,

Forget my previous answer, the warnings are not the problem.

The problem is in creating the new Atmel Studio 7 project with conversion of INO and that produces the message: "not enough arguments for format string".

I understand this error as a printf(...) with not enough arguments. Stange because printf() and familly are not documented in Arduino Reference.

jmP

PaulVdBergh

Dear mjP,

AFAIK, "int printf(const char* format, ...)" is a valid C/C++ statement ??  Is there any tool to highlight only the code that's relevant and dimmish the code that is between #ifdef ...  #else .. #endif and isn't relevant for the current build configuration ?  How can I see the code in these libs and/or debug these libs (or any Arduino code for that matter) using the Arduino IDE by single stepping or placing a breakpoint?

Even the preprossessors' output could be of help...

Paul.

jmparatte

I also use printf() and family in Arduino developments.

Perhaps it's now time to show us your code.

PaulVdBergh

Hi mpJ,

As in my OP:

The project's documentation and sketch files and necessary libraries can be found here. The download links are on the bottom of the page.
It is a rather complex sketch (implementing different Digital Command Control protocols used in model railroad sofrware and hardware). These additional libraries can also be found at the end of the page.

I don't know how to open a library file in arduino IDE, which makes it very difficult for me to understand the internals of both the sketch itself and the libraries.  I'm used to write sourcecode and debug the compiled program(s) using Atmel Studio and Atmel ICE. 

If there is a way to debug (ie single stepping and placing breakpoints) from within Arduino IDE, this could bring some light in the darkness ;)

Thanks.

PaulVdBergh

Update:

 

I changed arduino's compiler options (see this article), fixed all the errors and warnings shown in the arduino's output window, but to no avail, Atmel Studio refuses to convert the sketch into a AS solution...  sad

 

Anyone a suggestion ?

PaulVdBergh

As I asked this question to the Avr forum, I get the following solution.  This solved my problem.  :)

Go Up