1
0
mirror of https://github.com/RIOT-OS/RIOT.git synced 2025-12-25 14:33:52 +01:00

[drivers/cc110x_ng projects/test_cc110x_ng sys/transceiver]

* fixed length handling
 * more sophisticated sending function in userapp
This commit is contained in:
Oliver Hahm 2010-11-26 17:06:54 +01:00
parent 1956603065
commit e6752c739b
5 changed files with 47 additions and 20 deletions

View File

@ -11,7 +11,6 @@
#include <board.h>
uint8_t cc1100_send(cc1100_packet_t *packet) {
puts("Going to send\n");
volatile uint32_t abort_count;
uint8_t size;
/* TODO: burst sending */

View File

@ -10,6 +10,8 @@
#define CC1100_MAX_DATA_LENGTH (58)
#define CC1100_HEADER_LENGTH (3) ///< Header covers SRC, DST and FLAGS
#define CC1100_BROADCAST_ADDRESS (0x00) ///< CC1100 broadcast address
#define MAX_UID (0xFF) ///< Maximum UID of a node is 255

View File

@ -1,4 +1,6 @@
#include <stdio.h>
#include <string.h>
#include <shell.h>
#include <board_uart0.h>
#include <posix_io.h>
@ -7,13 +9,16 @@
#include <hwtimer.h>
#include <msg.h>
#include <transceiver.h>
#include <cc1100_ng.h>
#define SHELL_STACK_SIZE (4096)
#define RADIO_STACK_SIZE (4096)
#define SHELL_STACK_SIZE (2048)
#define RADIO_STACK_SIZE (2048)
#define TEXT_SIZE CC1100_MAX_DATA_LENGTH
int transceiver_pid;
char shell_stack_buffer[SHELL_STACK_SIZE];
char radio_stack_buffer[RADIO_STACK_SIZE];
char text_msg[TEXT_SIZE];
void trans_chan(char *chan);
void trans_addr(char *addr);
@ -30,12 +35,12 @@ const shell_command_t sc[] = {
{NULL, NULL, NULL}};
void trans_chan(char *chan) {
int c;
int16_t c;
tcmd.transceivers = TRANSCEIVER_CC1100;
tcmd.data = &c;
mesg.content.ptr = (char*) &tcmd;
if (sscanf(chan, "tchan %i", &c) > 0) {
if (sscanf(chan, "tchan %hi", &c) > 0) {
printf("Trying to set channel %i\n", c);
mesg.type = SET_CHANNEL;
}
@ -47,12 +52,12 @@ void trans_chan(char *chan) {
}
void trans_addr(char *addr) {
int a;
int16_t a;
tcmd.transceivers = TRANSCEIVER_CC1100;
tcmd.data = &a;
mesg.content.ptr = (char*) &tcmd;
if (sscanf(addr, "taddr %i", &a) > 0) {
if (sscanf(addr, "taddr %hi", &a) > 0) {
printf("Trying to set address %i\n", a);
mesg.type = SET_ADDRESS;
}
@ -68,15 +73,22 @@ void trans_send(char *text) {
uint32_t response;
tcmd.transceivers = TRANSCEIVER_CC1100;
tcmd.data = &p;
uint16_t addr;
p.length = 10;
p.dst = 5;
mesg.type = SND_PKT;
mesg.content.ptr = (char*) &tcmd;
msg_send_receive(&mesg, &mesg, transceiver_pid);
response = mesg.content.value;
printf("Packet send: %lu\n", response);
if (sscanf(text, "tsnd %hu %s", &(addr), text_msg) == 2) {
p.data = (uint8_t*) text_msg;
p.length = strlen(text_msg);
p.dst = addr;
mesg.type = SND_PKT;
mesg.content.ptr = (char*) &tcmd;
printf("Sending packet of length %u to %hu: %s\n", p.length, p.dst, (char*) p.data);
msg_send_receive(&mesg, &mesg, transceiver_pid);
response = mesg.content.value;
printf("Packet send: %lu\n", response);
}
else {
puts("Usage:\ttsnd <ADDR> <MSG>");
}
}
void shell_runner(void) {
@ -87,10 +99,24 @@ void shell_runner(void) {
void radio(void) {
msg m;
radio_packet_t *p;
uint8_t i;
while (1) {
msg_receive(&m);
printf("Received message of type %i: %lX\n", m.type, m.content.value);
printf("Received message of type %i:\n", m.type);
if (m.type == PKT_PENDING) {
p = (radio_packet_t*) m.content.ptr;
printf("Packet waiting, process...\n");
printf("\tLength:\t%u\n", p->length);
printf("\tSrc:\t%u\n", p->src);
printf("\tDst:\t%u\n", p->dst);
for (i = 0; i < p->length; i++) {
printf("%02X ", p->data[i]);
}
printf("\n");
}
}
}

View File

@ -6,7 +6,7 @@
/* Packets to buffer */
#define TRANSCEIVER_BUFFER_SIZE (10)
/* Stack size for transceiver thread */
#define TRANSCEIVER_STACK_SIZE (4096)
#define TRANSCEIVER_STACK_SIZE (2048)
/* The maximum of threads to register */
#define TRANSCEIVER_MAX_REGISTERED (10)
@ -31,7 +31,7 @@ enum transceiver_msg_type_t {
SET_ADDRESS, ///< Set the radio address
/* Error messages */
ENOBUFFER,
ENOBUFFER, ///< No buffer left
};
/**

View File

@ -228,7 +228,7 @@ static void receive_cc1100_packet(radio_packet_t *trans_p) {
trans_p->dst = p.address;
trans_p->rssi = cc1100_rx_buffer[rx_buffer_pos].rssi;
trans_p->lqi = cc1100_rx_buffer[rx_buffer_pos].lqi;
trans_p->length = p.length;
trans_p->length = p.length - CC1100_HEADER_LENGTH;
memcpy((void*) &(data_buffer[transceiver_buffer_pos]), p.data, CC1100_MAX_DATA_LENGTH);
eINT();
@ -253,7 +253,7 @@ static uint8_t send_packet(transceiver_type_t t, void *pkt) {
switch (t) {
case TRANSCEIVER_CC1100:
/* TODO: prepare and send packet here */
cc1100_pkt.length = p.length;
cc1100_pkt.length = p.length + CC1100_HEADER_LENGTH;
cc1100_pkt.address = p.dst;
cc1100_pkt.flags = 0;
memcpy(cc1100_pkt.data, p.data, p.length);