1
0
mirror of https://github.com/RIOT-OS/RIOT.git synced 2025-01-17 09:32:44 +01:00

examples: use astyle to adopt current code style guide

This commit is contained in:
Christian Mehlis 2014-01-25 11:22:09 +01:00
parent fbcbd7ff1f
commit f00693255b
7 changed files with 69 additions and 38 deletions

View File

@ -157,23 +157,29 @@ static void riot_ccn_relay_start(char *str)
char *toc_str = strtok(str, " ");
toc_str = strtok(NULL, " ");
if (!toc_str) {
shell_max_cache_entries = CCNL_DEFAULT_MAX_CACHE_ENTRIES;
} else {
}
else {
shell_max_cache_entries = atoi(toc_str);
}
toc_str = strtok(NULL, " ");
if (!toc_str) {
shell_threshold_prefix = CCNL_DEFAULT_THRESHOLD_PREFIX;
} else {
}
else {
shell_threshold_prefix = atoi(toc_str);
}
toc_str = strtok(NULL, " ");
if (!toc_str) {
shell_threshold_aggregate = CCNL_DEFAULT_THRESHOLD_AGGREGATE;
} else {
}
else {
shell_threshold_aggregate = atoi(toc_str);
}

View File

@ -33,7 +33,8 @@
char radio_stack_buffer[RADIO_STACK_SIZE];
msg_t msg_q[RCV_BUFFER_SIZE];
void radio(void) {
void radio(void)
{
msg_t m;
radio_packet_t *p;
radio_packet_length_t i;
@ -42,6 +43,7 @@ void radio(void) {
while (1) {
msg_receive(&m);
if (m.type == PKT_PENDING) {
p = (radio_packet_t *) m.content.ptr;
printf("Got radio packet:\n");
@ -54,6 +56,7 @@ void radio(void) {
for (i = 0; i < p->length; i++) {
printf("%02X ", p->data[i]);
}
p->processing--;
puts("\n");
}
@ -102,17 +105,20 @@ void init_transceiver(void)
}
#endif /* MODULE_TRANSCEIVER */
static int shell_readc(void) {
static int shell_readc(void)
{
char c = 0;
(void) posix_read(uart0_handler_pid, &c, 1);
return c;
}
static void shell_putchar(int c) {
static void shell_putchar(int c)
{
(void) putchar(c);
}
int main(void) {
int main(void)
{
shell_t shell;
(void) posix_open(uart0_handler_pid, 0);

View File

@ -3,7 +3,8 @@
#include <msg.h>
#include <kernel.h>
void second_thread(void) {
void second_thread(void)
{
printf("second_thread starting.\n");
msg_t m;
@ -23,7 +24,9 @@ int main(void)
msg_t m;
int pid = thread_create(second_thread_stack, sizeof(second_thread_stack), PRIORITY_MAIN-1, CREATE_WOUT_YIELD | CREATE_STACKTEST, second_thread, "pong");
int pid = thread_create(second_thread_stack, sizeof(second_thread_stack),
PRIORITY_MAIN - 1, CREATE_WOUT_YIELD | CREATE_STACKTEST,
second_thread, "pong");
m.content.value = 1;

View File

@ -52,6 +52,7 @@ void rpl_udp_monitor(void)
while (1) {
msg_receive(&m);
if (m.type == PKT_PENDING) {
p = (radio_packet_t *) m.content.ptr;
@ -65,6 +66,7 @@ void rpl_udp_monitor(void)
for (uint8_t i = 0; i < p->length; i++) {
DEBUG("%02X ", p->data[i]);
}
p->processing--;
DEBUG("\n");
}
@ -72,6 +74,7 @@ void rpl_udp_monitor(void)
ipv6_buf = (ipv6_hdr_t *) m.content.ptr;
printf("IPv6 datagram received (next header: %02X)", ipv6_buf->nextheader);
printf(" from %s ", ipv6_addr_to_str(addr_str, &ipv6_buf->srcaddr));
if (ipv6_buf->nextheader == IPV6_PROTO_NUM_ICMPV6) {
icmpv6_buf = (icmpv6_hdr_t *) &ipv6_buf[(LL_HDR_LEN + IPV6_HDR_LEN) + ipv6_ext_hdr_len];
icmp_type = icmpv6_buf->type;
@ -82,6 +85,7 @@ void rpl_udp_monitor(void)
DEBUG("\t ICMP type: %02X ", icmp_type);
DEBUG("\t ICMP code: %02X ", icmp_code);
}
printf("\n");
}
else if (m.type == ENOBUFFER) {
@ -95,8 +99,10 @@ void rpl_udp_monitor(void)
transceiver_command_t tcmd;
void rpl_udp_ignore(char *addr) {
void rpl_udp_ignore(char *addr)
{
uint16_t a;
if (transceiver_pid < 0) {
puts("Transceiver not runnning.");
return;
@ -109,6 +115,7 @@ void rpl_udp_ignore(char *addr) {
tcmd.transceivers = TRANSCEIVER_CC1100;
tcmd.data = &a;
a = atoi(addr + strlen("ign "));
if (strlen(addr) > strlen("ign ")) {
printf("sending to transceiver (%u): %u\n", transceiver_pid, (*(uint8_t *)tcmd.data));
msg_send(&mesg, transceiver_pid, 1);

View File

@ -28,18 +28,21 @@ void rpl_udp_init(char *str)
char *toc_str = strtok(str, " ");
toc_str = strtok(NULL, " ");
if (!toc_str) {
printf("Usage: init (r|n)\n");
printf("\tr\tinitialize as root\n");
printf("\tn\tinitialize as node router\n");
return;
}
char command = *toc_str;
uint8_t state;
if ((command == 'n') || (command == 'r')) {
printf("INFO: Initialize as %s on address %d\n", ((command == 'n') ? "node" : "root"), id);
if (!id || (id > 255)) {
printf("ERROR: address not a valid 8 bit integer\n");
return;
@ -61,6 +64,7 @@ void rpl_udp_init(char *str)
else {
ipv6_iface_set_routing_provider(rpl_get_next_hop);
}
int monitor_pid = thread_create(monitor_stack_buffer, MONITOR_STACK_SIZE, PRIORITY_MAIN - 2, CREATE_STACKTEST, rpl_udp_monitor, "monitor");
transceiver_register(TRANSCEIVER, monitor_pid);
ipv6_register_packet_handler(monitor_pid);
@ -110,11 +114,13 @@ void rpl_udp_loop(char *unused)
printf("---------------------------\n");
printf("OUTPUT\n");
printf("my rank: %d\n", mydodag->my_rank);
if (!is_root) {
printf("my preferred parent:\n");
printf("%s\n", ipv6_addr_to_str(addr_str, (&mydodag->my_preferred_parent->addr)));
printf("parent lifetime: %d\n", mydodag->my_preferred_parent->lifetime);
}
printf("---------------------------$\n");
for (int i = 0; i < RPL_MAX_ROUTING_ENTRIES; i++) {
@ -177,9 +183,11 @@ void rpl_udp_dodag(char *unused)
printf("Part of Dodag:\n");
printf("%s\n", ipv6_addr_to_str(addr_str, (&mydodag->dodag_id)));
printf("my rank: %d\n", mydodag->my_rank);
if (!is_root) {
printf("my preferred parent:\n");
printf("%s\n", ipv6_addr_to_str(addr_str, (&mydodag->my_preferred_parent->addr)));
}
printf("---------------------------\n");
}

View File

@ -71,6 +71,7 @@ void udp_send(char *str)
int bytes_sent;
int address;
char text[5];
if (sscanf(str, "send %i %s", &address, text) < 2) {
printf("usage: send <addr> <text>\n");
return;