1
0
mirror of https://github.com/RIOT-OS/RIOT.git synced 2024-12-29 04:50:03 +01:00

[sys shell]

* fixed some shell commands
This commit is contained in:
Oliver Hahm 2011-04-06 11:11:03 +02:00
parent f7d6ef4709
commit 0661ce2f7f
3 changed files with 35 additions and 17 deletions

View File

@ -1,27 +1,43 @@
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <cc1100-interface.h>
#ifdef MODULE_CC110X
void _cc1100_get_address_handler(char *str) {
radio_address_t addr = cc1100_get_address();
printf("cc1100 address: %i\n", addr);
void _cc110x_get_set_address_handler(char *addr) {
int16_t a;
a = atoi(addr+5);
if (strlen(addr) > 5) {
printf("[cc110x] Setting address %i ... ", a);
cc1100_set_address((radio_address_t)a);
if (cc1100_get_address() == (radio_address_t)a) {
puts("[OK]");
} else {
puts("Error!");
}
}
else {
printf("[cc1100] Got address: %i\n", cc1100_get_address());
}
}
void _cc1100_set_address_handler(char *str) {
int addr;
int res = sscanf(str, "cc1100_set_address %i", &addr);
if (res == 1) {
cc1100_set_address((radio_address_t)addr);
printf("Setting cc1100 address to %i: ", addr);
if (cc1100_get_address() == (radio_address_t)addr) {
void _cc110x_get_set_channel_handler(char *addr) {
int16_t a;
a = atoi(addr+5);
if (strlen(addr) > 5) {
printf("[cc110x] Setting channel %i...", a);
cc1100_set_channel(a);
if (cc1100_get_channel() == a) {
puts("OK");
} else {
puts("Error!");
}
} else {
puts("usage: cc1100_set_address <address>");
}
else {
printf("[cc1100] Got address: %i\n", cc1100_get_channel());
}
}
#endif

View File

@ -8,7 +8,9 @@ void _id_handler(char *id) {
newid = atoi(id+3);
if (strlen(id) < 3) {
#ifdef MODULE_CONFIG
printf("Current id: %u\n", sysconfig.id);
#endif
}
else {
printf("Setting new id %lu\n", newid);

View File

@ -24,8 +24,8 @@ extern void _reset_current_handler(char* unused);
#endif
#ifdef MODULE_CC110X
extern void _cc110x_get_address_handler(char *unused);
extern void _cc110x_set_address_handler(char *ptr);
extern void _cc110x_get_set_address_handler(char *addr);
extern void _cc110x_get_set_channel_handler(char *addr);
#endif
#ifdef MODULE_TRANSCEIVER
@ -56,8 +56,8 @@ const shell_command_t _shell_command_list[] = {
{"rstcur", "Resets coulomb counter.", _reset_current_handler},
#endif
#ifdef MODULE_CC110X
{"cc110x_get_address", "", _cc110x_get_address_handler},
{"cc110x_set_address", "", _cc110x_set_address_handler},
{"addr", "Gets or sets the address for the CC1100 transceiver", _cc110x_get_set_address_handler},
{"chan", "Gets or sets the channel for the CC1100 transceiver", _cc110x_get_set_channel_handler},
#endif
#ifdef MODULE_TRANSCEIVER
#ifdef MODULE_CC110X_NG