...
This commit is contained in:
parent
02b2f13795
commit
2f7aac6868
1 changed files with 17 additions and 187 deletions
204
kernel/tests.c
204
kernel/tests.c
|
@ -131,6 +131,10 @@ static int join_test(void* arg)
|
|||
}
|
||||
|
||||
#if defined(CONFIG_LWIP) && defined(CONFIG_ROCKCREEK)
|
||||
|
||||
|
||||
#define SHELLDEBUGPRINTF(x,...) kprintf(x,##__VA_ARGS__);
|
||||
|
||||
static int srv_cnt = 0;
|
||||
static Server srv;
|
||||
void srv_on_read(ServerEventArgs* e)
|
||||
|
@ -156,40 +160,32 @@ void srv_on_conn(ServerEventArgs* e)
|
|||
int tmp1,tmp2;
|
||||
char buff[256];
|
||||
|
||||
kprintf("someone finally connected\n");
|
||||
SHELLDEBUGPRINTF("someone finally connected\n");
|
||||
|
||||
tmp1 = get_clock_tick();
|
||||
for (i = 0; i < 1024*4; i++)
|
||||
{
|
||||
// sleep(1);
|
||||
|
||||
err = srv_sendBuffer(&srv,e->ClientID,buff,sizeof(buff));
|
||||
if ( err < 0)
|
||||
{
|
||||
SHELLDEBUGPRINTF("err: %d", err);
|
||||
kprintf("err: %d", err);
|
||||
}
|
||||
|
||||
if (!(i%10))
|
||||
{
|
||||
SHELLDEBUGPRINTF("\r-%d-",i);
|
||||
kprintf("\r-%d-",i);
|
||||
}
|
||||
|
||||
// Sleep(10);
|
||||
}
|
||||
tmp2 = get_clock_tick();
|
||||
|
||||
kprintf("send with %f kb/s", ((float)i*sizeof(buff))/(tmp2-tmp1));
|
||||
// SHELLDEBUGPRINTF("send with %f kb/s",((float)i*sizeof(buff))/(tmp2-tmp1));
|
||||
SHELLDEBUGPRINTF("send %d kb in %d ticks",i*sizeof(buff),(tmp2-tmp1));
|
||||
}
|
||||
|
||||
//#define SHELLDEBUGPRINTF(x,...) kprintf(x,##__VA_ARGS__);
|
||||
|
||||
void* server_task(void* e)
|
||||
{
|
||||
kprintf("created server\n");
|
||||
|
||||
SHELLDEBUGPRINTF("created server\n");
|
||||
|
||||
server_init(&srv,5555,2);
|
||||
|
||||
|
@ -197,104 +193,10 @@ void* server_task(void* e)
|
|||
srv._OnDisconnect = srv_on_disc;
|
||||
srv._OnConnect = srv_on_conn;
|
||||
|
||||
|
||||
// shelldebugprint("Server is ready...\n");
|
||||
|
||||
while(1)
|
||||
sleep(2);
|
||||
|
||||
return NULL;
|
||||
|
||||
#if 0
|
||||
int sockfd, newsockfd, portno, clilen;
|
||||
char buffer[512];
|
||||
struct sockaddr_in serv_addr, cli_addr;
|
||||
int n;
|
||||
uint64_t tmp1,tmp2;
|
||||
int err;
|
||||
t
|
||||
/* First call to socket() function */
|
||||
sockfd = socket(AF_INET, SOCK_STREAM, IPPROTO_TCP);
|
||||
if (sockfd < 0)
|
||||
{
|
||||
SHELLDEBUGPRINTF("ERROR opening socket");
|
||||
return;
|
||||
}
|
||||
/* Initialize socket structure */
|
||||
memset((char *) &serv_addr,0, sizeof(serv_addr));
|
||||
portno = 5001;
|
||||
serv_addr.sin_family = AF_INET;
|
||||
serv_addr.sin_addr.s_addr = INADDR_ANY;
|
||||
serv_addr.sin_port = htons(portno);
|
||||
|
||||
SHELLDEBUGPRINTF("binding");
|
||||
/* Now bind the host address using bind() call.*/
|
||||
if (bind(sockfd, (struct sockaddr *) &serv_addr,
|
||||
sizeof(serv_addr)) < 0)
|
||||
{
|
||||
SHELLDEBUGPRINTF("ERROR on binding");
|
||||
return;
|
||||
}
|
||||
|
||||
/* Now start listening for the clients, here process will
|
||||
* go in sleep mode and will wait for the incoming connection
|
||||
*/
|
||||
SHELLDEBUGPRINTF("listening");
|
||||
listen(sockfd,5);
|
||||
clilen = sizeof(cli_addr);
|
||||
|
||||
/* Accept actual connection from the client */
|
||||
SHELLDEBUGPRINTF("accepting");
|
||||
newsockfd = accept(sockfd, (struct sockaddr *)&cli_addr,
|
||||
&clilen);
|
||||
if (newsockfd < 0)
|
||||
{
|
||||
kprintf("ERROR on accept");
|
||||
return;
|
||||
}
|
||||
/* If connection is established then start communicating */
|
||||
memset(buffer,0,256);
|
||||
SHELLDEBUGPRINTF("recieving");
|
||||
n = recv( newsockfd,buffer,255,0 );
|
||||
if (n < 0)
|
||||
{
|
||||
SHELLDEBUGPRINTF("ERROR reading from socket");
|
||||
return;
|
||||
}
|
||||
SHELLDEBUGPRINTF("Here is the message: %s\n",buffer);
|
||||
|
||||
/* Write a response to the client */
|
||||
kprintf("writing");
|
||||
n = send(newsockfd,"I got your message",18,0);
|
||||
if (n < 0)
|
||||
{
|
||||
SHELLDEBUGPRINTF("ERROR writing to socket");
|
||||
return;
|
||||
}
|
||||
|
||||
tmp1 = get_clock_tick();
|
||||
|
||||
for (n = 0; n < 1024*256 ; n++)
|
||||
{
|
||||
if (!(n%100))
|
||||
SHELLDEBUGPRINTF("%d-",n);
|
||||
err = send(newsockfd,buffer,sizeof(buffer),0);
|
||||
if (err < 0)
|
||||
{
|
||||
SHELLDEBUGPRINTF("error on sending: %d",err);
|
||||
break;
|
||||
}
|
||||
// if (!(n%100))
|
||||
// sleep(1);
|
||||
// udelay(100);
|
||||
}
|
||||
|
||||
tmp2 = get_clock_tick();
|
||||
|
||||
SHELLDEBUGPRINTF("Send 1024*256 Bytes in : %d clock ticks",tmp2-tmp1);
|
||||
|
||||
#endif
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int cli_cnt = 0;
|
||||
|
@ -326,97 +228,25 @@ void* client_task(void* e)
|
|||
cli_init(&cli);
|
||||
cli._OnRead = cli_on_read;
|
||||
cli._OnDisconnect = cli_on_disc;
|
||||
sleep(4);
|
||||
sleep(2);
|
||||
|
||||
// SHELLDEBUGPRINTF("Client is ready...\n");
|
||||
SHELLDEBUGPRINTF("Client is ready...\n");
|
||||
kprintf("Client is ready...\n");
|
||||
|
||||
while (err)
|
||||
{
|
||||
sleep(1);
|
||||
err = cli_ConnectTo(&cli,"192.168.0.2",5555,0);
|
||||
SHELLDEBUGPRINTF("retry connect err = %d socket: %d\n",err,cli.sSocket);
|
||||
|
||||
|
||||
}
|
||||
SHELLDEBUGPRINTF("connected\n");
|
||||
kprintf("Client is ready...\n");
|
||||
|
||||
sleep(1);
|
||||
err = cli_sendBuffer(&cli,"Hallo Welt",sizeof("Hallo Welt"));
|
||||
SHELLDEBUGPRINTF("send message err = %d\n",err);
|
||||
kprintf("Client is ready...\n");
|
||||
|
||||
|
||||
while(1)
|
||||
sleep(2);
|
||||
sleep(2);
|
||||
|
||||
|
||||
#if 1
|
||||
while(1)
|
||||
{
|
||||
cli_sendBuffer(&cli,netbuffer,sizeof(netbuffer));
|
||||
sleep(1);
|
||||
}
|
||||
#endif
|
||||
return NULL;
|
||||
|
||||
#if 0
|
||||
char dir[2048];
|
||||
int sd;
|
||||
struct sockaddr_in sin;
|
||||
struct sockaddr_in pin;
|
||||
struct hostent *hp;
|
||||
int n;
|
||||
|
||||
int on = 1;
|
||||
|
||||
sleep(1);
|
||||
|
||||
/* fill in the socket structure with host information */
|
||||
memset(&pin, 0, sizeof(pin));
|
||||
pin.sin_family = AF_INET;
|
||||
pin.sin_addr.s_addr = inet_addr("192.168.0.2");
|
||||
pin.sin_port = htons(5001);
|
||||
|
||||
/* grab an Internet domain socket */
|
||||
if ((sd = socket(AF_INET, SOCK_STREAM, IPPROTO_TCP)) == -1) {
|
||||
kprintf("socketfail");
|
||||
return;
|
||||
}
|
||||
|
||||
// setsockopt( sd, IPPROTO_TCP, TCP_NODELAY, (char *) &on, sizeof( on));
|
||||
|
||||
kprintf("connecting with socket nr : %d",sd);
|
||||
/* connect to PORT on HOST */
|
||||
|
||||
if (connect(sd,(struct sockaddr *) &pin, sizeof(pin)) == -1) {
|
||||
kprintf("connectfail");
|
||||
return;
|
||||
}
|
||||
kprintf("sending");
|
||||
/* send a message to the server PORT on machine HOST */
|
||||
if (send(sd, "HELLO THERE", strlen("HELLO THERE"), 0) == -1) {
|
||||
kprintf("sendfail");
|
||||
return;
|
||||
}
|
||||
kprintf("recieving");
|
||||
/* wait for a message to come back from the server */
|
||||
if (recv(sd, dir, 256, 0) == -1) {
|
||||
kprintf("recvfail");
|
||||
return;
|
||||
}
|
||||
|
||||
/* spew-out the results and bail out of here! */
|
||||
kprintf("%s\n", dir);
|
||||
|
||||
while(1)
|
||||
{
|
||||
recv(sd,dir,sizeof(dir),0);
|
||||
// udelay(100);
|
||||
}
|
||||
|
||||
// close(sd);
|
||||
|
||||
#endif
|
||||
return NULL;
|
||||
}
|
||||
#endif
|
||||
|
@ -431,12 +261,12 @@ int test_init(void)
|
|||
|
||||
#if defined(CONFIG_LWIP) && defined(CONFIG_ROCKCREEK)
|
||||
|
||||
shell_init(RCCE_ue());
|
||||
// shell_init(RCCE_ue());
|
||||
//
|
||||
// sleep(10);
|
||||
// SHELLDEBUGPRINTF("hello World! I AM CORE NO. %d =) \n",RCCE_ue());
|
||||
|
||||
sleep(10);
|
||||
SHELLDEBUGPRINTF("hello World! I AM CORE NO. %d =) \n",RCCE_ue());
|
||||
|
||||
if (RCCE_ue())
|
||||
if (!RCCE_ue())
|
||||
create_kernel_task(NULL,server_task,NULL);
|
||||
else
|
||||
create_kernel_task(NULL,client_task,NULL);
|
||||
|
|
Loading…
Add table
Reference in a new issue