how to get information about arduino which is running?

Hi everyone,

I'm developing arduino project. I have a arduino uno with ethernet shield also sd card. My arduino as a server. on the other hand ı have a c++ socket client program which is communicate with my server arduino.

ı want to find my arduino features and send it back parsable format to my c++ client program. but ı researched and ı dıd not fınd any solution. Can someone have knowledge about it? ıs there any lıbrary or functıon for that?

the command is will be like that,

This command is sent by an external system to the device. The listening program will collect information

about the device it is running on, and using a parsebla format (like XML), it will send it back. Some

items can be listed as :

o # of AD converters

o Clock Frequeny

o Chip Model

o # of timers

o Serial/ USB/CAN/I2C communication types

o Size of registers (8,16,32,64)

o ...etc.

Hi Learner45,

first of all it is completely OK to a nebwee about programming. It is completely OK to have only a medium knoweldge about english. You seem to have only a medium knowledge about english.
So one suggestion is: this forum has a lot of language-specific subforums.
What is your native language you have grown up with? From some grammar-mistakes I guess german. There is a german sub-forum, and a french, an italian, a spanish, a dutch, etc. just scroll down the main forum until the languages apear.

i just understand 42. Which means I don't understand.
It will need much more words to describe what you want to do.

What do you mean by writing "ı want to find my arduino features" what do you mean with features? can you give two example-"features"

What do you mean with "This command is sent by an external system to the device."

how does he command look like? WHat is "the device"? The arduino or the c++client?

How are the arduino and the c++-client connected? B a serial interface?, SPI?, I2C?

How do the "items" look like?

In your title-question "how to get information about arduino which is running?" it i snot clear to me

do you want to gain information if teh Arduino is powered and executing his code?
should the Arduino get some information about connected things like sensors and what protocol the sensor is using?

These ar all details but what is the whole thing?
it is no self-purpose to send "features" or "items" over whatever protocol
best regards Stefan

You can get the device signature which is unique to each of the processor type , then have a look up table to identify the processor, so you can get the A/D type etc . You can also read the fuses to work out clock speed etc .

Can’t see this being easy , as you might need to upload a program to get that info - never tried it, or needed to .

I’ve no idea why you want to do this , and suspect there is a further question in here somewhere - what is your project ?

Some details are easier to get than others. For example the Arduino UNO has 6 analog input channels but if you want to use the Wire/TWI/I2C interface you can only use 4 of the 6.

hammy:
You can get the device signature which is unique to each of the processor type , then have a look up table to identify the processor, so you can get the A/D type etc . You can also read the fuses to work out clock speed etc .

Can’t see this being easy , as you might need to upload a program to get that info - never tried it, or needed to .

I’ve no idea why you want to do this , and suspect there is a further question in here somewhere - what is your project ?

Hi hammy,

first of all, thank you for helping.It is my summer practise project. I'm doing degree at software engineering. Actually that is the part of the my project. I completed some parts. I will give more information about the project in below. I am confused about it.

Topic: Internet of Things

The project is to control small internet devices using a remote program upload and peripharel discovery. A listening program will run in the background and will listen for external commands.

Requirement: The program will listen to a port for external commands and requests. After receiving the command, the listener program will execute the request. It is possible to transfer data in/out the device if necessary. The commands will have a predefined structure whicl should be identifies during the project. The small device can be an Ardunio system although this is not a must.

COMMANDS:

•GET_INFO

This command is sent by an external system to the device. The listening program will collect information about the device it is running on, and using a parsebla format (like XML), it will send it back. Some items can be listed as :

o # of AD converters
o Clock Frequeny
o Chip Model
o # of timers
o Serial/ USB/CAN/I2C communication types
o Size of registers (8,16,32,64)
o ...etc.

•UPLOAD DATA

Using a predefined format, data needs to be passed to the device and a suitable location will be used to store the data.
For example
o # of values to be stored
o Set of values
o Location ??? (dynamicly determined)

•DOWNLOAD DATA

Data generated after the running a program, will be transferred using a predefined protocol to external systems.
o Store the generated data to a predefined location. The data will uploaded to an external system upon request.

•UPLOAD/EXECUTE PROGRAM
This is to upload a program to the device. The program will be compiled externally using the info collected above. After receiving the program to a suitable region in the memory, the listener program will pass the control to the program. Using a timer, the listener program will wake up periodically and it may check the health of the running program and interrupt if necessary.

•INTERRUPT PROGRAM

This command will be used to stop the running program.

o # of AD converters

NUM_ANALOG_INPUTS

o Clock Frequeny

F_CPU

o Chip Model

Usually needs to be determined backwards from things like #define SAMD21 provided during compilation. (and not available as a convenient string or value.) Many chips have some sort of product identifier (like the "device signature" on AVR, or the CHIPID on SAM3x, or undocumented (?!) "Device Configuration Area" on SAMD (or maybe DSU->DID ?) Sigh.

o # of timers

Not readily available. Also note that "number of timers" may or may not have anything to do with "number of PWM outputs", since the number of PWMs per timer is variable, some chips have a separate PWM controller, and not all timers can do PWM. You can usually step through the pin translation tables and count ones that have timers, but the tables are different depending on architecture.

o Serial/ USB/CAN/I2C communication types

