[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [lwip-users] new at lwip, running test on windows using PPP
From: |
zulu4711 |
Subject: |
Re: [lwip-users] new at lwip, running test on windows using PPP |
Date: |
Wed, 29 Nov 2017 10:39:59 -0700 (MST) |
Thanks for input Simon, really appreciated!
I can confirm that the PPP_INPROC_IRQ_SAFE is set to 1.
Basically I have just taken the ppp sample from contrib and added my own
"worker thread" that calls the socket functions, maybe I have done something
wrong with that !?
My init/main looks like this:
/* This is somewhat different to other ports: we have a main loop here:
* a dedicated task that waits for packets to arrive. This would normally be
* done from interrupt context with embedded hardware, but we don't get an
* interrupt in windows for that :-) */
static void main_loop(void) {
err_t err;
sys_sem_t init_sem;
int count;
u8_t rxbuf[1024];
volatile int callClosePpp = 0;
/* initialize lwIP stack, network interfaces and applications */
err = sys_sem_new(&init_sem, 0);
LWIP_ASSERT("failed to create init_sem", err == ERR_OK);
tcpip_init(test_init, &init_sem);
/* we have to wait for initialization to finish before
* calling update_adapter()! */
sys_sem_wait(&init_sem);
sys_sem_free(&init_sem);
// while (netif_is_link_up(&ppp_netif)==0) sys_msleep(1000);
//_beginthread(thWorkerUDP,0,NULL);
//sleepy(1000);
//_beginthread(thWorkerUDP,0,NULL);
// sleepy(1000);
// CHG Test 25-11 2017
//_beginthread(thWorkerSocket,0,NULL);
//
sys_thread_new("thWorkerSocket", thWorkerSocket, NULL,
DEFAULT_THREAD_STACKSIZE, DEFAULT_THREAD_PRIO);
#if (LWIP_SOCKET || LWIP_NETCONN) && LWIP_NETCONN_SEM_PER_THREAD
netconn_thread_init();
#endif
/* MAIN LOOP for driver update (and timers if NO_SYS) */
while (!_kbhit()) {
/* try to read characters from serial line and pass them to PPPoS */
count = sio_read(ppp_sio, (u8_t*)rxbuf, 1024);
if(count > 0) {
pppos_input(ppp, rxbuf, count);
} else {
/* nothing received, give other tasks a chance to run */
sys_msleep(1);
}
{
int do_hup = 0;
if(do_hup) {
ppp_close(ppp, 1);
do_hup = 0;
}
}
if(callClosePpp && ppp) {
/* make sure to disconnect PPP before stopping the program... */
callClosePpp = 0;
pppapi_close(ppp, 0);
ppp = NULL;
}
}
if(ppp) {
u32_t started;
printf("Closing PPP connection...\n");
/* make sure to disconnect PPP before stopping the program... */
pppapi_close(ppp, 0);
ppp = NULL;
/* Wait for some time to let PPP finish... */
started = sys_now();
do
{
sys_msleep(50);
/* @todo: need a better check here: only wait until PPP is down */
} while(sys_now() - started < 5000);
}
{
char x;
scanf("%c", &x);
}
#if (LWIP_SOCKET || LWIP_NETCONN) && LWIP_NETCONN_SEM_PER_THREAD
netconn_thread_cleanup();
#endif
}
int main(int argc,char* argv[]) {
sio_idx = 25 ;
printf("Using serial port %d for PPP\n", sio_idx);
/* no stdio-buffering, please! */
setvbuf(stdout, NULL,_IONBF, 0);
sleepy(3000);
main_loop();
while (!_kbhit()) sys_msleep(50);
return 0;
}
--
Sent from: http://lwip.100.n7.nabble.com/lwip-users-f3.html