D
D
Denis2021-02-07 18:59:09
Arduino
Denis, 2021-02-07 18:59:09

How to convert to hex format using c#?

I am making a program that will convert the code in arduino ide to hex format, yes, I know that you can

Sketch -> Export binary file

I need it using c#

Answer the question

In order to leave comments, you need to log in

4 answer(s)
H
HemulGM, 2021-02-08
Folyush @AAGR

hex is not a format, but a bit representation. What you see in notepad or a hex editor when you open a file through them is just different representations of bits (zeros and ones). They can be represented even in hex (hexadecimal system), even in octal, even in decimal, even in symbols, which is what most notepads do.
The Arduino IDE doesn't convert the code to hex, it compiles the sect - it compiles it. What is compilation - you should know if you want to do something there on Sharpe.
You need to compile the sketch. It is compiled, oddly enough, by the compiler. It is located in the Arduino IDE folder. You look for it, you call the assembly of the desired sketch. Better yet, go and google "hand-compiling an arduino sketch".
The final HEX file is generated from the compiled binary, not from the code.
Those. first learn how to compile the code, and then translate it into a text version.

L
lonelymyp, 2021-02-08
@lonelymyp

The compiler converts the program to hex. This is a separate complex program that you cannot write.
Fortunately, the compiler can be used by everyone.
You can make a call to the standard compiler from arduino in your program, give it the program code as input and get the finished hex output

V
Vasily Bannikov, 2021-02-07
@vabka

See what commands the arduino ide calls when building the sketch and repeat this in C# through Process.Start

B
Borys Latysh, 2021-02-15
@nava2002

hex - the file is MACHINE CODES. That is, a set of codes that the controller processor interprets as commands.
All controllers have internal elements of different design and, consequently, different processor instruction sets.
Therefore, before uploading the firmware to Arduino, it is necessary to indicate which controller will be programmed.
A command in a high-level language (C++) is associated with the controller through a set of libraries and then turns into a set of commands that will make up the contents of the hex file written to the controller's memory.
The C# language does NOT have such an interpreter for microcontrollers used in Arduino.
Therefore, it is NOT possible to compile a program written in C# into an executable hex file.
Therefore, you need to REWRITE the text of the program written in C # (in a text editor) using the syntax of the C ++ language and only then it can be compiled for writing to the controller's memory.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question