PPP over serial

cancel
Showing results for 
Search instead for 
Did you mean: 

PPP over serial

12,197 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,022 Views
carlnormansuret
Contributor V

Hi all,

I wonder if someone would be willing to give some pointers / advice on how to go about making a simple 3G router out of the TWR52259 / TWR-SER board with MQX and a USB modem? 

I have the following hardware connected on my desk:

- TWR52259 MQX4.2 with TWRSER (Ethernet / Serial board) on the tower which all works fine

- Telit HE910 modem eval kit (3G modem module) connected via USB to the TWR-SER USB port. The CDC driver i have not gotten to work as yet, I cant work out how to have multiple serial ports (one for AT one for PPP), I cant even get a single one to work, it does connect though.

- I have a Laptop connected to the ethernet socket on the TWRSER which would be used to test the TWR Gateway solution (surf the net).

I believe I need to do these steps:

- Get the CDC driver working so we can communicate with HE910 on the USB port (work out how to get one AT type command port and one for PPP), I tried changing device type to "ttyACM0:" but no luck getting AT / OK response.

- Make a PPP client connection (ras:) on that USB CDC port(s), i think this might not be to hard after CDC is working/.

- somehow bind(?) the PPP connection to my Ethernet port so all IP data is sent out via the PPP connection, and any data coming in the PPP connection is routed out.

- create port forwarding rules

- block/white list IP's

I think I can work through it all over time, but this project seems like it would be common, and maybe someone would like to inbox me even if they want a quick job to take on / consult on, or maybe someone is willing to share...?

0 Kudos

1,024 Views
netra
Contributor IV

Hi Ceaser,

Request is sent by RTU(Board)

Response is sent by Modem

Request:-   54 0D 0A                                          AT..

Response:-  0D 0A 4F 4B 0D 0A                                 ..OK..

Request:- 41 54 2B 43 47 44 43 4F 4E 54 3D 31 2C 22 49 50     AT+CGDCONT=1,"IP

22 2C 22 61 69 72 74 65 6C 67 70 72 73 2E 63 6F             ","airtelgprs.co

6D 22 0D 0A                                                   m"..

 

 

Response:- 0D 0A 4F 4B 0D 0A                                  ..OK..

Request:-   41 54 44 54 2A 39 39 23 0D 0A                       ATDT*99#..

Response:-   0D 0A 43 4F 4E 4E 45 43 54 0D 0A                ..CONNECT..

         7E FF 7D 23 C0 21 7D 21 7D 21 7D 20 7D 32 7D 22 7D 26 7D 20 7D 2A 7D 20 7D 20 7D 23 7D 24 C0 23 7D 27 7D 22 7D 28 7D 22 55 83 7E

Request:- 7E FF 7D 23 C0 21 7D 21 90 7D 20 7D 2E 7D 22 7D 26 7D 20 7D 20 7D 20 7D 20 7D 27 7D 22 7D 28 7D 22 AF AD 7E

 

Response:- 7E FF 7D 23 C0 21 7D 23 90 7D 20 7D 2A 7D 22 7D 26 7D 20 7D 2A 7D 20 7D 20 D2 26 7E

Request:-  7E FF 7D 23 C0 21 7D 24 7D 21 7D 20 7D 28 7D 23 7D 24 C0 23 2C D4 7E

Response:-7E FF 7D 23 C0 21 7D 21 7D 22 7D 20 7D 2E 7D 22 7D 26 7D 20 7D 2A 7D 20 7D 20 7D 27 7D 22 7D 28 7D 22 D0 D3 7E

Request:-   7E FF 7D 23 C0 21 7D 21 91 7D 20 7D 2A 7D 22 7D 26 7D 20 7D 2A 7D 20 7D 20 61 33 7E

Response:-   7E FF 7D 23 C0 21 7D 22 91 7D 20 7D 2A 7D 22 7D 26 7D 20 7D 2A 7D 20 7D 20 7D 28 47 7E

Request:-7E FF 7D 23 C0 21 7D 22 7D 22 7D 20 7D 2E 7D 22 7D 26 7D 20 7D 2A 7D 20 7D 20 7D 27 7D 22 7D 28 7D 22 EE 50 7E

Response:-  7E 80 21 01 01 00 04 BB 99 7E 7E 80 21 01 01 00 04 BB 99 7E

Request:-  7E FF 7D 23 C0 21 7D 21 91 7D 20 7D 2A 7D 22 7D 26 7D 20 7D 2A 7D 20 7D 20 61 33 7E