Not readily available. CAN is not an enabled feature in the Arduino Core, so nit would be library-dependent.
You can usually identify such info from the chip-specific .h file, but it probably won't be in a very usable format. Instead, you'll be doing stuff like:

#if defined(CAN1)
#define N_CAN 2
#elif defined(CAN0) || defined(CAN)
#define N_CAN 1
#else
#define N_CAN 0
#endif

Some chips have communication controllers that can be configured for several different protocol, so...
(six "SERCOM" on a SAMD21, each of which COULD be SPI, I2C, or UART.)

o Size of registers (8,16,32,64)

For what purpose? timer registers with 16bits on an 8bit CPU? 8 bit IOPORT registers on a 32bit CPU?
sizeof(int) ?

I've written a couple similar things, most recently for SAMD (attached.) Looks like:

SAMD Explorer> board
Value of 'USB_MANUFACTURER' is 'Adafruit LLC'
Value of 'USB_PRODUCT' is 'Adafruit Grand Central M4'
Value of '__SKETCH_NAME__' is 'cli_dev.ino'
Value of '__VERSION__' is '7.2.1 20170904 (release) [ARM/embedded-7-branch revision 255204]'
Value of 'F_CPU' is 120000000
Value of 'sizeof(int)' is 4
Value of 'sizeof(double)' is 8
Value of 'sizeof (float)' is 4
Value of 'NUM_DIGITAL_PINS' is 53
Value of 'NUM_ANALOG_INPUTS' is 19

SAMD Explorer> sercom
Pin # 0 has SERCOM
Pin # 1 has SERCOM
Pin #14 has SERCOM
Pin #15 has SERCOM
Pin #16 has SERCOM
Pin #17 has SERCOM
Pin #18 has SERCOM
Pin #19 has SERCOM
Pin #20 has SERCOM
Pin #21 has SERCOM
Pin #24 has SERCOM
Pin #25 has SERCOM

SAMD Explorer> pwm
Pin # 2 has PWM Channel 0x002
Pin # 3 has PWM Channel 0x003
Pin # 4 has PWM Channel 0x004
Pin # 5 has PWM Channel 0x005
Pin # 6 has PWM Channel 0x100
Pin # 7 has PWM Channel 0x101
Pin # 8 has PWM Channel 0x100

cli_dev.zip (6.01 KB)

westfw:
NUM_ANALOG_INPUTS
F_CPU
Usually needs to be determined backwards from things like #define SAMD21 provided during compilation. (and not available as a convenient string or value.) Many chips have some sort of product identifier (like the "device signature" on AVR, or the CHIPID on SAM3x, or undocumented (?!) "Device Configuration Area" on SAMD (or maybe DSU->DID ?) Sigh.
Not readily available. Also note that "number of timers" may or may not have anything to do with "number of PWM outputs", since the number of PWMs per timer is variable, some chips have a separate PWM controller, and not all timers can do PWM. You can usually step through the pin translation tables and count ones that have timers, but the tables are different depending on architecture.
Not readily available. CAN is not an enabled feature in the Arduino Core, so nit would be library-dependent.
You can usually identify such info from the chip-specific .h file, but it probably won't be in a very usable format. Instead, you'll be doing stuff like:

#if defined(CAN1)

#define N_CAN 2
#elif defined(CAN0) || defined(CAN)
#define N_CAN 1
#else
#define N_CAN 0
#endif



Some chips have communication controllers that can be configured for several different protocol, so...
(six "SERCOM" on a SAMD21, each of which COULD be SPI, I2C, or UART.)
For what purpose? timer registers with 16bits on an 8bit CPU? 8 bit IOPORT registers on a 32bit CPU?
sizeof(int) ?


I've written a couple similar things, most recently for SAMD (attached.) Looks like:


SAMD Explorer> board
Value of 'USB_MANUFACTURER' is 'Adafruit LLC'
Value of 'USB_PRODUCT' is 'Adafruit Grand Central M4'
Value of 'SKETCH_NAME' is 'cli_dev.ino'
Value of 'VERSION' is '7.2.1 20170904 (release) [ARM/embedded-7-branch revision 255204]'
Value of 'F_CPU' is 120000000
Value of 'sizeof(int)' is 4
Value of 'sizeof(double)' is 8
Value of 'sizeof (float)' is 4
Value of 'NUM_DIGITAL_PINS' is 53
Value of 'NUM_ANALOG_INPUTS' is 19

SAMD Explorer> sercom
Pin # 0 has SERCOM
Pin # 1 has SERCOM
Pin #14 has SERCOM
Pin #15 has SERCOM
Pin #16 has SERCOM
Pin #17 has SERCOM
Pin #18 has SERCOM
Pin #19 has SERCOM
Pin #20 has SERCOM
Pin #21 has SERCOM
Pin #24 has SERCOM
Pin #25 has SERCOM

SAMD Explorer> pwm
Pin # 2 has PWM Channel 0x002
Pin # 3 has PWM Channel 0x003
Pin # 4 has PWM Channel 0x004
Pin # 5 has PWM Channel 0x005
Pin # 6 has PWM Channel 0x100
Pin # 7 has PWM Channel 0x101
Pin # 8 has PWM Channel 0x100

Hi westfw,

Thank you so much for helping. it looks so helpful , ı will try to handle my problem.

thx.