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:
parent
413b2898ec
commit
54172b5c86
@ -14,25 +14,13 @@
|
||||
#define SHELL_STACK_SIZE (2048)
|
||||
#define RADIO_STACK_SIZE (2048)
|
||||
|
||||
int transceiver_pid;
|
||||
char shell_stack_buffer[SHELL_STACK_SIZE];
|
||||
char radio_stack_buffer[RADIO_STACK_SIZE];
|
||||
|
||||
void mon_handler(char *mode);
|
||||
|
||||
shell_t shell;
|
||||
const shell_command_t sc[] = {
|
||||
{"mon", "", mon_handler},
|
||||
{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) {
|
||||
shell_init(&shell, sc, uart0_readc, uart0_putc);
|
||||
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");
|
||||
radio_pid = thread_create(radio_stack_buffer, RADIO_STACK_SIZE, PRIORITY_MAIN-2, CREATE_STACKTEST, radio, "radio");
|
||||
transceiver_init(TRANSCEIVER_CC1100);
|
||||
transceiver_pid = transceiver_start();
|
||||
transceiver_start();
|
||||
transceiver_register(TRANSCEIVER_CC1100, radio_pid);
|
||||
|
||||
while (1) {
|
||||
|
@ -57,7 +57,8 @@ typedef struct {
|
||||
void *data;
|
||||
} 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
|
||||
|
@ -63,6 +63,24 @@ void _cc1100_ng_send_handler(char *pkt) {
|
||||
printf("[cc1100] Packet sent: %lu\n", response);
|
||||
}
|
||||
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>");
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
@ -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_channel_handler(char *chan);
|
||||
extern void _cc1100_ng_send_handler(char *pkt);
|
||||
extern void _cc1100_ng_monitor_handler(char *mode);
|
||||
#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},
|
||||
{"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},
|
||||
{"monitor", "Enables or disables address checking for the CC1100 transceiver", _cc1100_ng_monitor_handler},
|
||||
#endif
|
||||
#endif
|
||||
{NULL, NULL, NULL}
|
||||
|
@ -35,6 +35,8 @@ uint8_t data_buffer[TRANSCEIVER_BUFFER_SIZE * PAYLOAD_SIZE];
|
||||
|
||||
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 transceiver_buffer_pos = 0;
|
||||
|
||||
@ -71,15 +73,15 @@ void transceiver_init(transceiver_type_t t) {
|
||||
|
||||
/* Start the transceiver thread */
|
||||
int transceiver_start(void) {
|
||||
int pid = thread_create(transceiver_stack, TRANSCEIVER_STACK_SIZE, PRIORITY_MAIN-3, CREATE_STACKTEST, run, "Transceiver");
|
||||
if (pid < 0) {
|
||||
transceiver_pid = thread_create(transceiver_stack, TRANSCEIVER_STACK_SIZE, PRIORITY_MAIN-3, CREATE_STACKTEST, run, "Transceiver");
|
||||
if (transceiver_pid < 0) {
|
||||
puts("Error creating transceiver thread");
|
||||
}
|
||||
else if (transceivers & TRANSCEIVER_CC1100) {
|
||||
DEBUG("Transceiver started for CC1100\n");
|
||||
cc1100_init(pid);
|
||||
cc1100_init(transceiver_pid);
|
||||
}
|
||||
return pid;
|
||||
return transceiver_pid;
|
||||
}
|
||||
|
||||
/* Register an upper layer thread */
|
||||
|
Loading…
Reference in New Issue
Block a user