[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [lwip-users] PPP-new threaded vs non-threaded application
From: |
Sylvain Rochet |
Subject: |
Re: [lwip-users] PPP-new threaded vs non-threaded application |
Date: |
Mon, 7 Apr 2014 22:30:03 +0200 |
User-agent: |
Mutt/1.5.21 (2010-09-15) |
Hello,
On Mon, Apr 07, 2014 at 08:05:33PM +0000, address@hidden wrote:
> Hi Sylvain,
>
> I think in your post
> http://lists.nongnu.org/archive/html/lwip-users/2013-06/msg00011.html,
> you gave some code snippet showing how to use ppp-new in user's
> application. I believe that snippet is used in a non-threaded
> application, am I right?
Yes, it is, or inside the tcpip thread with the tcpip_init_done callback
or tcpip_callback_with_block helper.
By the way, this is a great example for PPPoS I forgot I did, this
should definitely reach the doc folder :-)
> Can you give an example application code snippet for threaded
> environment? I have problem to get my threaded application work with
> PPP-new. Basically, I followed your example for non-threaded
> environment, but use functions with pre-fix pppapi_ instead of ppp_ as
> you suggested in that post. The following code snippet is my
> task(freeRTOS is used) function handling PPP.
>
> void vPPPApplication(void)
> {
> ppp_pcb *ppps;
> char *username = "test";
> char *password = "test";
>
> int connected = 0;
> int pd;
>
> ppps = pppapi_new();
ok
> /* set the method of authentication. Use PPPAUTHTYPE_PAP, or
> * PPPAUTHTYPE_CHAP for more security .
> * If this is not called, the default is PPPAUTHTYPE_NONE.
> */
> pppapi_set_auth(ppps, PPPAUTHTYPE_PAP, username, password);
ok
> pppapi_over_serial_create(ppps, 0, ppp_link_status_cb, NULL);
>
> pppapi_open(ppps, 0);
ok
> while(1)
> {
> u8_t buffer[128];
> int len;
> len = sio_read(0, buffer, 20);
> if(len <= 0) {
> vTaskDelay( 10 );
> } else {
> pppos_input(ppps, buffer, len);
> }
> }
> }
ok
Looks good for the case of a direct PPoS session (without a modem)
between two hosts.
Note that lwIP should be initialized before and it must finish its
initialisation before calling any of ppp_ or pppapi_ functions.
Sylvain
signature.asc
Description: Digital signature