Response:-  7E 80 21 01 01 00 04 BB 99 7E 7E 80 21 01 01 00 04 BB 99 7E 7E 80 21 01 01 00 04 BB 99 7E 7E 80 21 01 01 00 04 BB 99 7E

Request:-  7E FF 7D 23 C0 21 7D 21 91 7D 20 7D 2A 7D 22 7D 26 7D 20 7D 2A 7D 20 7D 20 61 33 7E

Response:-  7E 80 21 01 01 00 04 BB 99 7E 7E 80 21 01 01 00 04 BB 99 7E7E 80 21 01 01 00 04 BB 99 7E 7E 80 21 01 01 00 04 BB 99 7E

Request:-  7E FF 7D 23 C0 21 7D 21 91 7D 20 7D 2A 7D 22 7D 26 7D 20 7D 2A 7D 20 7D 20 61 33 7E

Response:-  7E 80 21 01 01 00 04 BB 99 7E 7E 80 21 01 01 00 04 BB 99 7E

Request:-  7E FF 7D 23 C0 21 7D 21 91 7D 20 7D 2A 7D 22 7D 26 7D 20 7D 2A 7D 20 7D 20 61 33 7E

Response:- 7E 80 21 01 01 00 04 BB 99 7E 7E 80 21 01 01 00 04 BB 99 7E

Request:- 7E FF 7D 23 C0 21 7D 21 91 7D 20 7D 2A 7D 22 7D 26 7D 20 7D 2A 7D 20 7D 20 61 33 7E

Response:-  7E 80 21 01 01 00 04 BB 99 7E 7E 80 21 01 01 00 04 BB 99 7E

Request:-  7E FF 7D 23 C0 21 7D 21 91 7D 20 7D 2A 7D 22 7D 26 7D 20 7D 2A 7D 20 7D 20 61 33 7E

Response:- 7E 80 21 01 01 00 04 BB 99 7E 7E 80 21 01 01 00 04 BB 99 7E

Request:-  7E FF 7D 23 C0 21 7D 21 91 7D 20 7D 2A 7D 22 7D 26 7D 20 7D 2A 7D 20 7D 20 61 33 7E

Response:- 7E 80 21 01 01 00 04 BB 99 7E 7E 80 21 01 01 00 04 BB 99 7E

Request:- 7E FF 7D 23 C0 21 7D 21 91 7D 20 7D 2A 7D 22 7D 26 7D 20 7D 2A 7D 20 7D 20 61 33 7E

Response:- 7E 80 21 01 01 00 04 BB 99 7E 7E 80 21 01 01 00 04 BB 99 7E

Request:-  7E FF 7D 23 C0 21 7D 21 91 7D 20 7D 2A 7D 22 7D 26 7D 20 7D 2A 7D 20 7D 20 61 33 7E

Response:-   7E 80 21 01 01 00 04 BB 99 7E 7E 80 21 01 01 00 04 BB 99 7E

Request:- 7E FF 7D 23 C0 21 7D 26 7D 23 7D 20 7D 24 48 57 7E

Response:-   7E FF 03 C0 21 05 03 00 04 85 72 7E 7E FF 7D 23 C0 21 7D 25 7D 23 7D 20 7D 24 85 72 7E 0D 0A 4E 4F 20 43 41 52 52 49 45 52 0D 0A

 

 

Thanks in advannce,

Netra

0 Kudos

1,024 Views
CaesarI
Contributor III

Hi Netra,

the end of your modem communication is NO CARRIER. That means your communication in protocolls LCP, IPCP and CCP to establish the PPP connection are not ok! Please encode the HDLC and decode the protocolls. Then you will see the problem.

Your ipcp_data structure need to be well defined. I use the following content:

         ipcp_data.IP_UP          = PPP_linkup;
         ipcp_data.IP_DOWN        = PPP_linkdown;
         ipcp_data.IP_PARAM       = &ppp_sem;
         ipcp_data.ACCEPT_LOCAL_ADDR  = TRUE;
         ipcp_data.ACCEPT_REMOTE_ADDR = TRUE;
         ipcp_data.DEFAULT_NETMASK= TRUE;
         ipcp_data.DEFAULT_ROUTE  = TRUE;
         ipcp_data.NEG_LOCAL_DNS  = TRUE;
         ipcp_data.NEG_REMOTE_DNS = FALSE;
         ipcp_data.ACCEPT_LOCAL_DNS   = TRUE;
         ipcp_data.ACCEPT_REMOTE_DNS  = TRUE;

         ipcp_data.LOCAL_DNS      = INADDR_ANY;
         ipcp_data.LOCAL_ADDR     = INADDR_ANY;
         ipcp_data.NETMASK        = INADDR_ANY;
         ipcp_data.REMOTE_DNS     = INADDR_ANY;
         ipcp_data.REMOTE_ADDR    = INADDR_ANY;

