1
0
mirror of git://projects.qi-hardware.com/nn-usb-fpga.git synced 2024-12-13 10:48:06 +02:00
nn-usb-fpga/plasma/kernel/dlltest.c

39 lines
922 B
C
Raw Normal View History

2010-04-22 04:01:38 +03:00
// dlltest.c
// Compile this program with "make dlltest".
// Then ftp test.bin to /flash/bin/dlltest.
// Then from a telnet prompt type "dlltest".
#include "dll.h"
void SocketReceive(IPSocket *socket)
{
}
void MyThread(void *sock)
{
char buf[80];
int i, bytes;
IPSocket *socket = sock;
for(i = 0; i < 10; ++i)
{
bytes = IPRead(socket, buf, sizeof(buf)-1);
buf[bytes] = 0;
IPPrintf(socket, "%d %s\n", i, buf);
OS_ThreadSleep(100);
}
socket->funcPtr = socket->userFunc; //restore socket receive function
}
// Function shouldn't block
void Start(IPSocket *socket, char *argv[])
{
IPPrintf(socket, "Hello from dlltest\n");
socket->userFunc = socket->funcPtr; //remember prev socket receive func
socket->funcPtr = SocketReceive; //new socket receive function
OS_ThreadCreate("MyThread", MyThread, socket, 100, 0);
}