Hello,
I´m using the IAR Electronic Workbench with "IAR C/C++ Compiler for ARM". Codeline 62 in Causes the error.
Here the Sourcecode:
------------hello_world.c--------------------------------------------------------------------------------------------------
/**
* \addtogroup helloworld
* @{
*/
/**
* \file
* An example of how to write uIP applications
* with protosockets.
* \author
* Adam Dunkels <[EMAIL PROTECTED]>
*/
/*
* This is a short example of how to write uIP applications using
* protosockets.
*/
/*
* We define the application state (struct hello_world_state) in the
* hello-world.h file, so we need to include it here. We also include
* uip.h (since this cannot be included in hello-world.h) and
* <string.h>, since we use the memcpy() function in the code.
*/
#include "hello-world.h"
#include "uip.h"
#include <string.h>
/*
* Declaration of the protosocket function that handles the connection
* (defined at the end of the code).
*/
static int handle_connection(struct hello_world_state *s);
/*---------------------------------------------------------------------------*/
/*
* The initialization function. We must explicitly call this function
* from the system initialization code, some time after uip_init() is
* called.
*/
void
hello_world_init(void)
{
/* We start to listen for connections on TCP port 1000. */
uip_listen(HTONS(1000));
}
/*---------------------------------------------------------------------------*/
/*
* In hello-world.h we have defined the UIP_APPCALL macro to
* hello_world_appcall so that this funcion is uIP's application
* function This function is called whenever an uIP event occurs
* (e.g. when a new connection is established, new data arrives, sent
* data is acknowledged, data needs to be retransmitted, etc.).
*/
void
hello_world_appcall(void)
{
/*
* The uip_conn structure has a field called "appstate" that holds
* the application state of the connection. We make a pointer to
* this to access it easier.
*/
struct hello_world_state *s = &(uip_conn->appstate);
/*
* If a new connection was just established, we should initialize
* the protosocket in our applications' state structure.
*/
if(uip_connected()) {
PSOCK_INIT(&s->p, s->inputbuffer, sizeof(s->inputbuffer));
}
/*
* Finally, we run the protosocket function that actually handles
* the communication. We pass it a pointer to the application state
* of the current connection.
*/
handle_connection(s);
}
/*---------------------------------------------------------------------------*/
/*
* This is the protosocket function that handles the communication. A
* protosocket function must always return an int, but must never
* explicitly return - all return statements are hidden in the PSOCK
* macros.
*/
static int
handle_connection(struct hello_world_state *s)
{
PSOCK_BEGIN(&s->p);
PSOCK_SEND_STR(&s->p, "Hello. What is your name?\n");
PSOCK_READTO(&s->p, '\n');
strncpy(s->name, s->inputbuffer, sizeof(s->name));
PSOCK_SEND_STR(&s->p, "Hello ");
PSOCK_SEND_STR(&s->p, s->name);
PSOCK_CLOSE(&s->p);
PSOCK_END(&s->p);
}
/*---------------------------------------------------------------------------*/
---------------------------------------hello_world.h-------------------------
/**
* \addtogroup apps
* @{
*/
/**
* \defgroup helloworld Hello, world
* @{
*
* A small example showing how to write applications with
* \ref psock "protosockets".
*/
/**
* \file
* Header file for an example of how to write uIP applications
* with protosockets.
* \author
* Adam Dunkels <[EMAIL PROTECTED]>
*/
#ifndef __HELLO_WORLD_H__
#define __HELLO_WORLD_H__
/* Since this file will be included by uip.h, we cannot include uip.h
here. But we might need to include uipopt.h if we need the u8_t and
u16_t datatypes. */
#include "uipopt.h"
#include "psock.h"
/* Next, we define the uip_tcp_appstate_t datatype. This is the state
of our application, and the memory required for this state is
allocated together with each TCP connection. One application state
for each TCP connection. */
typedef struct hello_world_state {
struct psock p;
char inputbuffer[10];
char name[40];
} uip_tcp_appstate_t;
/* Finally we define the application function to be called by uIP. */
void hello_world_appcall(void);
#ifndef UIP_APPCALL
#define UIP_APPCALL hello_world_appcall
#endif /* UIP_APPCALL */
void hello_world_init(void);
#endif /* __HELLO_WORLD_H__ */
/** @} */
/** @} */
----------------------------------------------------------------------------------------------------------------------------------------
greeni
>What C compiler are you using? What code line causes the error?
>/adam
>>b_greeni wrote:
>>Hello,
>>
>> I´m programming a microcontroller STR912FW44 using the uip TCP Stack
>> for ethernet communicaiton.
>>
>> I want to communicationtith a pc over a socket. Now i have
>> established a connection between the controller as server and the Pc
>> as client. But in future i want to send data from the pc to the controller and back.
>>
>>I tried to implement the hello world exampleusing protothread and the
>>psock.h, but it don´t works. I get the failure message a value of type
>>"u8_t(*)[12] cannot be assigned to an entity of type "struct hello_world_state".
>>Can anyone help me?
>>
>>
>> greeni
>>
--
Adam Dunkels, Swedish Institute of Computer Science http://www.sics.se/~adam/
I´m using the IAR Electronic Workbench with "IAR C/C++ Compiler for ARM". Codeline 62 in Causes the error.
Here the Sourcecode:
------------hello_world.c--------------------------------------------------------------------------------------------------
/**
* \addtogroup helloworld
* @{
*/
/**
* \file
* An example of how to write uIP applications
* with protosockets.
* \author
* Adam Dunkels <[EMAIL PROTECTED]>
*/
/*
* This is a short example of how to write uIP applications using
* protosockets.
*/
/*
* We define the application state (struct hello_world_state) in the
* hello-world.h file, so we need to include it here. We also include
* uip.h (since this cannot be included in hello-world.h) and
* <string.h>, since we use the memcpy() function in the code.
*/
#include "hello-world.h"
#include "uip.h"
#include <string.h>
/*
* Declaration of the protosocket function that handles the connection
* (defined at the end of the code).
*/
static int handle_connection(struct hello_world_state *s);
/*---------------------------------------------------------------------------*/
/*
* The initialization function. We must explicitly call this function
* from the system initialization code, some time after uip_init() is
* called.
*/
void
hello_world_init(void)
{
/* We start to listen for connections on TCP port 1000. */
uip_listen(HTONS(1000));
}
/*---------------------------------------------------------------------------*/
/*
* In hello-world.h we have defined the UIP_APPCALL macro to
* hello_world_appcall so that this funcion is uIP's application
* function This function is called whenever an uIP event occurs
* (e.g. when a new connection is established, new data arrives, sent
* data is acknowledged, data needs to be retransmitted, etc.).
*/
void
hello_world_appcall(void)
{
/*
* The uip_conn structure has a field called "appstate" that holds
* the application state of the connection. We make a pointer to
* this to access it easier.
*/
struct hello_world_state *s = &(uip_conn->appstate);
/*
* If a new connection was just established, we should initialize
* the protosocket in our applications' state structure.
*/
if(uip_connected()) {
PSOCK_INIT(&s->p, s->inputbuffer, sizeof(s->inputbuffer));
}
/*
* Finally, we run the protosocket function that actually handles
* the communication. We pass it a pointer to the application state
* of the current connection.
*/
handle_connection(s);
}
/*---------------------------------------------------------------------------*/
/*
* This is the protosocket function that handles the communication. A
* protosocket function must always return an int, but must never
* explicitly return - all return statements are hidden in the PSOCK
* macros.
*/
static int
handle_connection(struct hello_world_state *s)
{
PSOCK_BEGIN(&s->p);
PSOCK_SEND_STR(&s->p, "Hello. What is your name?\n");
PSOCK_READTO(&s->p, '\n');
strncpy(s->name, s->inputbuffer, sizeof(s->name));
PSOCK_SEND_STR(&s->p, "Hello ");
PSOCK_SEND_STR(&s->p, s->name);
PSOCK_CLOSE(&s->p);
PSOCK_END(&s->p);
}
/*---------------------------------------------------------------------------*/
---------------------------------------hello_world.h-------------------------
/**
* \addtogroup apps
* @{
*/
/**
* \defgroup helloworld Hello, world
* @{
*
* A small example showing how to write applications with
* \ref psock "protosockets".
*/
/**
* \file
* Header file for an example of how to write uIP applications
* with protosockets.
* \author
* Adam Dunkels <[EMAIL PROTECTED]>
*/
#ifndef __HELLO_WORLD_H__
#define __HELLO_WORLD_H__
/* Since this file will be included by uip.h, we cannot include uip.h
here. But we might need to include uipopt.h if we need the u8_t and
u16_t datatypes. */
#include "uipopt.h"
#include "psock.h"
/* Next, we define the uip_tcp_appstate_t datatype. This is the state
of our application, and the memory required for this state is
allocated together with each TCP connection. One application state
for each TCP connection. */
typedef struct hello_world_state {
struct psock p;
char inputbuffer[10];
char name[40];
} uip_tcp_appstate_t;
/* Finally we define the application function to be called by uIP. */
void hello_world_appcall(void);
#ifndef UIP_APPCALL
#define UIP_APPCALL hello_world_appcall
#endif /* UIP_APPCALL */
void hello_world_init(void);
#endif /* __HELLO_WORLD_H__ */
/** @} */
/** @} */
----------------------------------------------------------------------------------------------------------------------------------------
greeni
>What C compiler are you using? What code line causes the error?
>/adam
>>b_greeni wrote:
>>Hello,
>>
>> I´m programming a microcontroller STR912FW44 using the uip TCP Stack
>> for ethernet communicaiton.
>>
>> I want to communicationtith a pc over a socket. Now i have
>> established a connection between the controller as server and the Pc
>> as client. But in future i want to send data from the pc to the controller and back.
>>
>>I tried to implement the hello world exampleusing protothread and the
>>psock.h, but it don´t works. I get the failure message a value of type
>>"u8_t(*)[12] cannot be assigned to an entity of type "struct hello_world_state".
>>Can anyone help me?
>>
>>
>> greeni
>>
--
Adam Dunkels, Swedish Institute of Computer Science http://www.sics.se/~adam/
_________________________________
Stelle Deine Fragen bei Lycos iQ http://iq.lycos.de/qa/ask/