best regards,

Caesar

0 Kudos

1,024 Views
netra
Contributor IV

Hi caesarl,

I have upgraded MQX 3.5 to 4.1.1  .

I have successfully established connection between MCF52259 (PPP client) and PC (PPP server).

Now ,I want to connect MCF52259 (PPP client) and Modem (PPP server).

But the connection is getting failed , MCF is sending string "CLIENTCLIENT" and waiting for string "CLIENTSERVER".

which modem never replies.

How to go further ??

Please do reply

Regards,

Netra

0 Kudos

1,024 Views
shankarnaragoni
Contributor I

Hi netra,

I am new PPP over serial port driver and how to configure ppp over serial Can you please tell me the steps to create ppp connection in pc. please share ur ideas.

         

Best & Regards,

shankar

0 Kudos

1,024 Views
voider
Contributor II

Hi, I'm working on the same problem:

GPRS connected and need to send AT commands to check signal and SMS.

PPP is connecting and working ok, but I'm not sure in which way to go.

Anyone found a good solution? CMUX  or something else?

0 Kudos

1,024 Views
netra
Contributor IV

Hi voider,

I have already created ppp connection in mqx(It is working with pc ppp client connection) and want to connect with modem using dial up ppp at commands.

But. unable to connect can u tell me is there any problem in my code :-

io_dun_install("dun:");

    pfile = fopen("dun:", (char_ptr)comport.handle);

    pio = _iopcb_ppphdlc_init(pfile);

   

    error = PPP_initialize(pio, &phandle);

    if (error) {

       printf("\nPPP initialize: %lx", error);

       _task_block();

    } /* Endif */

    _iopcb_open(pio, PPP_lowerup, PPP_lowerdown, phandle);

    error = RTCS_if_add(phandle, RTCS_IF_PPP, &ihandle);

    if (error) {

       printf("\nIF add failed, error = %lx", error);

       _task_block();

    } /* Endif */

    _lwsem_create(&ppp_sem, 0);

    _mem_zero(&ipcp_data, sizeof(ipcp_data));

    ipcp_data.IP_UP = PPP_linkup;

    ipcp_data.IP_DOWN = NULL;

    ipcp_data.IP_PARAM = (pointer)&ppp_sem;

    ipcp_data.ACCEPT_LOCAL_ADDR = TRUE;

    ipcp_data.LOCAL_ADDR = PPP_LOCADDR;

    ipcp_data.ACCEPT_REMOTE_ADDR = TRUE;

    ipcp_data.REMOTE_ADDR = PPP_PEERADDR;

    ipcp_data.DEFAULT_NETMASK = TRUE;

    ipcp_data.NETMASK = 0;

    ipcp_data.DEFAULT_ROUTE = TRUE;

    ipcp_data.NEG_LOCAL_DNS = FALSE;

    ipcp_data.ACCEPT_LOCAL_DNS = 0;

    ipcp_data.LOCAL_DNS = 0;

    ipcp_data.NEG_REMOTE_DNS = FALSE;

    ipcp_data.ACCEPT_REMOTE_DNS = 0;

    ipcp_data.REMOTE_DNS = 0;

Please reply

Thanks in advance

netra

0 Kudos

1,024 Views
CaesarI
Contributor III

Hi netra,

I can't remember why, but we use 'ras' instead of' 'dun' and it works...

_io_ras_install("ras:");

