Determine Application Version
From Nutwiki
Test Environments
Hardware Comments | Nut/OS 4.6.3 |
Nut/OS 4.6.4 |
Nut/OS 4.7.4 |
Nut/OS 4.8.0 |
Nut/OS 4.8.7 | |
Ethernut 1.3 H | OK | OK Binaries |
OK Binaries |
OK Binaries |
OK Binaries Compiler: AVR-GCC 4.3.2 | |
Ethernut 2.1 B | OK | OK Binaries |
OK Binaries |
OK Binaries |
OK Binaries Compiler: AVR-GCC 4.3.2 | |
Ethernut 3.0 E | OK | OK Binaries |
OK Binaries |
OK Binaries |
OK Binaries Compiler: ARM-GCC 4.3.3 | |
EIR 1.0 C | Set jumper JP1 to DEBUG mode. | OK | OK Binaries |
OK Binaries |
OK Binaries |
|
Compiler: ARM-GCC 4.2.2 ; AVR-GCC 4.3.0 |
Description
This example shows an easy and common way to store a string (e.g. for the application version) and printing it out.
Source Code
<source lang="c">
- include <dev/board.h>
- include <stdio.h>
int main(void) {
char *version = "1.0";
u_long baud = 115200;
NutRegisterDevice(&DEV_DEBUG, 0, 0); freopen(DEV_DEBUG_NAME, "w", stdout); _ioctl(_fileno(stdout), UART_SETSPEED, &baud);
printf("Application version: %s\n", version);
for(;;); return 0;
}
</source>
Output
Application version: 1.0
Details
<source lang="c"> char *version = "1.0"; </source>
defines a pointer to the type char, which points to an adress in memory where the string "1.0" is stored.
<source lang="c"> printf("Application version: %s\n", version); </source>
now prints out the string stored at the adress, the version
pointer provides.