Merge pull request #2159 from posjodin/PR3

avr-rss2 platform fixes
contiki
Nicolas Tsiftes 2017-03-30 16:30:46 +02:00 committed by GitHub
commit 69c2e7e2b6
12 changed files with 55 additions and 284 deletions

View File

@ -1291,6 +1291,21 @@ rf230_listen_channel(uint8_t c)
radio_set_trx_state(RX_ON);
}
/*---------------------------------------------------------------------------*/
unsigned
rf230_get_panid(void)
{
unsigned pan;
uint8_t byte;
byte = hal_register_read(RG_PAN_ID_1);
pan = byte;
byte = hal_register_read(RG_PAN_ID_0);
pan = (pan << 8) + byte;
return pan;
}
void
rf230_set_pan_addr(unsigned pan,
unsigned addr,

View File

@ -215,6 +215,7 @@ void rf230_set_channel(uint8_t channel);
void rf230_listen_channel(uint8_t channel);
uint8_t rf230_get_channel(void);
void rf230_set_pan_addr(unsigned pan,unsigned addr,const uint8_t ieee_addr[8]);
unsigned rf230_get_panid(void);
void rf230_set_txpower(uint8_t power);
uint8_t rf230_get_txpower(void);
void rf230_set_rpc(uint8_t rpc);

View File

@ -110,14 +110,6 @@ Tested applications and examples
* `examples/powertrace`
* `example-shell`
Note that the shell example needs file `symbols.c` to be added to project also seems like
in `core/dev/serial-line.c` the function `process_poll` must be replaced with `process_post`:
/* Wake up consumer process */
- process_poll(&serial_line_process);
+ process_post(&serial_line_process, 0, 0);
Platform tutorial applications
-----------------------------
Example to read out various sensors, leds, serial numbers, and so on:

View File

@ -1,11 +0,0 @@
DEFINES+=PROJECT_CONF_H=\"project-conf.h\"
PROJECT_SOURCEFILES += stub-rdc.c
CONTIKI_PROJECT = sniffer
all: $(CONTIKI_PROJECT)
CONTIKI = ../../../..
CONTIKI_WITH_RIME = 1
include $(CONTIKI)/Makefile.include

View File

@ -1,29 +0,0 @@
Sniffer application mote side
=============================
This put the radio in sniff mode and should capure all traffic used
on the set channel.
Default channel
---------------
26
Bulld
-----
make TARGET=avr-rss2
Default serial port speed
-------------------------
38400 bps
More info & uasage
------------------
Look in the host directory
Contiki support
---------------
The code promisc for support is needed. This also adds the sensniff
format.
References
----------
https://github.com/g-oikonomou/sensniff

View File

@ -1,51 +0,0 @@
/*
* Copyright (c) 2010, Loughborough University - Computer Science
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
* 3. Neither the name of the Institute nor the names of its contributors
* may be used to endorse or promote products derived from this software
* without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE INSTITUTE AND CONTRIBUTORS ``AS IS'' AND
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
* ARE DISCLAIMED. IN NO EVENT SHALL THE INSTITUTE OR CONTRIBUTORS BE LIABLE
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
*
* This file is part of the Contiki operating system.
*/
/**
* \file
* Project specific configuration defines for the sniffer example.
*
* \author
* George Oikonomou - <oikonomou@users.sourceforge.net>
* Robert Olsson - <robert@radio.sensors.com>
*/
#ifndef PROJECT_CONF_H_
#define PROJECT_CONF_H_
#define NETSTACK_CONF_MAC nullmac_driver
/* Can see other channels. Interesting. */
/* #define NETSTACK_CONF_MAC csma_driver */
#define NETSTACK_CONF_RDC stub_rdc_driver
#endif /* PROJECT_CONF_H_ */

View File

@ -1,67 +0,0 @@
/*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
* 3. Neither the name of the Institute nor the names of its contributors
* may be used to endorse or promote products derived from this software
* without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE INSTITUTE AND CONTRIBUTORS ``AS IS'' AND
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
* ARE DISCLAIMED. IN NO EVENT SHALL THE INSTITUTE OR CONTRIBUTORS BE LIABLE
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
*
* This file is part of the Contiki operating system.
*
*/
/*
Author: Robert Olsson <robert@radio-sensors.com>
*/
#include "contiki.h"
#include "net/rime/rime.h"
#include "random.h"
#include "dev/button-sensor.h"
#include "dev/leds.h"
#include <stdio.h>
/*---------------------------------------------------------------------------*/
PROCESS(sniffer_process, "Sniffer process");
AUTOSTART_PROCESSES(&sniffer_process);
/*---------------------------------------------------------------------------*/
PROCESS_THREAD(sniffer_process, ev, data)
{
PROCESS_BEGIN();
/*
To get rf230bb radio in sniff mode we need to have radio in RX_ON.
The promisc commands fixes this for us. No need to set PAN and
address or MAC to zero is this case. Se Atmel datasheet. There is
a chance other radios works the same way.
*/
rf230_set_promiscuous_mode(1);
printf("Sniffer started\n");
while(1) {
PROCESS_YIELD();
}
PROCESS_END();
}
/*---------------------------------------------------------------------------*/

View File

@ -1,100 +0,0 @@
/*
* Copyright (c) 2010, Loughborough University - Computer Science
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
* 3. Neither the name of the Institute nor the names of its contributors
* may be used to endorse or promote products derived from this software
* without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE INSTITUTE AND CONTRIBUTORS ``AS IS'' AND
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
* ARE DISCLAIMED. IN NO EVENT SHALL THE INSTITUTE OR CONTRIBUTORS BE LIABLE
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
*
* This file is part of the Contiki operating system.
*/
/**
* \file
* Definition of a fake RDC driver to be used with passive
* examples. The sniffer will never send packets and it will never
* push incoming packets up the stack. We do this by defining this
* driver as our RDC. We then drop everything
*
* \author
* George Oikonomou - <oikonomou@users.sourceforge.net>
*/
#include "net/mac/mac.h"
#include "net/mac/rdc.h"
/*---------------------------------------------------------------------------*/
static void
send(mac_callback_t sent, void *ptr)
{
if(sent) {
sent(ptr, MAC_TX_OK, 1);
}
}
/*---------------------------------------------------------------------------*/
static void
send_list(mac_callback_t sent, void *ptr, struct rdc_buf_list *list)
{
if(sent) {
sent(ptr, MAC_TX_OK, 1);
}
}
/*---------------------------------------------------------------------------*/
static void
input(void)
{
}
/*---------------------------------------------------------------------------*/
static int
on(void)
{
return 1;
}
/*---------------------------------------------------------------------------*/
static int
off(int keep_radio_on)
{
return keep_radio_on;
}
/*---------------------------------------------------------------------------*/
static unsigned short
cca(void)
{
return 0;
}
/*---------------------------------------------------------------------------*/
static void
init(void)
{
}
/*---------------------------------------------------------------------------*/
const struct rdc_driver stub_rdc_driver = {
"stub-rdc",
init,
send,
send_list,
input,
on,
off,
cca,
};
/*---------------------------------------------------------------------------*/

View File

@ -78,10 +78,6 @@
#define NETSTACK_CONF_RADIO rf230_driver
#endif
#ifndef CHANNEL_802_15_4
#define CHANNEL_802_15_4 26
#endif
/* AUTOACK receive mode gives better rssi measurements, even if ACK is never requested */
#ifndef RF230_CONF_AUTOACK
#define RF230_CONF_AUTOACK 1
@ -110,6 +106,11 @@ void clock_adjust_ticks(clock_time_t howmany);
#define AVR_CONF_USE32KCRYSTAL 1
#define SLIP_PORT RS232_PORT_0
/* Default baud rare on RS232 port */
#ifndef RS232_BAUDRATE
#define RS232_BAUDRATE USART_BAUD_38400
#endif
/* Pre-allocated memory for loadable modules heap space (in bytes)*/
/* Default is 4096. Currently used only when elfloader is present. Not tested on Raven */
/* #define MMEM_CONF_SIZE 256 */
@ -164,6 +165,16 @@ typedef unsigned short uip_stats_t;
#define RDC_CONF_MCU_SLEEP 1
#if NETSTACK_CONF_WITH_IPV6
#ifndef NBR_TABLE_CONF_MAX_NEIGHBORS
#define NBR_TABLE_CONF_MAX_NEIGHBORS 20
#endif
#ifndef UIP_CONF_MAX_ROUTES
#define UIP_CONF_MAX_ROUTES 20
#endif
#ifndef UIP_CONF_BUFFER_SIZE
#define UIP_CONF_BUFFER_SIZE 1280
#endif
#define LINKADDR_CONF_SIZE 8
#define UIP_CONF_ICMP6 1
#define UIP_CONF_UDP 1
@ -229,16 +240,15 @@ typedef unsigned short uip_stats_t;
/* from previous GETs, causing decreased throughput, retransmissions, and timeouts. Increase to study this. */
/* ACKs to other ports become interleaved with computation-intensive GETs, so ACKs are particularly missed. */
/* Increasing the number of packet receive buffers in RAM helps to keep ACKs from being lost */
#define UIP_CONF_MAX_CONNECTIONS 4
/* 2 bytes per TCP listening port */
#define UIP_CONF_MAX_LISTENPORTS 4
/* 25 bytes per UDP connection */
#define UIP_CONF_UDP_CONNS 10
/* See uip-ds6.h */
#define NBR_TABLE_CONF_MAX_NEIGHBORS 20
#define UIP_CONF_DS6_DEFRT_NBU 2
#define UIP_CONF_DS6_PREFIX_NBU 3
#define UIP_CONF_MAX_ROUTES 20
#define UIP_CONF_DS6_ADDR_NBU 3
#define UIP_CONF_DS6_MADDR_NBU 0
#define UIP_CONF_DS6_AADDR_NBU 0
@ -270,10 +280,8 @@ typedef unsigned short uip_stats_t;
#define UIP_CONF_MAX_CONNECTIONS 2
#define UIP_CONF_MAX_LISTENPORTS 4
#define UIP_CONF_UDP_CONNS 5
#define NBR_TABLE_CONF_MAX_NEIGHBORS 20
#define UIP_CONF_DS6_DEFRT_NBU 2
#define UIP_CONF_DS6_PREFIX_NBU 3
#define UIP_CONF_MAX_ROUTES 4
#define UIP_CONF_DS6_ADDR_NBU 3
#define UIP_CONF_DS6_MADDR_NBU 0
#define UIP_CONF_DS6_AADDR_NBU 0
@ -299,10 +307,8 @@ typedef unsigned short uip_stats_t;
#define UIP_CONF_MAX_CONNECTIONS 2
#define UIP_CONF_MAX_LISTENPORTS 4
#define UIP_CONF_UDP_CONNS 5
#define NBR_TABLE_CONF_MAX_NEIGHBORS 4
#define UIP_CONF_DS6_DEFRT_NBU 2
#define UIP_CONF_DS6_PREFIX_NBU 3
#define UIP_CONF_MAX_ROUTES 4
#define UIP_CONF_DS6_ADDR_NBU 3
#define UIP_CONF_DS6_MADDR_NBU 0
#define UIP_CONF_DS6_AADDR_NBU 0
@ -332,7 +338,6 @@ typedef unsigned short uip_stats_t;
/* For slow slip connections, to prevent buffer overruns */
/* #define UIP_CONF_RECEIVE_WINDOW 300 */
#undef UIP_CONF_FWCACHE_SIZE
#define UIP_CONF_BUFFER_SIZE 600 /* DHCPv4 packets by ip64 module */
#define UIP_CONF_FWCACHE_SIZE 30
#define UIP_CONF_BROADCAST 1
#define UIP_ARCH_IPCHKSUM 1

View File

@ -186,9 +186,8 @@ initialize(void)
watchdog_init();
watchdog_start();
leds_init();
serial_line_init();
rs232_init(RS232_PORT_0, USART_BAUD_38400, USART_PARITY_NONE | USART_STOP_BITS_1 | USART_DATA_BITS_8);
rs232_init(RS232_PORT_0, RS232_BAUDRATE, USART_PARITY_NONE | USART_STOP_BITS_1 | USART_DATA_BITS_8);
rs232_redirect_stdout(RS232_PORT_0);
#if 0
@ -198,8 +197,6 @@ initialize(void)
//UBRR0L = 3; UBRR0H = 0; UCSR0A = (1 << U2X0); // 500k 0%
#endif
rs232_set_input(RS232_PORT_0, serial_line_input_byte);
clock_init();
if(MCUSR & (1 << PORF)) {
@ -271,6 +268,10 @@ initialize(void)
process_start(&etimer_process, NULL);
ctimer_init();
/* After process start */
serial_line_init();
rs232_set_input(RS232_PORT_0, serial_line_input_byte);
/* Start radio and radio receive process */
NETSTACK_RADIO.init();
@ -314,8 +315,18 @@ initialize(void)
memcpy(&uip_lladdr.addr, &addr.u8, sizeof(linkaddr_t));
#endif
#ifdef IEEE802154_CONF_PANID
rf230_set_pan_addr(IEEE802154_CONF_PANID, params_get_panaddr(), (uint8_t *)&addr.u8);
#else
rf230_set_pan_addr(params_get_panid(), params_get_panaddr(), (uint8_t *)&addr.u8);
#endif
#ifdef CHANNEL_CONF_802_15_4
rf230_set_channel(CHANNEL_CONF_802_15_4);
#else
rf230_set_channel(params_get_channel());
#endif
rf230_set_txpower(params_get_txpower());
#if NETSTACK_CONF_WITH_IPV6
@ -339,8 +350,8 @@ initialize(void)
NETSTACK_NETWORK.init();
#if ANNOUNCE_BOOT
PRINTA("MAC=%s, RDC=%s, NETWORK=%s, channel=%-u, check-rate-Hz=%-u, tx-power=%-u\n", NETSTACK_MAC.name,
NETSTACK_RDC.name, NETSTACK_NETWORK.name, rf230_get_channel(),
PRINTA("PAN=0x%X, MAC=%s, RDC=%s, NETWORK=%s, channel=%-u, check-rate-Hz=%-u, tx-power=%-u\n", rf230_get_panid(),
NETSTACK_MAC.name, NETSTACK_RDC.name, NETSTACK_NETWORK.name, rf230_get_channel(),
CLOCK_SECOND / (NETSTACK_RDC.channel_check_interval() == 0 ? 1 : NETSTACK_RDC.channel_check_interval()),
rf230_get_txpower());
#if UIP_CONF_IPV6_RPL
@ -349,7 +360,6 @@ initialize(void)
#if UIP_CONF_ROUTER
PRINTA("Routing Enabled\n");
#endif
#endif /* ANNOUNCE_BOOT */
#if NETSTACK_CONF_WITH_IPV6 || NETSTACK_CONF_WITH_IPV4

View File

@ -33,6 +33,12 @@ leds_off(unsigned char ledv)
void
leds_toggle(unsigned char ledv)
{
if(ledv & LEDS_YELLOW) {
PORTE ^= (1 << LED_YELLOW);
}
if(ledv & LEDS_RED) {
PORTE ^= (1 << LED_RED);
}
}
void
leds_invert(unsigned char ledv)