if ((pRasFile = fopen("ras:", (char_ptr)comport.handle)) != NULL) { ...

An example to send the different AT commands to open a ppp connetion via dial up modem you will find there.

Your ipcp_data struct will be revised if you want to get a DNS by your mobile network.

1,024 Views
netra
Contributor IV

Hi Caesarl

Thanks for your reply.

Changing to "RAS " means you made your ppp code as client .

But i need to know how ur modem communicates with modem .

Do send AT command before starting ppp or afterwards?

Can you share your log featuring ppp connection establishment between modem and board?

I will have clear idea who sends request for ppp and does it send "CLIENT" string as mentioned in ppp stack & how modem handles it.

Please do reply

netra

0 Kudos

1,024 Views
CaesarI
Contributor III

Hi Netra,

look careful at the file \ppp_fix\rtcs\examples\shell_PAP_GPRS\gprs.c of the PPP example in this thread...

There you will find the procedure to talk with your modem.

Caesar

1,024 Views
netra
Contributor IV

Hi Caesarl ,

Thankyou  for your fast reply .

Looking into the complete code , I found out there are two terminal one for ppp connection another was terminal connection for at commands .

What ever i understood is it correct?

I have only one serial port through which i have to start ppp & send at commands will it work??

Thanks in advance

Regards,

Netra

0 Kudos

1,024 Views
CaesarI
Contributor III

Hi Netra,

you need one seriel port only. The serial port will be open for modem communication, then after receiving CONNECT of ATD the handle will pass to the ras device to open and use the PPP connection... after closing the PPP connection you may use the serial port to communicate via AT commands - but not during an open PPP connection (except you will use CMUX)

Caesar.

1,024 Views
netra
Contributor IV

Hi Caesar,

Thanks for your  replies.

I went through the ppp_fix folder . I saw there are many changes in bsp file of ppp(for e.g :- ppphdlc.c,pktrx.c) .

These changes are made by you or originally present as i am using mqx version 3.5.

Please do reply.

regards,

netra

0 Kudos

1,024 Views
CaesarI
Contributor III

Hi netra,

I don't know what to do in MQX 3.5. Freescale released the ppp_fix while MQX 3.8 was the current version. Now the version 4.1 is available - I suggest to change to MQX 4.1 for your test...

0 Kudos

1,024 Views
JerryK
Contributor I

Hello,

I have MXQ 4.0 + PPP + GSM modem.

Initiates a PPP connection and then uses the TCP / IP stack.

fgsm_ptr = fopen("ittyb:",0);

fppp_ptr = fopen("ras:", (char_ptr)fgsm_ptr);

pio = _iopcb_ppphdlc_init(fppp_ptr);

PPP_initialize(pio, &phandle);

....

When PPP connections from time to time I want to go to the AT command line and check the SMS.

GSM modems as standard output of the transmission channel send to the modem +++, to re-enter the transmission channel send ATO.

How can I suspend on some time PPP and have access to a GSM modem?

Jaroslaw

0 Kudos

1,024 Views
CaesarI
Contributor III

Hi Jaroslaw,

did you find a usefull solution?

I think crashing the PPP connection to check network state, radio signal quality and SMS state is not a valid method...

Thx,

Caesar

0 Kudos

1,024 Views
Martin_
NXP Employee
NXP Employee

One possible solution for this is using MQX FIFO preemptive scheduling.

Assuming PPP task is priority 10. You can have an at_command_task with a higher priority 9, initially blocked.

A time to time, for example by a BSP timer interrupt, or from a switch (gpio input) interrupt, you can post a semaphore to make the at_command_task ready.

As it has higher priority than PPP task, PPP task becomes ready and at_command_task becomes active.

From this task, you can read/write from/to MQX serial driver. The only consideration is that the at_command_task has to use only non-blocking functions (including serial driver read and write functions). After serial communication is done in non-blocking manner, just block the task by a semaphore wait and PPP task would be activated.

0 Kudos

1,024 Views
CaesarI
Contributor III

Hi Martin,

thanks for your answer.

Your proposal might be only usable for small applications. We have an application that communicates over ethernet interface and do some control applications. There are also one task that continiously communicates to a GPRS modem using AT and PPP. I prefer using this modem task to prevent for double allocation of the 'local' modem object (handling the tty interface). Inside the modem task works a state machine using blocking functions to ensure other tasks (applications) to get time.

Now we will try to modify the tasks PPP_rx and PPP_tx to interrupt there work by message of modem_task reps. BSP timer to transfer the tty access to the modem task.

best regards,

Caesar

0 Kudos

1,024 Views
JerryK
Contributor I

Hello,

I modified the task PPP_rx_task, in a loop that checks if something came I added your flag, when sending SMS I set a flag and then I put out.

Jaroslaw


0 Kudos

1,070 Views
CarlFST60L
Senior Contributor II

I am also very interested in this solution, I have some hardware setup for exactly this requirment, though I currently use the GSM to create the PPP connection and use the built in socket control. It would be great to move these smarts back to the processor...

0 Kudos