Bontor Humala | 24 Jul 05:07 2014
Picon

Entering Critical Ssection in Contiki

Hello, I am trying to implement ModBus library on top of Contiki, using freeModBus. In porting the library, some functions needs to be implemented as noninterruptible task (critical section).

I tried using cpu_cpsid() and cpu_cpsie() in cpu.h but the message just stopped in the middle. Is there any API from Contiki to declare this "critical section", e.g. in freeRTOS you have taskENTER_CRITICAL and taskEXIT_CRITICAL

Thanks.
------------------------------------------------------------------------------
Want fast and easy access to all the code in your enterprise? Index and
search up to 200,000 lines of code with a free copy of Black Duck
Code Sight - the same software that powers the world's largest code
search on Ohloh, the Black Duck Open Hub! Try it now.
http://p.sf.net/sfu/bds
_______________________________________________
Contiki-developers mailing list
Contiki-developers@...
https://lists.sourceforge.net/lists/listinfo/contiki-developers
khelifi nesrine | 23 Jul 22:16 2014
Picon

energy paramter

Hi all,
 
I want to ask how to compute the residual energy of each node? I check the code I fund this instruction p->mc.obj.energy.energy_est which return the  energy consumption of  the path from the root to the node if I'm not wrong. But how can I compute the energy of each node?


--

 Nesrine Khelifi
------------------------------------------------------------------------------
Want fast and easy access to all the code in your enterprise? Index and
search up to 200,000 lines of code with a free copy of Black Duck
Code Sight - the same software that powers the world's largest code
search on Ohloh, the Black Duck Open Hub! Try it now.
http://p.sf.net/sfu/bds
_______________________________________________
Contiki-developers mailing list
Contiki-developers@...
https://lists.sourceforge.net/lists/listinfo/contiki-developers
Kerry Veenstra | 23 Jul 22:15 2014

Custom Radio Medium — Any Gotchas?

Hello folks,

I'm working on a new radio medium. So far, reading the Java source code of the Cooja simulator in my Instant
Contiki installation, the task looks straightforward. But I haven't tried to modify Cooja yet. 

I'd appreciate any suggestions or warnings that experience has provided you.

Thanks,

Kerry Veenstra

------------------------------------------------------------------------------
Want fast and easy access to all the code in your enterprise? Index and
search up to 200,000 lines of code with a free copy of Black Duck
Code Sight - the same software that powers the world's largest code
search on Ohloh, the Black Duck Open Hub! Try it now.
http://p.sf.net/sfu/bds
David Rodenas | 23 Jul 18:44 2014

Coffee file system + Ipv6 is too much for tmote sky?

Dear All,

I was programming an application which uses the coffee file system to store some statistics in flash memory. I was using tmote sky as target, and the compiler threw some errors related (I think) to memory overflow:

