How will I pass command line arguments to cross compiler code?

Hi people,

I have an interesting problem here. I need to generate a number (a 4-digit Integer) and give it as a command line argument to my exe file generated by the cross compiler.

The problem is, EXE file would be executed by the chip & not by the PC, hence giving any command line argument would need a connection between the chip & one of the ports on the PC.

Is there a way/mechanism by which I can give a command line argument during compile-time and not during the run-time?

Is there any functionality provided by the tool on these lines?

Regards,
Jinen.

Parents
  • In the target system, who types a command line? Do you actually have a command line interface task?

    Or do you mean you want to pass an argument to main() -- argc and argv? These arguments are usually derived from a command line in an interactive OS by the C run-time system. In an embedded system, they're generally meaningless, unless that embedded system is running some sort of user shell.

    Does this value need to be altered dynamically? That is, every time the system is powered on, or the user hits a key, or some such, you need to supply a value? In this case, you'd need to describe your user interface hardware. You probably have a UART somewhere on your microcontroller, for example. Perhaps you use it for a human-readable CLI, or perhaps you just invent a protocol to send a few bytes across the serial port.

    If it is sufficient that the value be supplied at compile time, then all you really need to do is set a #define, or perhaps generate a small .c file with a suitable constant variable definition. That hardwires in the value, and no communication is necessary.

Reply
  • In the target system, who types a command line? Do you actually have a command line interface task?

    Or do you mean you want to pass an argument to main() -- argc and argv? These arguments are usually derived from a command line in an interactive OS by the C run-time system. In an embedded system, they're generally meaningless, unless that embedded system is running some sort of user shell.

    Does this value need to be altered dynamically? That is, every time the system is powered on, or the user hits a key, or some such, you need to supply a value? In this case, you'd need to describe your user interface hardware. You probably have a UART somewhere on your microcontroller, for example. Perhaps you use it for a human-readable CLI, or perhaps you just invent a protocol to send a few bytes across the serial port.

    If it is sufficient that the value be supplied at compile time, then all you really need to do is set a #define, or perhaps generate a small .c file with a suitable constant variable definition. That hardwires in the value, and no communication is necessary.

Children
More questions in this forum