Merge branch 'master' of ssh://contiki.git.sourceforge.net/gitroot/contiki/contiki

This commit is contained in:
nvt 2012-02-11 02:14:20 +01:00
commit 9d8be775d4
12 changed files with 281 additions and 164 deletions

View File

@ -578,7 +578,7 @@ compress_hdr_hc06(rimeaddr_t *rime_destaddr)
/* Note that the payload length is always compressed */
/* Next header. We compress it if UDP */
#if UIP_CONF_UDP
#if UIP_CONF_UDP || UIP_CONF_ROUTER
if(UIP_IP_BUF->proto == UIP_PROTO_UDP) {
iphc0 |= SICSLOWPAN_IPHC_NH_C;
}
@ -700,7 +700,7 @@ compress_hdr_hc06(rimeaddr_t *rime_destaddr)
uncomp_hdr_len = UIP_IPH_LEN;
#if UIP_CONF_UDP
#if UIP_CONF_UDP || UIP_CONF_ROUTER
/* UDP header compression */
if(UIP_IP_BUF->proto == UIP_PROTO_UDP) {
PRINTF("IPHC: Uncompressed UDP ports on send side: %x, %x\n",

View File

@ -158,7 +158,8 @@ uip_ds6_periodic(void)
#if UIP_ND6_DEF_MAXDADNS > 0
} else if((locaddr->state == ADDR_TENTATIVE)
&& (locaddr->dadnscount <= uip_ds6_if.maxdadns)
&& (timer_expired(&locaddr->dadtimer))) {
&& (timer_expired(&locaddr->dadtimer))
&& (uip_len == 0)) {
uip_ds6_dad(locaddr);
#endif /* UIP_ND6_DEF_MAXDADNS > 0 */
}
@ -195,7 +196,7 @@ uip_ds6_periodic(void)
case NBR_INCOMPLETE:
if(locnbr->nscount >= UIP_ND6_MAX_MULTICAST_SOLICIT) {
uip_ds6_nbr_rm(locnbr);
} else if(stimer_expired(&locnbr->sendns)) {
} else if(stimer_expired(&locnbr->sendns) && (uip_len == 0)) {
locnbr->nscount++;
PRINTF("NBR_INCOMPLETE: NS %u\n", locnbr->nscount);
uip_nd6_ns_output(NULL, NULL, &locnbr->ipaddr);
@ -211,7 +212,7 @@ uip_ds6_periodic(void)
}
break;
case NBR_DELAY:
if(stimer_expired(&locnbr->reachable)) {
if(stimer_expired(&locnbr->reachable) && (uip_len == 0)) {
locnbr->state = NBR_PROBE;
locnbr->nscount = 1;
PRINTF("DELAY: moving to PROBE + NS %u\n", locnbr->nscount);
@ -226,7 +227,7 @@ uip_ds6_periodic(void)
uip_ds6_defrt_rm(locdefrt);
}
uip_ds6_nbr_rm(locnbr);
} else if(stimer_expired(&locnbr->sendns)) {
} else if(stimer_expired(&locnbr->sendns) && (uip_len == 0)) {
locnbr->nscount++;
PRINTF("PROBE: NS %u\n", locnbr->nscount);
uip_nd6_ns_output(NULL, &locnbr->ipaddr, &locnbr->ipaddr);
@ -241,7 +242,7 @@ uip_ds6_periodic(void)
#if UIP_CONF_ROUTER & UIP_ND6_SEND_RA
/* Periodic RA sending */
if(stimer_expired(&uip_ds6_timer_ra)) {
if(stimer_expired(&uip_ds6_timer_ra) && (uip_len == 0)) {
uip_ds6_send_ra_periodic();
}
#endif /* UIP_CONF_ROUTER & UIP_ND6_SEND_RA */

View File

@ -351,6 +351,11 @@ uip_nd6_ns_output(uip_ipaddr_t * src, uip_ipaddr_t * dest, uip_ipaddr_t * tgt)
} else {
uip_ds6_select_src(&UIP_IP_BUF->srcipaddr, &UIP_IP_BUF->destipaddr);
}
if (uip_is_addr_unspecified(&UIP_IP_BUF->srcipaddr)) {
PRINTF("Dropping NS due to no suitable source address\n");
uip_len = 0;
return;
}
UIP_IP_BUF->len[1] =
UIP_ICMPH_LEN + UIP_ND6_NS_LEN + UIP_ND6_OPT_LLAO_LEN;

View File

@ -345,7 +345,9 @@
#define RG_CSMA_BE 0x2f
/** Access parameters for sub-register MIN_BE in register @ref RG_CSMA_SEED_1 */
#define SR_MIN_BE 0x2e, 0xc0, 6
#define SR_reserved_2e_2 0x2e, 0x30, 4
/** Access parameters for AACK_SET_PD bit in register @ref RG_CSMA_SEED_1 */
#define SR_AACK_SET_PD 0x2e, 0x20, 5
//#define SR_reserved_2e_2 0x2e, 0x30, 4
/** Access parameters for sub-register I_AM_COORD in register @ref RG_CSMA_SEED_1 */
#define SR_I_AM_COORD 0x2e, 0x08, 3
/** Access parameters for sub-register CSMA_SEED_1 in register @ref RG_CSMA_SEED_1 */

View File

@ -410,6 +410,11 @@
#define HAL_TCCR1B_CONFIG ( ( 1 << ICES1 ) | ( 1 << CS11 ) | ( 1 << CS10 ) )
#define HAL_US_PER_SYMBOL ( 2 )
#define HAL_SYMBOL_MASK ( 0x7FFFffff )
//#elif ( F_CPU == 7953408UL )
#elif ( F_CPU == 7954432UL )
#define HAL_TCCR1B_CONFIG ( ( 1 << ICES1 ) | ( 1 << CS11 ) | ( 1 << CS10 ) )
#define HAL_US_PER_SYMBOL ( 2 )
#define HAL_SYMBOL_MASK ( 0x7FFFffff )
#elif ( F_CPU == 4000000UL )
#define HAL_TCCR1B_CONFIG ( ( 1 << ICES1 ) | ( 1 << CS11 ) | ( 1 << CS10 ) )
#define HAL_US_PER_SYMBOL ( 1 )

View File

@ -305,7 +305,8 @@ hal_rx_frame_t rxframe[RF230_CONF_RX_BUFFERS];
* \retval STATE_TRANSITION The radio transceiver's state machine is in
* transition between two states.
*/
static uint8_t
//static uint8_t
uint8_t
radio_get_trx_state(void)
{
return hal_subregister_read(SR_TRX_STATUS);
@ -506,8 +507,6 @@ flushrx(void)
rxframe[rxframe_head].length=0;
}
/*---------------------------------------------------------------------------*/
static uint8_t locked, lock_on, lock_off;
static void
on(void)
{
@ -581,19 +580,6 @@ off(void)
ENERGEST_OFF(ENERGEST_TYPE_LISTEN);
}
/*---------------------------------------------------------------------------*/
#define GET_LOCK() locked = 1
static void RELEASE_LOCK(void) {
if(lock_on) {
on();
lock_on = 0;
}
if(lock_off) {
off();
lock_off = 0;
}
locked = 0;
}
/*---------------------------------------------------------------------------*/
static void
set_txpower(uint8_t power)
{
@ -608,6 +594,11 @@ set_txpower(uint8_t power)
hal_subregister_write(SR_TX_PWR, power);
}
}
void rf230_setpendingbit(uint8_t value)
{
hal_subregister_write(SR_AACK_SET_PD, value);
}
#if 0
/*----------------------------------------------------------------------------*/
/**
\brief Calibrate the internal RC oscillator
@ -623,7 +614,6 @@ set_txpower(uint8_t power)
void
calibrate_rc_osc_32k(void)
{
#if 0
/* Calibrate RC Oscillator: The calibration routine is done by clocking TIMER2
* from the external 32kHz crystal while running an internal timer simultaneously.
@ -713,31 +703,18 @@ calibrate_rc_osc_32k(void)
// PRR0 |= (1 << PRTIM2);/* |(1 << PRTIM1); */
AVR_LEAVE_CRITICAL_REGION();
#endif
}
#endif
/*---------------------------------------------------------------------------*/
int
rf230_init(void)
{
uint8_t i;
DEBUGFLOW('i');
/* A jtag or brownout reset of the mcu tristates the RF230 control pins while
* it is in operation, which can result in a mulfunctioning condition when the
* radio is later re-initialized.
* This manifests as an incorrectly computed hardware FCS checksum.
* Setting up the pins before the poweron time delay seems to fix this.
*/
#if 1 //this works after a brownout or jtag reset
/* Initialize Hardware Abstraction Layer */
hal_init();
/* Wait in case VCC just applied */
delay_us(TIME_TO_ENTER_P_ON);
#else //this gives FCS errors 5 out of 6 times
/* Wait in case VCC just applied */
delay_us(TIME_TO_ENTER_P_ON);
/* Initialize Hardware Abstraction Layer */
hal_init();
#endif
/* Calibrate oscillator */
// printf_P(PSTR("\nBefore calibration OSCCAL=%x\n"),OSCCAL);
@ -751,7 +728,18 @@ rf230_init(void)
/* Do full rf230 Reset */
hal_set_rst_low();
hal_set_slptr_low();
#if 1
/* On powerup a TIME_RESET delay is needed here, however on some other MCU reset
* (JTAG, WDT, Brownout) the radio may be sleeping. It can enter an uncertain
* state (sending wrong hardware FCS for example) unless the full wakeup delay
* is done.
* Wake time depends on board capacitance; use 2x the nominal delay for safety.
* See www.avrfreaks.net/index.php?name=PNphpBB2&file=viewtopic&t=78725
*/
delay_us(2*TIME_SLEEP_TO_TRX_OFF);
#else
delay_us(TIME_RESET);
#endif
hal_set_rst_high();
/* Force transition to TRX_OFF */
@ -858,17 +846,11 @@ rf230_transmit(unsigned short payload_len)
{
int txpower;
uint8_t total_len;
uint8_t radiowason;
uint8_t tx_result;
#if RF230_CONF_TIMESTAMPS
struct timestamp timestamp;
#endif /* RF230_CONF_TIMESTAMPS */
GET_LOCK();
/* Save receiver state */
radiowason=RF230_receive_on;
/* If radio is sleeping we have to turn it on first */
/* This automatically does the PLL calibrations */
if (hal_get_slptr()) {
@ -954,7 +936,7 @@ rf230_transmit(unsigned short payload_len)
#if defined(__AVR_ATmega128RFA1__)
sei();
#endif
PRINTF("rf230_transmit:\n");
PRINTF("rf230_transmit: %d\n", (int)total_len);
#if DEBUG>1
/* Note the dumped packet will have a zero checksum unless compiled with RF230_CONF_CHECKSUM
* since we don't know what it will be if calculated by the hardware.
@ -979,7 +961,7 @@ rf230_transmit(unsigned short payload_len)
#if RF230_CONF_AUTORETRIES
tx_result = hal_subregister_read(SR_TRAC_STATUS);
#else
tx_result=0;
tx_result=RADIO_TX_OK;
#endif
#ifdef ENERGEST_CONF_LEVELDEVICE_LEVELS
@ -991,14 +973,6 @@ rf230_transmit(unsigned short payload_len)
set_txpower(txpower & 0xff);
}
/* Restore receive mode */
if(radiowason) {
DEBUGFLOW('l');
on();
} else {
off();
}
#if RF230_CONF_TIMESTAMPS
setup_time_for_transmission = txtime - timestamp.time;
@ -1012,24 +986,24 @@ rf230_transmit(unsigned short payload_len)
ENERGEST_OFF(ENERGEST_TYPE_TRANSMIT);
if(RF230_receive_on) {
DEBUGFLOW('l');
ENERGEST_ON(ENERGEST_TYPE_LISTEN);
on();
} else {
#if RADIOALWAYSON
/* Enable reception */
on();
#else
/* Go to lower power TRX_OFF state (turn off PLL) */
hal_subregister_write(SR_TRX_CMD, CMD_FORCE_TRX_OFF);
off();
PRINTF("rf230_transmit: turning radio off\n");
#endif
}
RELEASE_LOCK();
#if RF230_INSERTACK
ack_pending = 0;
#endif
if (tx_result==1) { //success, data pending from adressee
if (tx_result==1) { //success, data pending from addressee
tx_result=RADIO_TX_OK; //handle as ordinary success
}
@ -1051,6 +1025,7 @@ rf230_transmit(unsigned short payload_len)
} else if (tx_result==5) { //Expected ACK, none received
DEBUGFLOW('n');
tx_result = RADIO_TX_NOACK;
PRINTF("rf230_transmit: ACK not received\n");
RIMESTATS_ADD(badackrx); //ack was requested but not received
} else if (tx_result==7) { //Invalid (Can't happen since waited for idle above?)
DEBUGFLOW('o');
@ -1076,7 +1051,6 @@ rf230_prepare(const void *payload, unsigned short payload_len)
ack_seqnum=*(((uint8_t *)payload)+2);
#endif
GET_LOCK();
DEBUGFLOW('p');
// PRINTF("rf230: sending %d bytes\n", payload_len);
@ -1094,9 +1068,7 @@ rf230_prepare(const void *payload, unsigned short payload_len)
#if RADIOSTATS
RF230_sendfail++;
#endif
#if DEBUG
printf_P(PSTR("rf230_prepare: packet too large (%d, max: %d)\n"),total_len,RF230_MAX_TX_FRAME_LENGTH);
#endif
PRINTF("rf230_prepare: packet too large (%d, max: %d)\n",total_len,RF230_MAX_TX_FRAME_LENGTH);
ret = -1;
goto bail;
}
@ -1130,7 +1102,6 @@ rf230_prepare(const void *payload, unsigned short payload_len)
bail:
RELEASE_LOCK();
return ret;
}
/*---------------------------------------------------------------------------*/
@ -1146,9 +1117,7 @@ rf230_send(const void *payload, unsigned short payload_len)
#endif
if((ret=rf230_prepare(payload, payload_len))) {
#if DEBUG
printf_P(PSTR("rf230_send: Unable to send, prep failed (%d)\n"),ret);
#endif
PRINTF("rf230_send: Unable to send, prep failed (%d)\n",ret);
goto bail;
}
@ -1169,20 +1138,13 @@ rf230_off(void)
return 0;
}
/* If we are called when the driver is locked, we indicate that the
radio should be turned off when the lock is unlocked. */
if(locked) {
lock_off = 1;
return 1;
}
/* If we are currently receiving a packet
we don't actually switch the radio off now, but signal that the
driver should switch off the radio once the packet has been
received and processed, by setting the 'lock_off' variable. */
/* If we are currently receiving a packet, we still call off(),
as that routine waits until Rx is complete (packet uploaded in ISR
so no worries about losing it). If using RX_AACK_MODE, chances are
the packet is not for us and will be discarded. */
if (!rf230_isidle()) {
lock_off = 1;
return 1;
PRINTF("rf230_off: busy receiving\r\n");
//return 1;
}
off();
@ -1196,11 +1158,6 @@ rf230_on(void)
DEBUGFLOW('q');
return 1;
}
if(locked) {
lock_on = 1;
DEBUGFLOW('r');
return 1;
}
on();
return 1;
@ -1349,7 +1306,16 @@ PROCESS_THREAD(rf230_process, ev, data)
rf230_pending = 0;
packetbuf_clear();
/* Turn off interrupts to avoid ISR writing to the same buffers we are reading. */
HAL_ENTER_CRITICAL_REGION();
len = rf230_read(packetbuf_dataptr(), PACKETBUF_SIZE);
/* Restore interrupts. */
HAL_LEAVE_CRITICAL_REGION();
PRINTF("rf230_read: %u bytes lqi %u\n",len,rf230_last_correlation);
RF230PROCESSFLAG(1);
if(len > 0) {
packetbuf_set_datalen(len);
@ -1370,10 +1336,13 @@ PROCESS_THREAD(rf230_process, ev, data)
PROCESS_END();
}
/* Get packet from Radio if any, else return zero.
/* Read packet that was uploaded from Radio in ISR, else return zero.
* The two-byte checksum is appended but the returned length does not include it.
* Frames are buffered in the interrupt routine so this routine
* does not access the hardware or change its status.
* However, this routine must be called with interrupts disabled to avoid ISR
* writing to the same buffer we are reading.
* As a result, PRINTF cannot be used in here.
*/
/*---------------------------------------------------------------------------*/
static int
@ -1433,44 +1402,40 @@ if (!RF230_receive_on) {
rf230_time_of_departure = 0;
#endif /* RF230_CONF_TIMESTAMPS */
// can't use PRINTF as interrupts are disabled
// PRINTSHORT("r%d",rxframe[rxframe_head].length);
PRINTF("rf230_read: %u bytes lqi %u crc %u\n",rxframe[rxframe_head].length,rxframe[rxframe_head].lqi,rxframe[rxframe_head].crc);
//PRINTF("rf230_read: %u bytes lqi %u crc %u\n",rxframe[rxframe_head].length,rxframe[rxframe_head].lqi,rxframe[rxframe_head].crc);
#if DEBUG>1
{
uint8_t i;
PRINTF("0000");
for (i=0;i<rxframe[rxframe_head].length;i++) PRINTF(" %02x",rxframe[rxframe_head].data[i]);
PRINTF("\n");
//uint8_t i;
//PRINTF("0000");
//for (i=0;i<rxframe[rxframe_head].length;i++) PRINTF(" %02x",rxframe[rxframe_head].data[i]);
//PRINTF("\n");
}
#endif
// GET_LOCK();
//if(len > RF230_MAX_PACKET_LEN) {
if(len > RF230_MAX_TX_FRAME_LENGTH) {
/* Oops, we must be out of sync. */
DEBUGFLOW('u');
flushrx();
RIMESTATS_ADD(badsynch);
// RELEASE_LOCK();
return 0;
}
if(len <= AUX_LEN) {
DEBUGFLOW('s');
PRINTF("len <= AUX_LEN\n");
//PRINTF("len <= AUX_LEN\n");
flushrx();
RIMESTATS_ADD(tooshort);
// RELEASE_LOCK();
return 0;
}
if(len - AUX_LEN > bufsize) {
DEBUGFLOW('v');
PRINTF("len - AUX_LEN > bufsize\n");
//PRINTF("len - AUX_LEN > bufsize\n");
flushrx();
RIMESTATS_ADD(toolong);
// RELEASE_LOCK();
return 0;
}
/* Transfer the frame, stripping the footer, but copying the checksum */
@ -1500,8 +1465,8 @@ if (!RF230_receive_on) {
#if RF230_CONF_CHECKSUM
if(checksum != crc16_data(buf, len - AUX_LEN, 0)) {
DEBUGFLOW('w');
PRINTF("checksum failed 0x%04x != 0x%04x\n",
checksum, crc16_data(buf, len - AUX_LEN, 0));
//PRINTF("checksum failed 0x%04x != 0x%04x\n",
// checksum, crc16_data(buf, len - AUX_LEN, 0));
}
#if FOOTER_LEN
if(footer[1] & FOOTER1_CRC_OK &&
@ -1547,7 +1512,7 @@ if (!RF230_receive_on) {
#if FOOTER_LEN
} else {
DEBUGFLOW('x');
PRINTF("bad crc");
//PRINTF("bad crc");
RIMESTATS_ADD(badcrc);
len = AUX_LEN;
}
@ -1572,9 +1537,7 @@ if (!RF230_receive_on) {
void
rf230_set_txpower(uint8_t power)
{
GET_LOCK();
set_txpower(power);
RELEASE_LOCK();
}
/*---------------------------------------------------------------------------*/
uint8_t
@ -1632,17 +1595,6 @@ rf230_cca(void)
uint8_t cca=0;
uint8_t radio_was_off = 0;
/* If the radio is locked by an underlying thread (because we are
being invoked through an interrupt), we preted that the coast is
clear (i.e., no packet is currently being transmitted by a
neighbor). */
if(locked) {
DEBUGFLOW('|');
// return 1; rf230 hangs on occasion?
return 0;
}
/* Turn radio on if necessary. If radio is currently busy return busy channel */
/* This may happen when testing radio duty cycling with RADIOALWAYSON */
if(RF230_receive_on) {

View File

@ -88,6 +88,14 @@ ifdef WITH_UIP
CFLAGS += -DWITH_UIP=1
endif
## Copied from Makefile.include, since Cooja overrides CFLAGS et al
ifdef UIP_CONF_IPV6
CFLAGS += -DUIP_CONF_IPV6=1
ifneq ($(UIP_CONF_RPL),0)
CFLAGS += -DUIP_CONF_IPV6_RPL=1
endif # UIP_CONF_RPL
endif # UIP_CONF_IPV6
REDEF_PRINTF=1 # Redefine functions to enable printf()s inside Cooja
### Define custom targets

View File

@ -67,7 +67,7 @@ $1-makes:
$(MAKE) -C ../../examples/irc TARGET=$1
$(MAKE) -C ../../examples/email TARGET=$1
$(MAKE) -C ../../examples/ftp TARGET=$1
$(MAKE) -C ../../../../contikiprojects/vandenbrande.com/twitter/platform/$1
$(MAKE) -C ../../../contikiprojects/vandenbrande.com/twitter/platform/$1
endef
$(eval $(call makes,apple2enh))
@ -125,7 +125,7 @@ apple2enh-4-disk: apple2enh-makes
java -jar $(AC) -p contiki-4.dsk dhcp.system sys 0 < ../apple2enh/loader.system
java -jar $(AC) -cc65 contiki-4.dsk dhcp bin 0 < ../../cpu/6502/dhcp/dhcp-client.apple2enh
java -jar $(AC) -p contiki-4.dsk breadbox.system sys 0 < ../apple2enh/loader.system
java -jar $(AC) -cc65 contiki-4.dsk breadbox bin < ../../../../contikiprojects/vandenbrande.com/twitter/platform/apple2enh/breadbox64.apple2enh
java -jar $(AC) -cc65 contiki-4.dsk breadbox bin < ../../../contikiprojects/vandenbrande.com/twitter/platform/apple2enh/breadbox64.apple2enh
java -jar $(AC) -p contiki-4.dsk cs8900a.eth rel 0 < ../../cpu/6502/dhcp/cs8900a.eth
java -jar $(AC) -p contiki-4.dsk lan91c96.eth rel 0 < ../../cpu/6502/dhcp/lan91c96.eth
java -jar $(AC) -p contiki-4.dsk a2e.stdmou.mou rel 0 < $(CC65_HOME)/mou/a2e.stdmou.mou
@ -150,35 +150,35 @@ c64-1-disk: c64-makes
c64-2-disk: c64-makes
$(C1541) -format contiki,00 d64 contiki-2.d64
$(C1541) -attach contiki-2.d64 -write dummy.cfg contiki.cfg,u
$(C1541) -attach contiki-2.d64 -write ../../cpu/6502/dhcp/dhcp-client.c64 dhcp,p
$(C1541) -attach contiki-2.d64 -write ../../examples/email/email-client.c64 email,p
$(C1541) -attach contiki-2.d64 -write ../../examples/ftp/ftp-client.c64 ftp,p
$(C1541) -attach contiki-2.d64 -write ../../../../contikiprojects/vandenbrande.com/twitter/platform/c64/breadbox64.c64 breadbox64,p
$(C1541) -attach contiki-2.d64 -write ../../cpu/6502/dhcp/cs8900a.eth cs8900a.eth,u
$(C1541) -attach contiki-2.d64 -write ../../cpu/6502/dhcp/lan91c96.eth lan91c96.eth,u
$(C1541) -attach contiki-2.d64 -write $(CC65_HOME)/mou/c64-1351.mou c64-1351.mou,u
$(C1541) -attach contiki-2.d64 -write dummy.cfg contiki.cfg,u
$(C1541) -attach contiki-2.d64 -write ../../cpu/6502/dhcp/dhcp-client.c64 dhcp,p
$(C1541) -attach contiki-2.d64 -write ../../examples/email/email-client.c64 email,p
$(C1541) -attach contiki-2.d64 -write ../../examples/ftp/ftp-client.c64 ftp,p
$(C1541) -attach contiki-2.d64 -write ../../../contikiprojects/vandenbrande.com/twitter/platform/c64/breadbox64.c64 breadbox64,p
$(C1541) -attach contiki-2.d64 -write ../../cpu/6502/dhcp/cs8900a.eth cs8900a.eth,u
$(C1541) -attach contiki-2.d64 -write ../../cpu/6502/dhcp/lan91c96.eth lan91c96.eth,u
$(C1541) -attach contiki-2.d64 -write $(CC65_HOME)/mou/c64-1351.mou c64-1351.mou,u
$(eval $(call makes,c128))
c128-1-disk: c128-makes
$(C1541) -format contiki,00 d71 contiki-1.d71
$(C1541) -attach contiki-1.d71 -write dummy.cfg contiki.cfg,u
$(C1541) -attach contiki-1.d71 -write ../../cpu/6502/dhcp/dhcp-client.c128 dhcp,p
$(C1541) -attach contiki-1.d71 -write ../../examples/webserver/webserver-example.c128 webserver,p
$(C1541) -attach contiki-1.d71 -write ../../examples/webbrowser/webbrowser.c128 webbrowser,p
$(C1541) -attach contiki-1.d71 -write ../../examples/wget/wget.c128 wget,p
$(C1541) -attach contiki-1.d71 -write ../../examples/irc/irc-client.c128 irc,p
$(C1541) -attach contiki-1.d71 -write ../../examples/email/email-client.c128 email,p
$(C1541) -attach contiki-1.d71 -write ../../examples/ftp/ftp-client.c128 ftp,p
$(C1541) -attach contiki-1.d71 -write ../../../../contikiprojects/vandenbrande.com/twitter/platform/c128/breadbox64.c128 breadbox64,p
$(C1541) -attach contiki-1.d71 -write ../../cpu/6502/dhcp/cs8900a.eth cs8900a.eth,u
$(C1541) -attach contiki-1.d71 -write ../../cpu/6502/dhcp/lan91c96.eth lan91c96.eth,u
$(C1541) -attach contiki-1.d71 -write $(CC65_HOME)/mou/c128-1351.mou c128-1351.mou,u
$(C1541) -attach contiki-1.d71 -write ../../examples/webserver/httpd-cfs/index.htm index.htm,u
$(C1541) -attach contiki-1.d71 -write ../../examples/webserver/httpd-cfs/backgrnd.gif backgrnd.gif,u
$(C1541) -attach contiki-1.d71 -write ../../examples/webserver/httpd-cfs/contiki.gif contiki.gif,u
$(C1541) -attach contiki-1.d71 -write ../../examples/webserver/httpd-cfs/notfound.htm notfound.htm,u
$(C1541) -attach contiki-1.d71 -write dummy.cfg contiki.cfg,u
$(C1541) -attach contiki-1.d71 -write ../../cpu/6502/dhcp/dhcp-client.c128 dhcp,p
$(C1541) -attach contiki-1.d71 -write ../../examples/webserver/webserver-example.c128 webserver,p
$(C1541) -attach contiki-1.d71 -write ../../examples/webbrowser/webbrowser.c128 webbrowser,p
$(C1541) -attach contiki-1.d71 -write ../../examples/wget/wget.c128 wget,p
$(C1541) -attach contiki-1.d71 -write ../../examples/irc/irc-client.c128 irc,p
$(C1541) -attach contiki-1.d71 -write ../../examples/email/email-client.c128 email,p
$(C1541) -attach contiki-1.d71 -write ../../examples/ftp/ftp-client.c128 ftp,p
$(C1541) -attach contiki-1.d71 -write ../../../contikiprojects/vandenbrande.com/twitter/platform/c128/breadbox64.c128 breadbox64,p
$(C1541) -attach contiki-1.d71 -write ../../cpu/6502/dhcp/cs8900a.eth cs8900a.eth,u
$(C1541) -attach contiki-1.d71 -write ../../cpu/6502/dhcp/lan91c96.eth lan91c96.eth,u
$(C1541) -attach contiki-1.d71 -write $(CC65_HOME)/mou/c128-1351.mou c128-1351.mou,u
$(C1541) -attach contiki-1.d71 -write ../../examples/webserver/httpd-cfs/index.htm index.htm,u
$(C1541) -attach contiki-1.d71 -write ../../examples/webserver/httpd-cfs/backgrnd.gif backgrnd.gif,u
$(C1541) -attach contiki-1.d71 -write ../../examples/webserver/httpd-cfs/contiki.gif contiki.gif,u
$(C1541) -attach contiki-1.d71 -write ../../examples/webserver/httpd-cfs/notfound.htm notfound.htm,u
$(eval $(call makes,atari))
@ -221,10 +221,10 @@ atari-3-disk: atari-makes
atari-4-disk: atari-makes
mkdir -p atr
cp ../atari/dos.sys atr/dos.sys
cp ../atari/dup.sys atr/dup.sys
cp dummy.cfg atr/contiki.cfg
cp ../../cpu/6502/dhcp/dhcp-client.atari atr/dhcp.com
cp ../../../../contikiprojects/vandenbrande.com/twitter/platform/atari/breadbox64.atari atr/breadbox.com
cp ../atari/dos.sys atr/dos.sys
cp ../atari/dup.sys atr/dup.sys
cp dummy.cfg atr/contiki.cfg
cp ../../cpu/6502/dhcp/dhcp-client.atari atr/dhcp.com
cp ../../../contikiprojects/vandenbrande.com/twitter/platform/atari/breadbox64.atari atr/breadbox.com
$(DIR2ATR) -b Dos25 1040 contiki-4.atr atr
rm -r atr

View File

@ -1474,6 +1474,7 @@ public class CollectServer implements SerialConnectionListener {
boolean resetSensorLog = false;
boolean useSensorLog = true;
boolean useSerialOutput = true;
String host = null;
String command = null;
String logFileToLoad = null;
String comPort = null;
@ -1482,6 +1483,18 @@ public class CollectServer implements SerialConnectionListener {
String arg = args[i];
if (arg.length() == 2 && arg.charAt(0) == '-') {
switch (arg.charAt(1)) {
case 'a':
if (i + 1 < n) {
host = args[++i];
int pIndex = host.indexOf(':');
if (pIndex > 0) {
port = Integer.parseInt(host.substring(pIndex + 1));
host = host.substring(0, pIndex);
}
} else {
usage(arg);
}
break;
case 'c':
if (i + 1 < n) {
command = args[++i];
@ -1527,7 +1540,12 @@ public class CollectServer implements SerialConnectionListener {
CollectServer server = new CollectServer();
SerialConnection serialConnection;
if (port > 0) {
if (host != null) {
if (port <= 0) {
port = 60001;
}
serialConnection = new TCPClientConnection(server, host, port);
} else if (port > 0) {
serialConnection = new UDPConnection(server, port);
} else if (command == null) {
serialConnection = new SerialDumpConnection(server);
@ -1560,11 +1578,12 @@ public class CollectServer implements SerialConnectionListener {
if (arg != null) {
System.err.println("Unknown argument '" + arg + '\'');
}
System.err.println("Usage: java CollectServer [-n] [-i] [-r] [-f [file]] [-p port] [-c command] [COMPORT]");
System.err.println("Usage: java CollectServer [-n] [-i] [-r] [-f [file]] [-a host:port] [-p port] [-c command] [COMPORT]");
System.err.println(" -n : Do not read or save sensor data log");
System.err.println(" -r : Clear any existing sensor data log at startup");
System.err.println(" -i : Do not allow serial output");
System.err.println(" -f : Read serial data from standard in");
System.err.println(" -a : Connect to specified host:port");
System.err.println(" -p : Read data from specified UDP port");
System.err.println(" -c : Use specified command for serial data input/output");
System.err.println(" COMPORT: The serial port to connect to");

View File

@ -0,0 +1,130 @@
/*
* Copyright (c) 2012, Swedish Institute of 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.
*
* -----------------------------------------------------------------
*
* TCPClientConnection
*
* Authors : Niclas Finne
*/
package se.sics.contiki.collect;
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.PrintStream;
import java.net.Socket;
/**
*
*/
public class TCPClientConnection extends SerialConnection {
private final String host;
private final int port;
private Socket client;
private BufferedReader in;
private PrintStream out;
public TCPClientConnection(SerialConnectionListener listener, String host, int port) {
super(listener);
this.host = host;
this.port = port;
}
@Override
public String getConnectionName() {
return "<tcp://" + host + ':' + port + '>';
}
@Override
public void open(String comPort) {
close();
this.comPort = comPort == null ? "" : comPort;
isClosed = false;
try {
client = new Socket(host, port);
in = new BufferedReader(new InputStreamReader(client.getInputStream()));
out = new PrintStream(client.getOutputStream());
System.out.println("Opened TCP connection to " + host + ':' + port);
/* Start thread listening on UDP */
Thread readInput = new Thread(new Runnable() {
public void run() {
try {
String line;
while (isOpen && (line = in.readLine()) != null) {
serialData(line);
}
} catch (IOException e) {
lastError = "Error when reading from SerialConnection TCP: " + e;
System.err.println(lastError);
if (!isClosed) {
e.printStackTrace();
closeConnection();
}
} finally {
System.out.println("SerialConnection TCP terminated.");
closeConnection();
}
}
}, "TCP thread");
isOpen = true;
serialOpened();
readInput.start();
} catch (Exception e) {
lastError = "Failed to open TCP connection to " + host + ':' + port + ": " + e;
System.err.println(lastError);
e.printStackTrace();
closeConnection();
}
}
@Override
protected void doClose() {
try {
if (in != null) {
in.close();
in = null;
}
if (out != null) {
out.close();
out = null;
}
if (client != null) {
client.close();
client = null;
}
} catch (IOException e) {
e.printStackTrace();
}
}
}

View File

@ -1,8 +1,5 @@
<?xml version="1.0" encoding="UTF-8"?>
<simconf>
<project>[CONTIKI_DIR]/tools/cooja/apps/mrm</project>
<project>[CONTIKI_DIR]/tools/cooja/apps/mspsim</project>
<project>[CONTIKI_DIR]/tools/cooja/apps/avrora</project>
<simulation>
<title>My simulation</title>
<delaytime>0</delaytime>
@ -22,8 +19,8 @@
se.sics.cooja.mspmote.SkyMoteType
<identifier>sky1</identifier>
<description>Sky Mote Type #sky1</description>
<source>[CONTIKI_DIR]/examples/sky-shell-exec/sky-shell-exec.c</source>
<commands>echo CLEANING
<source EXPORT="discard">[CONTIKI_DIR]/examples/sky-shell-exec/sky-shell-exec.c</source>
<commands EXPORT="discard">echo CLEANING
make clean TARGET=sky
echo COMPILING CONTIKI EXECUTABLE
@ -35,7 +32,7 @@ make sky-shell-exec.sky CORE=sky-shell-exec.sky TARGET=sky
make sky-shell-exec.sky CORE=sky-shell-exec.sky TARGET=sky
make sky-shell-exec.sky CORE=sky-shell-exec.sky TARGET=sky
make sky-shell-exec.sky CORE=sky-shell-exec.sky TARGET=sky</commands>
<firmware>[CONTIKI_DIR]/examples/sky-shell-exec/sky-shell-exec.sky</firmware>
<firmware EXPORT="copy">[CONTIKI_DIR]/examples/sky-shell-exec/sky-shell-exec.sky</firmware>
<moteinterface>se.sics.cooja.interfaces.Position</moteinterface>
<moteinterface>se.sics.cooja.interfaces.IPAddress</moteinterface>
<moteinterface>se.sics.cooja.interfaces.Mote2MoteRelations</moteinterface>
@ -44,12 +41,10 @@ make sky-shell-exec.sky CORE=sky-shell-exec.sky TARGET=sky</commands>
<moteinterface>se.sics.cooja.mspmote.interfaces.SkyButton</moteinterface>
<moteinterface>se.sics.cooja.mspmote.interfaces.SkyFlash</moteinterface>
<moteinterface>se.sics.cooja.mspmote.interfaces.SkyByteRadio</moteinterface>
<moteinterface>se.sics.cooja.mspmote.interfaces.SkySerial</moteinterface>
<moteinterface>se.sics.cooja.mspmote.interfaces.MspSerial</moteinterface>
<moteinterface>se.sics.cooja.mspmote.interfaces.SkyLED</moteinterface>
</motetype>
<mote>
se.sics.cooja.mspmote.SkyMote
<motetype_identifier>sky1</motetype_identifier>
<breakpoints />
<interface_config>
se.sics.cooja.interfaces.Position
@ -61,6 +56,11 @@ make sky-shell-exec.sky CORE=sky-shell-exec.sky TARGET=sky</commands>
se.sics.cooja.mspmote.interfaces.MspMoteID
<id>1</id>
</interface_config>
<interface_config>
se.sics.cooja.mspmote.interfaces.MspSerial
<history>ls~;~K~;ls~;read hello-world.b64~;</history>
</interface_config>
<motetype_identifier>sky1</motetype_identifier>
</mote>
</simulation>
<plugin>
@ -70,7 +70,6 @@ make sky-shell-exec.sky CORE=sky-shell-exec.sky TARGET=sky</commands>
<height>200</height>
<location_x>0</location_x>
<location_y>0</location_y>
<minimized>false</minimized>
</plugin>
<plugin>
se.sics.cooja.plugins.MoteInterfaceViewer
@ -84,7 +83,6 @@ make sky-shell-exec.sky CORE=sky-shell-exec.sky TARGET=sky</commands>
<height>551</height>
<location_x>3</location_x>
<location_y>347</location_y>
<minimized>false</minimized>
</plugin>
<plugin>
se.sics.cooja.mspmote.plugins.MspStackWatcher
@ -94,7 +92,6 @@ make sky-shell-exec.sky CORE=sky-shell-exec.sky TARGET=sky</commands>
<height>201</height>
<location_x>247</location_x>
<location_y>-1</location_y>
<minimized>false</minimized>
</plugin>
<plugin>
se.sics.cooja.plugins.ScriptRunner
@ -151,7 +148,7 @@ while (!msg.contains("Contiki&gt;")) {
log.testFailed();
} else {
log.log("VERIFIED: " + msg + "\n");
sb.replace(0, msg.length()-1, new String(""));
sb.replace(0, msg.trim().length(), new String(""));
}
YIELD();
@ -192,8 +189,7 @@ while (true) {
log.log("&gt; ELF loader error: " + msg +"\n");
log.testFailed();
}
}
</script>
}</script>
<active>true</active>
</plugin_config>
<width>600</width>
@ -201,7 +197,6 @@ while (true) {
<height>700</height>
<location_x>215</location_x>
<location_y>199</location_y>
<minimized>false</minimized>
</plugin>
</simconf>

Binary file not shown.