IoT project with arduino. I'm stuck at some commands.

Hi guys,

I'm developing IoT project with arduino and cpp client socket. The arduino has ethernet shıeld w5100 and sd card. I'm stuck with some commands which are important for the project.

Arduino as a server and cpp socket client.

I need to find arduino's specifications and send it back parsable format like XML ,

another command is that ı need to send binary file to arduino and arduino upload that and execute it. It will be FTP kinda command. Can some help to me? I can only send and receive messages between arduino and cpp socket client right now. I researched the commands but I did not to reach success. I need some support. Thx.

More explanation about project,

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.

this is too big.
what is your coding experience?
on what Arduino do you want to run this?
what is really needed?
what goal should this very generic setup fulfill?

Some parts of these requirements will be very difficult or not possible with Arduino.

Particularly the "UPLOAD/EXECUTE PROGRAM" part. Some types of "Arduino" such as those based on ESP8266 chips, have the ability to be re-programmed "over the air" (OTA). But this is achieved in a way that may not be able to meet those requirements, because the uploaded program completely replaces the previous program. The requirements sound like a 'master' program running an uploaded 'slave' program which the master can manage and interrupt. This may not be possible because Arduino do not have a multi-tasking operating system that would be required to achieve that.

If you want a small development board that has the power and resources to run a multi-tasking OS, maybe consider Raspberry Pi Zero W or similar.

Juraj:
this is too big.
what is your coding experience?
on what Arduino do you want to run this?
what is really needed?
what goal should this very generic setup fulfill?

First of all, thank you for answering.

I have a code experience but not with arduino. C/C++ mostly but ı'm doing a degree at software engineering so my experience not too much.

I want to execute with arduino uno.

the project pushed me too hard.My university professor gave this project for summer internship.

And ı just set my arduino uno as a server and cpp client socket i wrote. They can receive and send messages via tcp port . and that's all ı have no idea how can ı do that commands.

Thx.

PaulRB:
Some parts of these requirements will be very difficult or not possible with Arduino.

Particularly the "UPLOAD/EXECUTE PROGRAM" part. Some types of "Arduino" such as those based on ESP8266 chips, have the ability to be re-programmed "over the air" (OTA). But this is achieved in a way that may not be able to meet those requirements, because the uploaded program completely replaces the previous program. The requirements sound like a 'master' program running an uploaded 'slave' program which the master can manage and interrupt. This may not be possible because Arduino do not have a multi-tasking operating system that would be required to achieve that.

If you want a small development board that has the power and resources to run a multi-tasking OS, maybe consider Raspberry Pi Zero W or similar.

Thank you for answering PaulRB,

My university professor gave this project for summer internship. I think he wants the impossible according to your answer. I'm really stuck with that project. I do not know how i am gonna do that but thank you again.

Does your professor know you are targetting Arduino Uno?
Was Arduino Uno his suggestion, or your idea?

If it was the profs idea then I'm surprised at their lack of knowledge. Unless the uploaded program is meant to be some kind of virtual machine language, I can't really see how this would work. Especially the whole timer interrupt thing.

The GET_INFO command is also sort of strange. Really all it needs to return is the board type "Arduino Uno". Once you know that all the other stuff is a given.

pcbbc:
Does your professor know you are targetting Arduino Uno?
Was Arduino Uno his suggestion, or your idea?

If it was the profs idea then I'm surprised at their lack of knowledge. Unless the uploaded program is meant to be some kind of virtual machine language, I can't really see how this would work. Especially the whole timer interrupt thing.

The GET_INFO command is also sort of strange. Really all it needs to return is the board type "Arduino Uno". Once you know that all the other stuff is a given.

Hi pcbcc , thank you for answering.

Yes it was his idea. he said "the type of Arduino system is not very important, you can have one from the cheap. and The goal is to work on any system". Also I've been researching for 4 days for get_info command and ı did not find anything about it. And he said before the project details ,"the project wıll be about arduino and c/c++ programming".

in this case you have to meet the requirements in a minimal possible way.
for example store and download data to/from EEPROM, because you can not fit networking library and SD library in a usable sketch on Uno.
no XML. that needs too many strings which will take too much flash memory. JSON is possible.
and some very simple and short 'program' commands

The number and variety of Arduino systems is very varied. They go from 8-bit devices with very limited resources up to things ESP8266 with a 32-bit RISC core. His statement that "the type of Arduino system is not very important" is naive to say the least.

For the UPLOAD/EXECUTE PROGRAM part (at least on the large majority of Arduino devices which can only run code from FLASH) you're basically being asked to write a Ethernet bootloader. Quite a complex one at that.

So I would go back to your professor and clarify that is indeed what he is looking for. Point out that a "suitable region in the memory" implies FLASH on, for example ATMega328 devices such as the Uno, and that implies a bootloader.

Also the maximum bootloader space on a Uno is 2048 words, so 4KB.
To give you an idea, a very basic OTA bootloader using an NRF24 radio can be made to fit in 2KB.
But that's before you add the GET_INFO and UPLOAD/DOWNLOAD DATA commands.