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

[sys/shell project/test_cc110x_ng]

' moved monitor command from userapp to default shell command set

[sys/transceiver]
 ' make transceiver_pid "public"
This commit is contained in:
Oliver Hahm 2010-11-27 11:09:42 +01:00
parent 413b2898ec
commit 54172b5c86
5 changed files with 30 additions and 19 deletions

View File

@ -14,25 +14,13 @@
#define SHELL_STACK_SIZE (2048) #define SHELL_STACK_SIZE (2048)
#define RADIO_STACK_SIZE (2048) #define RADIO_STACK_SIZE (2048)
int transceiver_pid;
char shell_stack_buffer[SHELL_STACK_SIZE]; char shell_stack_buffer[SHELL_STACK_SIZE];
char radio_stack_buffer[RADIO_STACK_SIZE]; char radio_stack_buffer[RADIO_STACK_SIZE];
void mon_handler(char *mode);
shell_t shell; shell_t shell;
const shell_command_t sc[] = { const shell_command_t sc[] = {
{"mon", "", mon_handler},
{NULL, NULL, NULL}}; {NULL, NULL, NULL}};
void mon_handler(char *mode) {
unsigned int m;
sscanf(mode, "mon %u", &m);
printf("Setting monitor mode: %u\n", m);
cc1100_set_monitor(m);
}
void shell_runner(void) { void shell_runner(void) {
shell_init(&shell, sc, uart0_readc, uart0_putc); shell_init(&shell, sc, uart0_readc, uart0_putc);
posix_open(uart0_handler_pid, 0); posix_open(uart0_handler_pid, 0);
@ -67,7 +55,7 @@ int main(void) {
thread_create(shell_stack_buffer, SHELL_STACK_SIZE, PRIORITY_MAIN-1, CREATE_STACKTEST, shell_runner, "shell"); thread_create(shell_stack_buffer, SHELL_STACK_SIZE, PRIORITY_MAIN-1, CREATE_STACKTEST, shell_runner, "shell");
radio_pid = thread_create(radio_stack_buffer, RADIO_STACK_SIZE, PRIORITY_MAIN-2, CREATE_STACKTEST, radio, "radio"); radio_pid = thread_create(radio_stack_buffer, RADIO_STACK_SIZE, PRIORITY_MAIN-2, CREATE_STACKTEST, radio, "radio");
transceiver_init(TRANSCEIVER_CC1100); transceiver_init(TRANSCEIVER_CC1100);
transceiver_pid = transceiver_start(); transceiver_start();
transceiver_register(TRANSCEIVER_CC1100, radio_pid); transceiver_register(TRANSCEIVER_CC1100, radio_pid);
while (1) { while (1) {

View File

@ -57,7 +57,8 @@ typedef struct {
void *data; void *data;
} transceiver_command_t;; } transceiver_command_t;;
extern void *transceiver_rx_buffer; /* The transceiver thread's pid */
extern int transceiver_pid;
/** /**
* @brief Initializes the transceiver module for certain transceiver types * @brief Initializes the transceiver module for certain transceiver types

View File

@ -63,6 +63,24 @@ void _cc1100_ng_send_handler(char *pkt) {
printf("[cc1100] Packet sent: %lu\n", response); printf("[cc1100] Packet sent: %lu\n", response);
} }
else { else {
puts("Usage:\ttsnd <ADDR> <MSG>"); puts("Usage:\ttxtsnd <ADDR> <MSG>");
} }
} }
void _cc1100_ng_monitor_handler(char *mode) {
unsigned int m;
tcmd.transceivers = TRANSCEIVER_CC1100;
tcmd.data = &m;
mesg.content.ptr = (char*) &tcmd;
if (sscanf(mode, "monitor %u", &m) == 1) {
printf("Setting monitor mode: %u\n", m);
mesg.type = SET_MONITOR;
msg_send(&mesg, transceiver_pid, 1);
}
else {
puts("Usage:\nmonitor <MODE>");
}
}

View File

@ -31,6 +31,7 @@ extern void _cc1100_set_address_handler(char *ptr);
extern void _cc1100_ng_get_set_address_handler(char *addr); extern void _cc1100_ng_get_set_address_handler(char *addr);
extern void _cc1100_ng_get_set_channel_handler(char *chan); extern void _cc1100_ng_get_set_channel_handler(char *chan);
extern void _cc1100_ng_send_handler(char *pkt); extern void _cc1100_ng_send_handler(char *pkt);
extern void _cc1100_ng_monitor_handler(char *mode);
#endif #endif
#endif #endif
@ -60,6 +61,7 @@ const shell_command_t _shell_command_list[] = {
{"addr", "Gets or sets the address for the CC1100 transceiver", _cc1100_ng_get_set_address_handler}, {"addr", "Gets or sets the address for the CC1100 transceiver", _cc1100_ng_get_set_address_handler},
{"chan", "Gets or sets the channel for the CC1100 transceiver", _cc1100_ng_get_set_channel_handler}, {"chan", "Gets or sets the channel for the CC1100 transceiver", _cc1100_ng_get_set_channel_handler},
{"txtsnd", "Sends a text message to a given node via the CC1100 transceiver", _cc1100_ng_send_handler}, {"txtsnd", "Sends a text message to a given node via the CC1100 transceiver", _cc1100_ng_send_handler},
{"monitor", "Enables or disables address checking for the CC1100 transceiver", _cc1100_ng_monitor_handler},
#endif #endif
#endif #endif
{NULL, NULL, NULL} {NULL, NULL, NULL}

View File

@ -35,6 +35,8 @@ uint8_t data_buffer[TRANSCEIVER_BUFFER_SIZE * PAYLOAD_SIZE];
uint32_t response; ///< response bytes for messages to upper layer threads uint32_t response; ///< response bytes for messages to upper layer threads
int transceiver_pid; ///< the transceiver thread's pid
static volatile uint8_t rx_buffer_pos = 0; static volatile uint8_t rx_buffer_pos = 0;
static volatile uint8_t transceiver_buffer_pos = 0; static volatile uint8_t transceiver_buffer_pos = 0;
@ -71,15 +73,15 @@ void transceiver_init(transceiver_type_t t) {
/* Start the transceiver thread */ /* Start the transceiver thread */
int transceiver_start(void) { int transceiver_start(void) {
int pid = thread_create(transceiver_stack, TRANSCEIVER_STACK_SIZE, PRIORITY_MAIN-3, CREATE_STACKTEST, run, "Transceiver"); transceiver_pid = thread_create(transceiver_stack, TRANSCEIVER_STACK_SIZE, PRIORITY_MAIN-3, CREATE_STACKTEST, run, "Transceiver");
if (pid < 0) { if (transceiver_pid < 0) {
puts("Error creating transceiver thread"); puts("Error creating transceiver thread");
} }
else if (transceivers & TRANSCEIVER_CC1100) { else if (transceivers & TRANSCEIVER_CC1100) {
DEBUG("Transceiver started for CC1100\n"); DEBUG("Transceiver started for CC1100\n");
cc1100_init(pid); cc1100_init(transceiver_pid);
} }
return pid; return transceiver_pid;
} }
/* Register an upper layer thread */ /* Register an upper layer thread */