PPP over serial

cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

PPP over serial

16,261 Views
FredericoPrado
Contributor II

Hello.

 

I am trying to figure out how to use the PPP driver to establish a connection through a GPRS external modem. It would be a standard Dial up connection.

 

I was only able to find examples on how to use use PPP over Ethernet and HDLC. I don`t have a clue on how exactly do I manage the call on dial up connections, and how can I generate an io pcb table for a serial connection in order to initialize the PPP driver.

 

Does anyone have an idea on how to do it?

Labels (1)
Tags (1)
40 Replies

1,401 Views
CarlFST60L
Senior Contributor II

Hi,

 

BUMP!

 

Anyone?

 

Regards,

Carl Norman

 

0 Kudos

1,401 Views
Niall
Contributor II

There is a PPP over serial example in the RTCS example folder in the MQX installation. It's the shell example. This might help to get you started.

0 Kudos

1,401 Views
admin
Specialist II

I had a reply to a service request: SR# 1-784694661

"Currently we don’t have a PPP client, however it is under development and will be available on MQX 3.8 version."

-----Service request reply text ends.----

 

I have successfully tested the PPP (Point-to-Point) Example Application. The TWR52259 is the ppp server and my computer is the ppp Client and the PC gets the IP address from the TWR52259.

 

LOCAL_ADDRESS 10.200.1.98 (TWR52259)

PEER_ADDRESS 10.200.1.99 (My PC)

GATEWAY                NO GATEWAY AT THIS POINT

 

And I can ping between them and they respond each other.

 

Now, what I need is to make the TWR52259 gets connected to a Gateway (i.e. a router, or a modem) and therefore have internet connection through the serial UART cable.

 

Regarding the reply answer about that there is no a PPP client implementation yet for TWR52259, I have some questions:

 

1. Is it possible to implement a PPP connection between the TWR52259 and a gateway through the serial UART and be bound to internet just like it is possible with an Ethernet cable connected to the LAN?

 

TWR52259 ---ppp over uart---- GATEWAY ----- internet

Would be the same as:

TWR52259 ---Ethernet cable---- GATEWAY ----- internet

??

 

2. ¿Would that be transparent to the application layer of the TWR52259 (i.e. to send an e-mail, httpd server, FTP client/server, TCP/IP socket)?

 

3. If that is possible, How can I do that then?

 

During the PPP (Point-to-Point) Example Application test I noted the IPCP_DATA_STRUCT

typedef struct {

void (_CODE_PTR_ IP_UP) (pointer);

void (_CODE_PTR_ IP_DOWN) (pointer);

pointer IP_PARAM;

unsigned ACCEPT_LOCAL_ADDR : 1;

unsigned ACCEPT_REMOTE_ADDR : 1;

unsigned DEFAULT_NETMASK : 1;

unsigned DEFAULT_ROUTE : 1;

unsigned NEG_LOCAL_DNS : 1;

unsigned NEG_REMOTE_DNS : 1;

unsigned ACCEPT_LOCAL_DNS : 1;

/*Ignored if NEG_LOCAL_DNS = 0. */

unsigned ACCEPT_REMOTE_DNS : 1;

/*Ignored if NEG_REMOTE_DNS = 0. */

unsigned : 0;

_ip_address LOCAL_ADDR;

_ip_address REMOTE_ADDR;

_ip_address NETMASK;

/* Ignored if DEFAULT_NETMASK = 1. */

_ip_address LOCAL_DNS;

/* Ignored if NEG_LOCAL_DNS = 0. */

_ip_address REMOTE_DNS;

/* Ignored if NEG_REMOTE_DNS = 0. */

} IPCP_DATA_STRUCT, _PTR_ IPCP_DATA_STRUCT_PTR;

 

And I believe that it is possible to configure all the parameters of this struct to make the TWR52259 routes all the protocols from the application layer to another router and then to the internet just like it does over Ethernet.

 

One more thing:

The protocol for a CLIENT-SERVER ppp connection is:

 

1. The Client sends the "CLIENT" String.

2. The Server responds with "CLIENTSERVER" String

3. Then the negotiation begins and the client binds to the network through ppp.

 

Now, In the PPP (Point-to-Point) Example Application I noted the following lines at the PPP_start(void) function call:

#ifdef PPP_DEVICE_DUN

_io_dun_install("dun:");

pfile = fopen("dun:", (char_ptr)pfile);

#endif

 

This was made to install the Dial-Up Networking driver.

 

In the io_dun.c library are the drivers to communicate to Windows Dial-Up Networking or Windows NT RAS.

 

Now, Inside the _io_dun_install function we can see the following source code lines:

dev_ptr->RECV = "CLIENT";

dev_ptr->SEND = "CLIENTSERVER";

dev_ptr->RECV_SIZE = 6;

dev_ptr->SEND_SIZE = 12;

 

But inside the _io_ras_install function we can see it backwards:

dev_ptr->RECV = "CLIENTSERVER";

dev_ptr->SEND = "CLIENT";

dev_ptr->RECV_SIZE = 12;

dev_ptr->SEND_SIZE = 6;

 

In the PPP (Point-to-Point) Example Application I tried to use _io_ras_install("ras:"); and configure my PC like a ppp server.

 

Using a signal analysis software tool I saw that the TWR52259 starts now with "CLIENT" and the PC responds with the "CLIENTSERVER" and then some data handshaking between both is seen and in the side of my PC (the SERVER) the CONNECTION LOG says "Connection Established". But in the side of the TWR52259 the _lwsem_wait(&ppp_sem); function never breaks, it is waiting for the PPP_linkup signal and it stays forever there.

 

Now here my last words....

 

1. Does what I am doing make any sense or not?

2. "There is no PPP Client implementation yet for the TWR52259. Wait for the MQX 3.8 version." is the final Answer and I am wasting my time tryng to get blood out of a stone?

3. Is it possible to connect to a local Network and to the internet (with a modem or router) through the serial cable (over ppp)?

 

Hope there is some solution for the problem.

Thank you very much and my best regards.

 

 

 

0 Kudos

1,401 Views
admin
Specialist II

Hello.

I successfully made the connection to the internet using the TWR52259 as ppp client and my PC as a ppp server which is connected to the Internet through a Router and sharing that connection through the serial cable.

 

Is just exactly as the ppp protocol says:

1. The Client (TWR52259) sends the "CLIENT" String.
2. The Server (The PC) responds with "CLIENTSERVER" String.
3. Then the negotiation begins and the client binds to the network through ppp.

 

The change in the _io_dun_install function is necessary so the TWR52259 sends a "CLIENT" string instead of "CLIENTSERVER" which is for servers.

what I did is to change the _io_dun_install("dun:"); line to _io_ras_install("ras:");

 

Using the signal analysis tool to see what was happening in the TX/RX lines of the serial cable I noticed that as the RAS driver and the PPP_DEVICE ("ittyc:" in my case) are installed the "CLIENT" string is sent immediately. At this point there is a possibility that the server is already in a ppp connection and the "CLIENT" string only finishes that connection and the server gets ready again to accept a new connection and then another "CLIENT" string is necessary. Now, this is a problem because sometimes the PC working as a server needs time to get ready to receive a another "CLIENT" string and start a new connection. Therefore I used the _io_dun_write with a _time_delay to give the server a little time to hang up the last connection and get ready to the new connection.

After all these changes I noticed that the server now always answer the second "CLIENT" string with "CLIENTSERVER" and gets ready to a new connection.

 

I implemented the very simple function:

static void PPP_linkdown (pointer lwsem) {printf("\nLink Down\n");}
for the link down event.


And a little change to the ipcp_data:

ipcp_data.IP_UP              = PPP_linkup;
ipcp_data.IP_DOWN            = PPP_linkdown;
ipcp_data.IP_PARAM           = &ppp_sem;
ipcp_data.ACCEPT_LOCAL_ADDR  = TRUE;//FALSE;//TRUE;
ipcp_data.LOCAL_ADDR         = INADDR_ANY;//PPP_LOCADDR;
ipcp_data.ACCEPT_REMOTE_ADDR = TRUE;
ipcp_data.REMOTE_ADDR        = INADDR_ANY;
ipcp_data.DEFAULT_NETMASK    = TRUE;
ipcp_data.NETMASK      = INADDR_ANY;
ipcp_data.DEFAULT_ROUTE      = TRUE;
ipcp_data.NEG_LOCAL_DNS     = FALSE;
ipcp_data.ACCEPT_LOCAL_DNS  = FALSE;
ipcp_data.LOCAL_DNS      = INADDR_ANY;
ipcp_data.NEG_REMOTE_DNS    = FALSE;
ipcp_data.ACCEPT_REMOTE_DNS = FALSE;
ipcp_data.REMOTE_DNS        = INADDR_ANY;


It is necessary to conect all the DB9 connector pins to the PC even if not using the hardware flow control. The PC needs some other signals, not only TX and RX. Alternatively you can use use a loop back handshaking db9 connector in the side of the PC if you spect to use only a TX/RX/GND cable. http://www.lammertbies.nl/comm/info/RS-232_null_modem.html (Null modem with loop back handshaking)

 

With all this, I succesfully got access to internet with the TWR52259 through the serial cable using my PC as bridge to the local network.

 

Now let's suppose that the ppp connection is lost (i.e. serial cable diconnected, PC restart, etcetera).

How can I implement an algorithm to reconnect to the PPP connection?

 

I tried to implement the reconnection algorithm by my self. For example every 10 seconds shut the PPP connection down and set it up again but I haven't been able to success.

 

I call the _iopcb_close(pio); function and the connection is successfully shouted down but never back again.

I don't know what functions I have to call in order to shut ppp connection down and start it again.

 

Does anyone knows?

 

I suppose it must be something like:

1. To shut the connection down:

  a)RTCS_if_unbind(ihandle, IPCP_get_local_addr(ihandle));   
  b)_iopcb_close(pio);  
  c)RTCS_if_remove(ihandle);


2. To set the connection up again:

  a)RTCS_if_add(phandle, RTCS_IF_PPP, &ihandle);
  b)_iopcb_open(pio, PPP_lowerup, PPP_lowerdown, phandle);
  c)error = RTCS_if_bind_IPCP(ihandle, &ipcp_data);


Any help will be very appreciated.


 

One more thing. I tested a ppp connection with a Wavecom Q64 modem:

 

First I tried a PC--Modem connection and I got internet access working perfect.

 

Now, it is obvious that TWR52259---PC---MODEM connection will be working fine. But I want to connect TWR52259 directly to the Modem.

 

Using the TWR52259--Modem I made a little change to the TWR52259 ppp example Changing the beginning string "CLIENT" to "ATD*99***1#". Using the signal analysis tool I see that the MODEM answers the "CONNECT 115200" string and then the PPP handshake begins but I get the NO CARRIER error.

Is there any extra configuration necessary for the Modem in order to make it works?(i.e. PAP, EAP, CHAP, security, passwords, etcetera).

I mean something such as the PPP connection configuration needed in the PC explained in the  PPP (Point-to-Point) Example Application documentation.


Thank you so much and my best regards.

0 Kudos

1,351 Views
netra
Contributor IV

Hi,

Can you please tell me the steps to create ppp connection in pc .

Thanks in advance,

netra

0 Kudos

1,401 Views
Vadym
Contributor I

I publish solution, that allowed me make PAP authenticated serial line connection.

I used direct serial connection, without any modems or something else, to be clear that problem only in our code.

I used … \MQX\src\rtcs\examples\shell demo application( my report and source code in attachment).

52259eva board like client and PC like server.  To make connection to PC first of all you need create “Incoming connection” in according with   PPP_example_readme_v1.doc (in attached files)

Next step is to add “Incoming Connection” user with same name and pass like you will use from client side.

In my example I used

Username :        ppp_user

Password:          Secret129456cz

You can see it in attached file demo.c

 

Next step is to change files chap.c and pap.c (I add that files to attachment, in directory …\solution\new_version_of_chap_pap )

Next step is in file  …\src\rtcs\source\include\ppp.h   change definition of PPP_SECRETS_NOT_SHARED from “1” to “0”

It must looks like :

#define PPP_SECRETS_NOT_SHARED 0

It will allow application to use _PPP_PAP_LSECRET variable directly. And now we need recompile rtcs library.

It will switch macros PPP_SECRET() from ppp.h   to right form to allow it to take right value of _PPP_PAP_LSECRET :

        

            #if PPP_SECRETS_NOT_SHARED

           #define PPP_SECRET(p,s) p->s

            #else

            #define PPP_SECRET(p,s) s            ACTIVE NOW

Next step is make some changes in application:

First of all we need define right username and password in file demo.c

In my case it is :

….

char localname[]    = "ppp_user";

char localsecret[]  = "Secret129456cz";

….

 

It is same like in “Incoming Connection” on PC.

Next important thing is to set global variable that will be used for client PAP authentication:

_PPP_PAP_LSECRET =  &lsecret;

All another variable related authentication must be NULL :

    _PPP_PAP_RSECRETS  = NULL;// rsecrets;

    _PPP_CHAP_LNAME    = NULL;// localname;

    _PPP_CHAP_LSECRETS = NULL;// lsecrets;

    _PPP_CHAP_RSECRETS = NULL;// rsecrets;

I attached all my source code, pictures of board terminal window, pictures of PC incoming connection,new chap.c and pap.c files,

and communication log between our board and PC during PAP authentication process(…\solution\report_datas\ppp_PAP_connection_log.txt).  

It is end.

 

Do not forger to configure board like client in config.h

#define PPP_DEVICE_DUN  0    /* The board serves as the PPP server */

#define PPP_DEVICE_RAS  1    /* The board serves as the PPP client */

 

All source files from my test project you can found in attachment in dir …\solution\source_of_shell  .

If you found something wrong, give me know . 

0 Kudos

1,401 Views
Vadym
Contributor I

I have done PPP example for m52259evb and MQX3.8.0 . It can close and open PPP PAP through GPRS connection without any memory leak. I use ping command to be sure connection was established with internet well.

To use this example you need change next files in MQX\src\rtcs\source\

include\ppp.h

include\ppp_prv.h

ppp\chap.c

ppp\pap.c

ppp\pktrx.c

ppp\ppphdlc.c

os\mqx25x\rtcspart.c

copy to \rtcs\examples\ folder “shell_PAP_GPRS”. Pay some attention to GPRS init function( SIM pin number, internet name... )

Use user_config.h from archive for libs for m52259evb or use it like example for another CPU.

Rebild PSP,BSP,RTCS libs.

 

0 Kudos

1,401 Views
CaesarI
Contributor III

Hi Vadym,

Vadym Volokitin schrieb:

I used … \MQX\src\rtcs\examples\shell demo application( my report and source code in attachment).

I wanted to comprehend your solution, but I do'nt know how to find your attachment in this thread (I'm very new in this forum but interested in using GPRS Modem to connect via PPP).

May anyone help?


regard,

Caesar

0 Kudos

1,401 Views
c0170
Senior Contributor III

Hello,

I have attached vadym's zip file with the fix. Follow his instructions in above post.

There is release of MQX 4.0 soon, PPP will be there :smileywink:

Regards,

MartinK

0 Kudos

1,401 Views
CaesarI
Contributor III

Hello Martin,

I tryed to connect to GPRS network, got CONNECT and IP address, but all ping requests used in the example application got lost (error code 0x1510 = no route to host).

My system is a TWRK60, has a working RTCS on ethernet and should get an GRPS interface aditionally. Both interfaces should work parallel and simultaneously to serve a web site and some other TCP things...


So, I do'nt understand why the PPP over serial (GPRS) does'nt be integrated in the RTCS. I thought, binding the serial interface like RTCS_if_bind_IPCP brings all serial traffic to the TCP/IP stack and conversely... but no ping request sended by my application went out of the tty an no ping request on the tty forces a reaction.

What's my mistake?

Note: while adding the PPP interface to the RTCS some other task serving TCP communication over ethernet works fine (steadily communicates with a client, pings to othe hosts and answers on ping requests). Is'nt it possible to use two interfaces at one time?

Do you need more information to help?

I hope I'm reading from you before christmas - otherwise MERRY CHRISTMAS!

Caesar

0 Kudos

1,401 Views
BryGuyH
Contributor IV

Yeah we have half a dozen mods to the ppp module (everything from memory leaks - which should be fixed in 4.0 from what I'm told - to link negotiation). I think you're interested in this one from ipcpfsm.c

static boolean IPCP_up

   (

      PPPFSM_CFG_PTR    fsm

            /* [IN] - State Machine */

   )

{ /* Body */

   IP_IF_PTR            if_ptr = fsm->PRIVATE;

   IPCP_CFG_STRUCT_PTR  ipcp_ptr = if_ptr->HANDLE;

   /* Bind the negotiated IP address to this interface */

   ipcp_ptr->BIND_PARMS.ihandle = if_ptr;

   ipcp_ptr->BIND_PARMS.address = ipcp_ptr->LOPT.ADDR;

   ipcp_ptr->BIND_PARMS.network = ipcp_ptr->POPT.ADDR?ipcp_ptr->POPT.ADDR:((ipcp_ptr->LOPT.ADDR & IN_CLASSC_NET) + 1);

   //ipcp_ptr->BIND_PARMS.network = ipcp_ptr->POPT.ADDR;

   ipcp_ptr->BIND_PARMS.netmask = INADDR_ANY;

 

   RTCSCMD_smartissue(ipcp_ptr->BIND_PARMS, IPIF_bind_ppp);

   /* Install a default gateway */

   if (ipcp_ptr->INIT.DEFAULT_ROUTE) {

      ipcp_ptr->GATE_PARMS.address = ipcp_ptr->POPT.ADDR?ipcp_ptr->POPT.ADDR:((ipcp_ptr->LOPT.ADDR & IN_CLASSC_NET) + 1);

      //ipcp_ptr->GATE_PARMS.address = ipcp_ptr->POPT.ADDR;

      ipcp_ptr->GATE_PARMS.network = INADDR_ANY;

      ipcp_ptr->GATE_PARMS.netmask = INADDR_ANY;

      /* Start CR 1133 */

      ipcp_ptr->GATE_PARMS.locmask = 0;

      /* End CR 1133 */

      RTCSCMD_smartissue(ipcp_ptr->GATE_PARMS, IPIF_gate_add);

   } /* Endif */

#if RTCSCFG_ENABLE_DNS || RTCSCFG_ENABLE_LWDNS

   /* Set up the primary DNS server */

   if (ipcp_ptr->NEG.NEG_DNS) {

#if RTCSCFG_ENABLE_DNS

      /* Start CR 2257 */

      DNS_SLIST_STRUCT slist_entry;

      DNS_init_slist_entry(&slist_entry);

      slist_entry.IPADDR = ipcp_ptr->LOPT.DNS;

      if (DNS_add_slist_entry(&slist_entry) != DNS_OK)

         return FALSE;

      /* End CR 2257 */

#else

      LWDNS_server_ipaddr = ipcp_ptr->LOPT.DNS;

#endif

   } /* Endif */

#endif

   if (ipcp_ptr->IP_UP) {

      ipcp_ptr->IP_UP(ipcp_ptr->IP_PARAM);

   } /* Endif */

   return TRUE;

} /* Endbody */

0 Kudos

1,401 Views
CaesarI
Contributor III

Thx, now I saw you released MQX 4.0 already on the 14. of december, now I try to port the applicaton to MQX 4.0 an will tell you the result soon.

Caesar

0 Kudos

1,355 Views
BryGuyH
Contributor IV

I don't work for Freescale. The fixes I posted above to ppp for the default route and dns server are not in 4.0

0 Kudos

1,401 Views
CaesarI
Contributor III

Hello Martin,

I edited this post, cause there where korrupt file properties in my project, so no updated library was used....


Thx, Caesar

0 Kudos

1,401 Views
JerryK
Contributor I

Do MQX version 4.0 when using GPRS Modem to connect via PPP, communication will be possible by CMUX?

0 Kudos

1,401 Views
c0170
Senior Contributor III

Hello Jaroslaw,

what are you exactly asking ? I am sorry, but I am not able to understand your question.

Regards,

MartinK

0 Kudos

1,401 Views
JerryK
Contributor I

Hello,

CMUX in GSM modem (multiplexer mode) enables one serial interface to transmit data to a few different customer

applications. This is achieved with the Multiplexer (CMUX) that provides a few virtual channels.

This is represents a great advantage for fax, data, and GPRS ongoing calls. Thanks to the Multiplexer

feature operations such as controlling the module or using the SMS service can be done via the

additional channels without disturbing the data flow and no access to the second UART is necessary.

To access the a few virtual interfaces, both the GSM engine and the customer application must

contain CMUX components that communicate over the multiplexer protocol.

In Multiplexer mode, AT commands and data are encapsulated into packets. Each packet has channel

identification and may vary in length.

I would like to do so that the data transmission in MQX between the PPP and the UART also passed through function CMUX.


0 Kudos

1,401 Views
CaesarI
Contributor III

Thanks, next week I will try to realize.

Caesar

0 Kudos

1,401 Views
Niall
Contributor II

Vadym,

I have made the RTCS file changes you suggested. My GPRS application code is similar to yours. I am seeing some problems with my application: -

 

1. Closing the PPP connection leaves an invalid message pool

2. Error 0x1505 when RTCS_if_unbind() is called (Invalid local address). Do you see this in your application?

3. I am seeing a problem with connecting a TCP/IP socket to a remote server. The code you posted creates a PPP connection and performs a ping with a remote server. This functionality also works fine on my application. I can close a PPP connection, then reconnect and the ping will always work.  However connecting a TCP/IP socket to the remote server does not always work with second and subsequent socket connections. The first TCP/IP connection to the remote server always works. When I close the PPP connection and try to make a new connection a timeout failure occurs in 9 out of 10 attempts. The problem seems to be due to a memory partition issue - see debugger screenshot in attached file. This may be de to the RTCS interface not being unbound (see 2. above)

 

Is there a way to shut down the TCP/IP task and clean up it's resourses before making a reconnection attempt? I guess what I am looking for is the opposite to the RTCS_create() function. Currently I need to perform a software reset between server connections in order to restart the TCP/IP task. This is not a good solution.

 

I have attached a zip file with my C code and a word document showing debugger screenshots and console output.

 

Any help would be appreciated.

0 Kudos

1,401 Views
Vadym
Contributor I

Thank you for report Niall. I need some time to fix this problem. But now I realy overloaded. 

0 Kudos