---
[...]
contiki-sky-main.c:(.init9+0x16e): relocation truncated to fit: R_MSP430_16 against symbol `contikimac_driver' defined in .rodata section in contiki-sky.a(contikimac.o)
[...]
---

After trying everything in my own app, I tested a simple code using the example app examples/ipv6/rpl-udp/udp-client.c:

---
#include <string.h>
#include "cfs/cfs.h"        // new code
#include "cfs/cfs-coffee.h"         // new code

[...]

PROCESS_THREAD(udp_client_process, ev, data)
{
  static struct etimer periodic;
  static struct ctimer backoff_timer;
#if WITH_COMPOWER
  static int print = 0;
#endif
//<new code>
  char *filename = "msg_file";
  int fd_write;
  int n;
  char message[32];
  char buf[100];
//</new code>

[...]

#if WITH_COMPOWER
  powertrace_sniff(POWERTRACE_ON);
#endif

//</new code>
  cfs_coffee_format();
  cfs_remove(filename);  
 
  strcpy(message,"#1.hello world.");
  strcpy(buf,message);
  printf("step 1: %s\n", buf );
  if((fd_write = cfs_open(filename, CFS_WRITE)) != -1) {
    n = cfs_write(fd_write, message, sizeof(message));
    cfs_close(fd_write);
    printf("step 2: successfully written to cfs. wrote %i bytes\n", n);
  } else {
    printf("ERROR: could not write to memory in step 2.\n");
  }
//</new code> 
  
  etimer_set(&periodic, SEND_INTERVAL);

[...]
---

But again same errors. I tried also to use cfs_coffee_reserve() function, and same result. However, if I compile the app using a different target, for example, z1 motes, it works.

Would you know what I am doing wrong? Would you possibly know some tips to make this run for tmote sky? Does the combination ipv6 and cfs actually work in tmote sky? I have been looking into the contiki mailing list, but no luck so far...

Thanks in advance,

David 


------------------------------------------------------------------------------
Want fast and easy access to all the code in your enterprise? Index and
search up to 200,000 lines of code with a free copy of Black Duck
Code Sight - the same software that powers the world's largest code
search on Ohloh, the Black Duck Open Hub! Try it now.
http://p.sf.net/sfu/bds
_______________________________________________
Contiki-developers mailing list
Contiki-developers@...
https://lists.sourceforge.net/lists/listinfo/contiki-developers
José Silva Oliveira Araujo | 23 Jul 16:16 2014
Picon
Picon

Re: Modeified version of MSPsim for GISOO

Dear Deepak,

For some weird reason the file was changed from its original location. I have now updated the link and you can
follow it now. The link is also here:
https://code.google.com/p/kth-gisoo/source/browse/trunk/files/gisoo_installation_files/mspsim.zip. 

In case there is something missing, please let us know.

Best regards,
Jose Araujo 
_____________________________
PhD student
Department of Automatic Control
KTH Royal Institute of Technology
http://people.kth.se/~araujo/ 
https://code.google.com/p/kth-gisoo/ 
https://code.google.com/p/kth-hvac/

-----Original Message-----
From: contiki-developers-request@...
[mailto:contiki-developers-request@...] 
Sent: den 22 juli 2014 19:01
To: contiki-developers@...
Subject: Contiki-developers Digest, Vol 98, Issue 42

Message: 1
Date: Tue, 22 Jul 2014 17:15:12 +0530
From: deepak khatri <deepakkhatri45@...>
Subject: [Contiki-developers] Fwd: Modeified version of MSPsim for
	GISOO
To: contiki-developers@...
Message-ID:
	<CACNpxkCxGxct-apCbmYi7Xp8zdgFVRXQPvB+cqJF4V9ij2E9Jw@...>
Content-Type: text/plain; charset="utf-8"

---------- Forwarded message ----------
From: deepak khatri <deepakkhatri45@...>
Date: Tue, Jul 22, 2014 at 4:40 PM
Subject: Modeified version of MSPsim for GISOO
To: contiki-developers-request@...

Hii

Following the instruction on this link:
https://code.google.com/p/kth-gisoo/wiki/Installation i installed cooja for windows using cygwin.
For enabling dac communication MSPSim.jar has to be modified and it is asked to download it from the link:
https://kth-gisoo.googlecode.com/svn/trunk/files/gisoo/mspsim.zip

 But the link is not working. Please help!

------------------------------------------------------------------------------
Want fast and easy access to all the code in your enterprise? Index and
search up to 200,000 lines of code with a free copy of Black Duck
Code Sight - the same software that powers the world's largest code
search on Ohloh, the Black Duck Open Hub! Try it now.
http://p.sf.net/sfu/bds
Dall'Ora, Riccardo | 23 Jul 15:37 2014
Picon

sky-shell-exec misses some bytes when uploading a file to CFS

Dear all,

I am using  "sky-shell-exec" in Contiki/examples to upload a large binary file from my PC to Tmote Sky's
Coffee File System (CFS). However, I observed that it is not very reliable: some bytes are not written to
CFS, resulting in a smaller file than the actually uploaded one. I have tried uploading through both
InstantContiki and the native Linux and the result is the same. 

Did anyone experience the same problem? Any suggestions on how to do a reliable file transfer to CFS? 

Thanks
Riccardo
------------------------------------------------------------------------------
Want fast and easy access to all the code in your enterprise? Index and
search up to 200,000 lines of code with a free copy of Black Duck
Code Sight - the same software that powers the world's largest code
search on Ohloh, the Black Duck Open Hub! Try it now.
http://p.sf.net/sfu/bds
Sapana Khemkar | 23 Jul 13:52 2014
Picon

psock not working proprly

Hi

 

I am trying to port polarssl library in Contiki 2.7. I have written TCP client code to test this library using psock socket provided in Contiki. I have used platform cooja on cooja simulation for testing.

To send data on network I have defined my_send function as below and set this as ssl_bio  for polarssl

 

static int

my_send(void *ctx, const unsigned char *buf, size_t len)

{

     static struct psock *psocket;

    

     psocket = ( struct psock *) ctx;

 

     //start thread to send data and wait until finished

     send_data(psocket, buf, len);

     //return no of bytes transmitted

     return (len - psocket->sendlen) ;

}

 

Below is definition of send_data thread

 

static

PT_THREAD(send_data(struct psock *psocket, const unsigned char *buf, size_t len))

{

    

     PSOCK_BEGIN(psocket);

 

     printf("send_data -> \n");

    

     PSOCK_SEND(psocket, buf, len); 

 

     PSOCK_END(psocket);

    

}

 

Here I am assuming that my_send function will wait until send_data thread completed. Is this correct?

 

My problem is that my send function always fails and returns 0. Has somebody faced such problem with psock socket. Am I doing anything wrong?

I have attached my example code for your reference. Any clues/pointers are welcome.

 

Thanks in advance.

 

Sapana

 

 

DISCLAIMER ========== This e-mail may contain privileged and confidential information which is the property of Persistent Systems Ltd. It is intended only for the use of the individual or entity to which it is addressed. If you are not the intended recipient, you are not authorized to read, retain, copy, print, distribute or use this message. If you have received this communication in error, please notify the sender and delete all copies of this message. Persistent Systems Ltd. does not accept any liability for virus infected mails.

#include <string.h>
#include <stdlib.h>
#include <stdio.h>

#include "net/uip-debug.h"
#include "contiki.h"
#include "contiki-lib.h"
#include "contiki-net.h"
#include "random.h"

#include "polarssl/entropy.h"
#include "polarssl/ctr_drbg.h"
#include "polarssl/certs.h"
#include "polarssl/x509.h"
#include "polarssl/ssl.h"
#include "polarssl/net.h"
#include "polarssl/error.h"
#include "polarssl/debug.h"

#define SERVER_PORT 443

#define SERVER_NAME "aaaa::ff:fe00:1"

#define GET_REQUEST "GET / HTTP/1.0\r\n\r\n"
#define INBUF_SIZE 		400
#define OUTBUF_SIZE 		400

PROCESS(ssl_client_process, "SSL Client");

AUTOSTART_PROCESSES(&ssl_client_process);

/*****************************************************/
/*Global Variables************************************/

static uint8_t inbuf[INBUF_SIZE];
static uint8_t outbuf[OUTBUF_SIZE];
ssl_context ssl;
 x509_crt cacert;
//use two different psock strutures for in and out communication
 struct psock socket_in, socket_out;
static int len,ret;

//temp
static char my_rand(void)
{
	return random_rand() ;
}
static void my_debug(void *ctx, int level, const char *str)
{
	printf("%s", str);
}
     
static int random_num(void *p_rng, unsigned char *output, size_t output_len)
{
	int i;
	printf("random_num...\n");
	for(i=0; i<output_len; i++)
	{
		//output[i]=(unsigned char)random_rand();
		output[i] = my_rand();
	}
	return 0; 
} 
static
PT_THREAD(recv_data(struct psock *psocket, size_t len))
{
	
	PSOCK_BEGIN(psocket);

  printf("recv_data -> \n");
	
	PSOCK_READBUF_LEN( psocket, len );	

	PSOCK_END(psocket);
	
}
static int 
my_recv(void *ctx, unsigned char *buf, size_t len)
{
	int bytes_received = 0;
	struct psock *psocket = (struct psock *) ctx;

	printf("my_recv %d bytes...\n", len);
#if 1
	recv_data(psocket, len);
	bytes_received = PSOCK_DATALEN( psocket );
	printf("received %d bytes \n", bytes_received);

	memcpy( buf, inbuf, bytes_received);
	return bytes_received;
#endif
	return len;

}
static
PT_THREAD(send_data(struct psock *psocket, const unsigned char *buf, size_t len))
{
	
	PSOCK_BEGIN(psocket);

	printf("send_data -> \n");
	
	PSOCK_SEND(psocket, buf, len);	

	PSOCK_END(psocket);
	
}
static int 
my_send(void *ctx, const unsigned char *buf, size_t len)
{
	static struct psock *psocket;
	
	psocket = ( struct psock *) ctx;

	printf("send %d bytes...\n", len);
	send_data(psocket, buf, len);
	printf("psocket->sendlen=%d\n", psocket->sendlen);
 	return len;
}

static int 
handle_connection(void)
{
	ret = ssl_handshake( &ssl ) ;
	if(ret != 0 )
    {
        if( ret != POLARSSL_ERR_NET_WANT_READ && ret != POLARSSL_ERR_NET_WANT_WRITE )
        {
			printf( " failed\n  ! ssl_handshake returned -0x%x\n\n", -ret );
			return -1;
		}
    }

    printf( " ok\n" );

    /* Verify the server certificate */
    printf( "  . Verifying peer X.509 certificate..." );

    /* In real life, we may want to bail out when ret != 0 */
    if( ( ret = ssl_get_verify_result( &ssl ) ) != 0 )
    {
        printf( " failed\n" );

        if( ( ret & BADCERT_EXPIRED ) != 0 )
            printf( "  ! server certificate has expired\n" );

        if( ( ret & BADCERT_REVOKED ) != 0 )
            printf( "  ! server certificate has been revoked\n" );

        if( ( ret & BADCERT_CN_MISMATCH ) != 0 )
            printf( "  ! CN mismatch (expected CN=%s)\n", "PolarSSL Server 1" );

        if( ( ret & BADCERT_NOT_TRUSTED ) != 0 )
            printf( "  ! self-signed or not signed by a trusted CA\n" );

        printf( "\n" );
    }
    else
        printf( " ok\n" );
		
	/* Write the GET request  */
    printf( "  > Write to server:" );
    len = sprintf( (char *) outbuf, GET_REQUEST );

    while( ( ret = ssl_write( &ssl, outbuf, len ) ) <= 0 )
    {
        if( ret != POLARSSL_ERR_NET_WANT_READ && ret != POLARSSL_ERR_NET_WANT_WRITE )
        {
            printf( " failed\n  ! ssl_write returned %d\n\n", ret );
            //goto exit;
        }
    }

    len = ret;
    printf( " %d bytes written\n\n%s", len, (char *) outbuf );

    /*
     * 7. Read the HTTP response
     */
    printf( "  < Read from server:" );
    
    do
    {
        len = INBUF_SIZE - 1;
        memset( inbuf, 0, INBUF_SIZE );
        ret = ssl_read( &ssl, inbuf, len );

        if( ret == POLARSSL_ERR_NET_WANT_READ || ret == POLARSSL_ERR_NET_WANT_WRITE )
            continue;

        if( ret == POLARSSL_ERR_SSL_PEER_CLOSE_NOTIFY )
            break;

        if( ret < 0 )
        {
            printf( "failed\n  ! ssl_read returned %d\n\n", ret );
            break;
        }

        if( ret == 0 )
        {
            printf( "\n\nEOF\n\n" );
            break;
        }

        len = ret;
        printf( " %d bytes read\n\n%s", len, (char *) inbuf );
    }
    while( 1 );

    ssl_close_notify( &ssl );	

    return 1;	
  
}
PROCESS_THREAD(ssl_client_process, ev, data)
{
	PROCESS_BEGIN();
	PROCESS_PAUSE();
	PROCESS_PAUSE();
	PROCESS_PAUSE();
	PROCESS_PAUSE();
	PROCESS_PAUSE();
	debug_set_threshold(0);	
	
	memset( &ssl, 0, sizeof( ssl_context ) );
    	x509_crt_init( &cacert );
	uip_ipaddr_t server_ipaddr;

	uip_ip6addr(&server_ipaddr, 0xaaaa, 0, 0, 0, 0, 0xff, 0xfe00, 0x01);
	tcp_connect(&server_ipaddr, UIP_HTONS(SERVER_PORT), NULL);
	printf("Connecting...\n");
	PROCESS_WAIT_EVENT_UNTIL(ev == tcpip_event);
	

	if(uip_aborted() || uip_timedout() || uip_closed()) 
	{
		printf("Could not establish connection\n");
	}
	else if(uip_connected()) 
	{
		printf("Connected\n");

    
		PSOCK_INIT(&socket_in, inbuf, INBUF_SIZE);
		PSOCK_INIT(&socket_out, outbuf, OUTBUF_SIZE);
		if( ( ret = ssl_init( &ssl ) ) != 0 )
		{
			printf( " failed\n  ! ssl_init returned %d\n\n", ret );
			//goto exit;
		}
		printf("psock init done\n");
		random_init(0);
		ssl_set_endpoint( &ssl, SSL_IS_CLIENT );
		/* OPTIONAL is not optimal for security,
		* but makes interop easier in this simplified example */
		ssl_set_authmode( &ssl, SSL_VERIFY_OPTIONAL );
		ssl_set_ca_chain( &ssl, &cacert, NULL, "PolarSSL Server 1" );

		ssl_set_rng( &ssl, random_num, NULL );
		ssl_set_dbg( &ssl, my_debug, NULL );
		ssl_set_bio( &ssl, my_recv, &socket_in, my_send, &socket_out);

		do 
		{
			if(handle_connection() == -1)
				goto exit;
			PROCESS_WAIT_EVENT_UNTIL(ev == tcpip_event);
		}
		while(!(uip_closed() || uip_aborted() || uip_timedout()));
		printf("\nConnection closed.\n");
	}

exit:	;
	PROCESS_END();

}
------------------------------------------------------------------------------
Want fast and easy access to all the code in your enterprise? Index and
search up to 200,000 lines of code with a free copy of Black Duck
Code Sight - the same software that powers the world's largest code
search on Ohloh, the Black Duck Open Hub! Try it now.
http://p.sf.net/sfu/bds
_______________________________________________
Contiki-developers mailing list
Contiki-developers@...
https://lists.sourceforge.net/lists/listinfo/contiki-developers
khelifi nesrine | 22 Jul 21:13 2014
Picon

RPL metrics

Hi all,
 
I'm trying to undetrstand the code of RPL. I have some questions:
 
1- can we use in the same time both of ETX and Energy parameters? or just one RPL_DAG_MC ?
 
2- "p->link_metric" gives the value exact of ETX between the current node and its parent? what is the utility of this function:
 
NEIGHBOR_INFO_FIX2ETX(p->link_metric * p->dag->instance->min_hoprankinc)
and the second one also
 etx = (etx * RPL_DAG_MC_ETX_DIVISOR) / NEIGHBOR_INFO_ETX_DIVISOR;
 
if I need to know the value of ETX, I should use one of these functions or just the value is equal to p->link_metric ?
 
3- I want to know the remaining energy of each node, how can I do this? based on which variables? because I see different flags with energy metric:
 
The bit index within the flags field of
   the rpl_metric_object_energy structure. */
#define RPL_DAG_MC_ENERGY_INCLUDED 3
#define RPL_DAG_MC_ENERGY_TYPE  1
#define RPL_DAG_MC_ENERGY_ESTIMATION 0
#define RPL_DAG_MC_ENERGY_TYPE_MAINS  0
#define RPL_DAG_MC_ENERGY_TYPE_BATTERY  1
#define RPL_DAG_MC_ENERGY_TYPE_SCAVENGING 2
 
 
Thanks in advance for your help



--

 Nesrine Khelifi
------------------------------------------------------------------------------
Want fast and easy access to all the code in your enterprise? Index and
search up to 200,000 lines of code with a free copy of Black Duck
Code Sight - the same software that powers the world's largest code
search on Ohloh, the Black Duck Open Hub! Try it now.
http://p.sf.net/sfu/bds
_______________________________________________
Contiki-developers mailing list
Contiki-developers@...
https://lists.sourceforge.net/lists/listinfo/contiki-developers
vamsi chikati | 22 Jul 19:12 2014
Picon

power optimization with nullrdc

Hi,
  The econotag platform when I compiled with ContikiMAC, it is not able to join in network with a border router with nullrdc. Mail archives suggest that ContikiMAC is not quite implemented for this platform in the main line Contiki source.
  If this is correct could anybody please suggest how can I reduce power consumption with nullrdc. If I manage the power from application layer(switching on/off when required by app), it is rendering the whole network to be one-many connection but not mesh network as intermediate routers are off when required for hopping.

Can I use some other RDC? Or can I reduce power consumption in nullrdc itself?

Thanks and regards,
Vamsi


------------------------------------------------------------------------------
Want fast and easy access to all the code in your enterprise? Index and
search up to 200,000 lines of code with a free copy of Black Duck
Code Sight - the same software that powers the world's largest code
search on Ohloh, the Black Duck Open Hub! Try it now.
http://p.sf.net/sfu/bds
_______________________________________________
Contiki-developers mailing list
Contiki-developers@...
https://lists.sourceforge.net/lists/listinfo/contiki-developers
José Silva Oliveira Araujo | 22 Jul 19:00 2014
Picon
Picon

validation of COOJA radio models

Hi all,

 

I was wondering if any of you knew of papers or thesis which have done a validation of any of the radio models that were implemented in COOJA? I was trying to find work which has done some tests indoors or outdoors, in a real testbed, and has compared the results to the ones given for the same setup in COOJA.


Thanks for the help!

 

Best regards,

José Araújo

_____________________________

PhD student

Department of Automatic Control

KTH Royal Institute of Technology

http://people.kth.se/~araujo/

https://code.google.com/p/kth-gisoo/

https://code.google.com/p/kth-hvac/

 

 

------------------------------------------------------------------------------
Want fast and easy access to all the code in your enterprise? Index and
search up to 200,000 lines of code with a free copy of Black Duck
Code Sight - the same software that powers the world's largest code
search on Ohloh, the Black Duck Open Hub! Try it now.
http://p.sf.net/sfu/bds
_______________________________________________
Contiki-developers mailing list
Contiki-developers@...
https://lists.sourceforge.net/lists/listinfo/contiki-developers
Sapana Khemkar | 22 Jul 17:46 2014
Picon

heap and stack size for cooja motes

Hi


I am trying to test example-psoc-server using psock on cooja mote.


I receive data in a buffer. If I statically allocate memory to this buffer using array then example works fine.

But instead of using static allocation, if I use malloc to allocate memory to buffer then I cannot receive more than 4 bytes. Data more than 4 bytes is discarded by server.


Can you please tell me reason behind this?

How can I control heap and stack size for cooja mote in cooja simulation?


Thanks

Sapana




 

DISCLAIMER ========== This e-mail may contain privileged and confidential information which is the property of Persistent Systems Ltd. It is intended only for the use of the individual or entity to which it is addressed. If you are not the intended recipient, you are not authorized to read, retain, copy, print, distribute or use this message. If you have received this communication in error, please notify the sender and delete all copies of this message. Persistent Systems Ltd. does not accept any liability for virus infected mails.

------------------------------------------------------------------------------
Want fast and easy access to all the code in your enterprise? Index and
search up to 200,000 lines of code with a free copy of Black Duck
Code Sight - the same software that powers the world's largest code
search on Ohloh, the Black Duck Open Hub! Try it now.
http://p.sf.net/sfu/bds
_______________________________________________
Contiki-developers mailing list
Contiki-developers@...
https://lists.sourceforge.net/lists/listinfo/contiki-developers

Gmane