This discussion has been locked.
You can no longer post new replies to this discussion. If you have a question you can start a new discussion

PPP using TCP client socket

Hello,

I'm having trouble using TCP client socket on a PPP link.

I'm using Keil RTX 4.74.0 and MDK-Pro 5.0.4

PPP is established using a GPRS modem (I have updated the Modem_Standard.c to deal with network registration and so on)

In my main loop, once ppp_is_up() == true, I create a tcp_socket using :
tcp_soc = tcp_get_socket (TCP_TYPE_CLIENT|TCP_TYPE_FLOW_CTRL, 0, 30, tcp_callback);

and then connect it using :
tcp_connect (tcp_soc, rem_ip, 9301, 0);

The server is a http server.

Once the connection is established, the callback is then called from the Core Network with event == tcpEventEstablished. When this event is called, the main loop gets a flag indicating that it's time to write the request to the socket.

The write part is working and I receive a tcpEventACK in the callback.

The server on the other side well receive the request and sends the answer, but, the callback never gets called with the tcpEventData. In the end, the socket is closed and finaly aborted.

I have a serial spy where I can see the PPP dialog and I can see both the request and the answer.

Where do you think I go wrong ?

Thanks,

Alain.

Parents
  • Hello Franc,

    Again, thanks for your suggestion.

    As I'm using MDK-Pro framework and Cortex M4, this one is using the STM32F4 UART driver.
    I have "unlocked" the UART_STM32F4xx.c file and updated the __UART1_RX_BUFFER_SIZE (initial value was 128) from 1K to 4K and nothing has changed, still FCS Check Failed.

    I have change serial cables that are used between my MCBSTM32F400 board and my modem without success too.

    Next thing I will try to do is writing an IP server that would simply send echo to see if the problem has to deal with message length (I doubt about this because I also receive FCS check fail on simple LCP echo command :

    641.0 PPP:Sending frame
    641.0 PPP: Protoc: LCP
    641.0 PPP: Length: 12
    641.0 PPP:*** Processing frame ***
    641.0 PPP: Protoc: LCP
    641.0 PPP: Length: 12 bytes
    641.0 PPP:*** Processing LCP frame ***
    641.0 PPP: Code : Echo_Rep
    641.0 PPP: Id_Val: 0x17
    641.0 PPP: Length: 8
    641.0 PPP: Magic-Number: 0x367651BD
    671.0 PPP:LCP Send Echo Request
    671.0 PPP: Magic-Number: 0xD0102765
    671.0 PPP:Sending LCP frame
    671.0 PPP: Code : Echo_Req
    671.0 PPP: Id_Val: 0x18
    671.0 PPP: Length: 8
    671.0 PPP:Sending frame
    671.0 PPP: Protoc: LCP
    671.0 PPP: Length: 12
    671.0 PPP:*** Processing frame ***
    671.0 PPP: Length: 9 bytes
    671.0 PPP-ERR:Frame FCS Check Failed
    671.1 PPP:*** Processing frame ***
    671.1 PPP: Length: 18 bytes
    671.1 PPP-ERR:Frame FCS Check Failed
    673.0 PPP:LCP Send Echo Request
    673.0 PPP: Magic-Number: 0xD0102765
    673.0 PPP:Sending LCP frame
    673.0 PPP: Code : Echo_Req
    673.0 PPP: Id_Val: 0x18
    673.0 PPP: Length: 8
    673.0 PPP:Sending frame
    673.0 PPP: Protoc: LCP
    673.0 PPP: Length: 12
    673.0 PPP:*** Processing frame ***
    673.0 PPP: Protoc: LCP
    673.0 PPP: Length: 12 bytes
    673.0 PPP:*** Processing LCP frame ***
    673.0 PPP: Code : Echo_Rep
    673.0 PPP: Id_Val: 0x18
    673.0 PPP: Length: 8
    673.0 PPP: Magic-Number: 0x367651BD
    703.0 PPP:LCP Send Echo Request
    703.0 PPP: Magic-Number: 0xD0102765
    703.0 PPP:Sending LCP frame
    703.0 PPP: Code : Echo_Req
    703.0 PPP: Id_Val: 0x19
    703.0 PPP: Length: 8
    703.0 PPP:Sending frame
    703.0 PPP: Protoc: LCP
    703.0 PPP: Length: 12

    Thanks,

    Alain.

Reply
  • Hello Franc,

    Again, thanks for your suggestion.

    As I'm using MDK-Pro framework and Cortex M4, this one is using the STM32F4 UART driver.
    I have "unlocked" the UART_STM32F4xx.c file and updated the __UART1_RX_BUFFER_SIZE (initial value was 128) from 1K to 4K and nothing has changed, still FCS Check Failed.

    I have change serial cables that are used between my MCBSTM32F400 board and my modem without success too.

    Next thing I will try to do is writing an IP server that would simply send echo to see if the problem has to deal with message length (I doubt about this because I also receive FCS check fail on simple LCP echo command :

    641.0 PPP:Sending frame
    641.0 PPP: Protoc: LCP
    641.0 PPP: Length: 12
    641.0 PPP:*** Processing frame ***
    641.0 PPP: Protoc: LCP
    641.0 PPP: Length: 12 bytes
    641.0 PPP:*** Processing LCP frame ***
    641.0 PPP: Code : Echo_Rep
    641.0 PPP: Id_Val: 0x17
    641.0 PPP: Length: 8
    641.0 PPP: Magic-Number: 0x367651BD
    671.0 PPP:LCP Send Echo Request
    671.0 PPP: Magic-Number: 0xD0102765
    671.0 PPP:Sending LCP frame
    671.0 PPP: Code : Echo_Req
    671.0 PPP: Id_Val: 0x18
    671.0 PPP: Length: 8
    671.0 PPP:Sending frame
    671.0 PPP: Protoc: LCP
    671.0 PPP: Length: 12
    671.0 PPP:*** Processing frame ***
    671.0 PPP: Length: 9 bytes
    671.0 PPP-ERR:Frame FCS Check Failed
    671.1 PPP:*** Processing frame ***
    671.1 PPP: Length: 18 bytes
    671.1 PPP-ERR:Frame FCS Check Failed
    673.0 PPP:LCP Send Echo Request
    673.0 PPP: Magic-Number: 0xD0102765
    673.0 PPP:Sending LCP frame
    673.0 PPP: Code : Echo_Req
    673.0 PPP: Id_Val: 0x18
    673.0 PPP: Length: 8
    673.0 PPP:Sending frame
    673.0 PPP: Protoc: LCP
    673.0 PPP: Length: 12
    673.0 PPP:*** Processing frame ***
    673.0 PPP: Protoc: LCP
    673.0 PPP: Length: 12 bytes
    673.0 PPP:*** Processing LCP frame ***
    673.0 PPP: Code : Echo_Rep
    673.0 PPP: Id_Val: 0x18
    673.0 PPP: Length: 8
    673.0 PPP: Magic-Number: 0x367651BD
    703.0 PPP:LCP Send Echo Request
    703.0 PPP: Magic-Number: 0xD0102765
    703.0 PPP:Sending LCP frame
    703.0 PPP: Code : Echo_Req
    703.0 PPP: Id_Val: 0x19
    703.0 PPP: Length: 8
    703.0 PPP:Sending frame
    703.0 PPP: Protoc: LCP
    703.0 PPP: Length: 12

    Thanks,

    Alain.

Children
  • You using UART to communicate with the modem? Have you verified the baudrate?

    Note that the modem might be able to accept a larger baudrate error when receiving data from you, than what your side is able to handle when receiving data from the modem.

    Next thing - is the UART using DMA or FIFO or similar that helps avoiding character loss in case you get a bit of interrupt latency because of some other interrupt handler consuming too much time or some part of your code turning off interrupts in critical sections?

  • Hello,

    Got good and bad news :
    - It's working
    - Keil's Driver or Keil RLNet gots bug at some points

    After digging deep in the source code of the Keil UART Driver :
    - The UART initialisation is done using a callback that should be called on ARM_UART_EVENT_RX_NOT_EMPTY event. But ARM_UART_EVENT_RX_NOT_EMPTY is never fired in the UART IRQ Processing.
    - The RLNet PPP is contantly pooling the UART using UART_DataAvailable and UART_ReadData accordingly to the returned available number of data returned.

    At some point (don't know when / don't want to spend more time on that issue) the UART_ReadData is called using a 64 byte size request whereas only 1 byteis available in the UART cyclic buufer.

    This result in FCS check error (I this RLNet process 64 Bytes where only 1 has been filled ...)

    I have solved the problem changing the UART_DataAvailable core function to return 1 whenever ptr_uart->info->rx.empty equal false.

    Many thanks for having pointing me in the UART direction.

    Alain.