реклама на сайте
подробности

 
 
> STM32 lwIP PPPoS, STM32 lwIP PPPoS
eisufu
сообщение Jul 9 2012, 16:53
Сообщение #1


Участник
*

Группа: Участник
Сообщений: 33
Регистрация: 29-06-10
Пользователь №: 58 196



Не знаю, существуют ли русскоязычные гуру в PPP, но рискну.
На STM32F407 крутится FreeRTOS с lwIP. Пытаюсь установить PPP-соединение, но оно не устанавливается до конца. Собрал с выводом диагностической информации (лог - ниже), но интерпретировать не могу. Видел в интернете, что у людей возникают схожие проблемы, но решений и у них нет. Помогите пожалуйста найти решение проблемы.
Пакеты фрагментируются, та как приходится перенаправлять траффик с USB-модема, подключённого к компьютеру, на устройство и обратно. Скрипт в режиме поллинга с периодом 0.1 секунды читает и пишет из виртуального COM-порта USB-модема в COM-порт, к которому подключено устройство, и наоборот. Думаю пакеты из байтов должны нормально собираться. sio_read не бесконечно блокирующая, стоит таймаут 1.5 секунды. Иначе вообще ничего не получается.
CODE
send: 'ATZ0 E0 V0'
recv:
0
send: 'ATS0=0'
recv:
0
send: 'AT+CGDCONT=1,"IP","internet.mts.ru"'
recv:
0
send: 'ATDT*99#'
recv:
1
lcp_init: xmit_accm=0 0 0 0
upap_init: 0
pppOverSerialOpen: unit 0: Connecting
pppStart: unit 0
ppp_set_xaccm[0]: outACCM=0 0 0 0
ppp_send_config[0]: outACCM=FF FF FF FF
ppp_recv_config[0]: inACCM=0 0 0 0
lcp_lowerup: asyncmap=0 0 0 0
LCP: lowerup state 0 (LS_INITIAL) -> 2 (LS_CLOSED)
auth_reset: 0
lcp_addci: L opt=2 0
lcp_addci: L opt=5 52181044
lcp_addci: opt=7
lcp_addci: opt=8
pppWrite[0]: len=47
fsm_sdata(LCP): Sent code 1,1,20.
LCP: sending Configure-Request, id 1
LCP: open state 2 (LS_CLOSED) -> 6 (LS_REQSENT)
pppStart: finished
pppInProc[0]: got 154 bytes
pppInput[0]: LCP len=25
fsm_input(LCP):1,224,25
fsm 0
lcp_addci: L opt=5 33CF11CE
lcp_addci: opt=7
lcp_addci: opt=8
pppWrite[0]: len=46
fsm_sdata(LCP): Sent code 1,2,20.
LCP: sending Configure-Request, id 2
lcp_reqci: rcvd ASYNCMAP=0 CHAP C223,5 MAGICNUMBER (19972D3) PCOMPRESSION
lcp_reqci: ACCOMPRESSION
lcp_reqci: returning CONFACK.
pppWrite[0]: len=53
fsm_sdata(LCP): Sent code 2,225,25.
pppInput[0]: packet processed
pppInProc[0]: got 153 bytes
pppInput[0]: LCP len=25
fsm_input(LCP):1,226,25
fs2 0
lcp_addci: L opt=5 F7BDAD33
lcp_addci: opt=7
lcp_addci: opt=8
pppWrite[0]: len=44
fsm_sdata(LCP): Sent code 1,3,20.
LCP: sending Configure-Request, id 3
lcp_reqci: rcvd ASYNCMAP=0 CHAP C223,5 MAGICNUMBER (19972D3) PCOMPRESSION
lcp_reqci: ACCOMPRESSION
lcp_reqci: returning CONFACK.
pppWrite[0]: len=52
fsm_sdata(LCP): Sent code 2,227,25.
pppInput[0]: packet processed
pppInProc[0]: got 151 bytes
pppInput[0]: LCP len=25
fsm_input(LCP):1,228,25
fsm 0
lcp_addci: L opt=5 246375C
lcp_addci: opt=7
lcp_addci: opt=8
pppWrite[0]: len=45
fsm_sdata(LCP): Sent code 1,4,20.
LCP: sending Configure-Request, id 4
lcp_reqci: rcvd ASYNCMAP=0 CHAP C223,5 MAGICNUMBER (19972D3) PCOMPRESSION
lcp_reqci: ACCOMPRESSION
lcp_reqci: returning CONFACK.
pppWrite[0]: len=52
fsm_sdata(LCP): Sent code 2,229,25.
pppInput[0]: packet processed
pppInProc[0]: got 153 bytes
pppInput[0]: LCP len=25
fsm_input(LCP):1,230,25
fs2 0
lcp_addci: L opt=5 E236C5DD
lcp_addci: opt=7
lcp_addci: opt=8
pppWrite[0]: len=44
fsm_sdata(LCP): Sent code 1,5,20.
LCP: sending Configure-Request, id 5
lcp_reqci: rcvd ASYNCMAP=0 CHAP C223,5 MAGICNUMBER (19972D3) PCOMPRESSION
lcp_reqci: ACCOMPRESSION
lcp_reqci: returning CONFACK.
pppWrite[0]: len=52
fsm_sdata(LCP): Sent code 2,231,25.
pppInput[0]: packet processed
pppInProc[0]: got 152 bytes
pppInput[0]: LCP len=25
fsm_input(LCP):1,232,25
fsm 0
lcp_addci: L opt=5 8E005B91
lcp_addci: opt=7
lcp_addci: opt=8
pppWrite[0]: len=46
fsm_sdata(LCP): Sent code 1,6,20.
LCP: sending Configure-Request, id 6
lcp_reqci: rcvd ASYNCMAP=0 CHAP C223,5 MAGICNUMBER (19972D3) PCOMPRESSION
lcp_reqci: ACCOMPRESSION
lcp_reqci: returning CONFACK.
pppWrite[0]: len=52
fsm_sdata(LCP): Sent code 2,233,25.
pppInput[0]: packet processed
pppInProc[0]: got 153 bytes
pppInput[0]: LCP len=25
fsm_input(LCP):1,234,25
fs2 0
lcp_addci: L opt=5 37DA08AA
lcp_addci: opt=7
lcp_addci: opt=8
pppWrite[0]: len=45
fsm_sdata(LCP): Sent code 1,7,20.
LCP: sending Configure-Request, id 7
lcp_reqci: rcvd ASYNCMAP=0 CHAP C223,5 MAGICNUMBER (19972D3) PCOMPRESSION
lcp_reqci: ACCOMPRESSION
lcp_reqci: returning CONFACK.
pppWrite[0]: len=52
fsm_sdata(LCP): Sent code 2,235,25.
pppInput[0]: packet processed
pppInProc[0]: got 152 bytes
pppInput[0]: LCP len=25
fsm_input(LCP):1,236,25
fsm 0
lcp_addci: L opt=5 7D452883
lcp_addci: opt=7
lcp_addci: opt=8
pppWrite[0]: len=46
fsm_sdata(LCP): Sent code 1,8,20.
LCP: sending Configure-Request, id 8
lcp_reqci: rcvd ASYNCMAP=0 CHAP C223,5 MAGICNUMBER (19972D3) PCOMPRESSION
lcp_reqci: ACCOMPRESSION
lcp_reqci: returning CONFACK.
pppWrite[0]: len=52
fsm_sdata(LCP): Sent code 2,237,25.
pppInput[0]: packet processed
pppInProc[0]: got 154 bytes
pppInput[0]: LCP len=25
fsm_input(LCP):1,238,25
fs2 0
lcp_addci: L opt=5 BB77512B
lcp_addci: opt=7
lcp_addci: opt=8
pppWrite[0]: len=44
fsm_sdata(LCP): Sent code 1,9,20.
LCP: sending Configure-Request, id 9
lcp_reqci: rcvd ASYNCMAP=0 CHAP C223,5 MAGICNUMBER (19972D3) PCOMPRESSION
lcp_reqci: ACCOMPRESSION
lcp_reqci: returning CONFACK.
pppWrite[0]: len=53
fsm_sdata(LCP): Sent code 2,239,25.
pppInput[0]: packet processed
pppInProc[0]: got 151 bytes
pppInput[0]: LCP len=25
fsm_input(LCP):1,240,25
fsm 0
lcp_addci: L opt=5 320709B8
lcp_addci: opt=7
lcp_addci: opt=8
pppWrite[0]: len=47
fsm_sdata(LCP): Sent code 1,10,20.
LCP: sending Configure-Request, id 10
lcp_reqci: rcvd ASYNCMAP=0 CHAP C223,5 MAGICNUMBER (19972D3) PCOMPRESSION
lcp_reqci: ACCOMPRESSION
lcp_reqci: returning CONFACK.
pppWrite[0]: len=52
fsm_sdata(LCP): Sent code 2,241,25.
pppInput[0]: packet processed
pppInProc[0]: got 154 bytes
pppInput[0]: LCP len=25
fsm_input(LCP):1,242,25
fst=2 0
lcp_addci: L opt=5 874F608F
lcp_addci: opt=7
lcp_addci: opt=8
pppWrite[0]: len=44
fsm_sdata(LCP): Sent code 1,11,20.
LCP: sending Configure-Request, id 11
lcp_reqci: rcvd ASYNCMAP=0 CHAP C223,5 MAGICNUMBER (19972D3) PCOMPRESSION
lcp_reqci: ACCOMPRESSION
lcp_reqci: returning CONFACK.
pppWrite[0]: len=52
fsm_sdata(LCP): Sent code 2,243,25.
pppInput[0]: packet processed
pppInProc[0]: got 2 bytes
LCP: timeout resending Config-Request state=8 (LS_ACKSENT)
lcp_addci: L opt=2 0
lcp_addci: L opt=5 874F608F
lcp_addci: opt=7
lcp_addci: opt=8
pppWrite[0]: len=45
fsm_sdata(LCP): Sent code 1,11,20.
LCP: sending Configure-Request, id 11
pppClose() called
pppClose: unit 0 kill_link -> pppStop
pppStop: unit 0
pppWrite[0]: len=29
fsm_sdata(LCP): Sent code 5,12,16.
LCP: close reason=User request state 8 (LS_ACKSENT) -> 4 (LS_CLOSING)
pppRecvWakeup: unit 0
LCP: timeout resending Terminate-Requests state=4 (LS_CLOSING)
pppWrite[0]: len=29
fsm_sdata(LCP): Sent code 5,13,16.
LCP: timeout sending Terminate-Request state=4 (LS_CLOSING)
link_terminated: 0
Connection terminated.
pppLinkTerminated: unit 0
pppRecvWakeup: unit 0
pppLinkTerminated: unit 0: linkStatusCB=0x800de11 errCode=-5
pppLinkTerminated: finished.


Сообщение отредактировал IgorKossak - Jul 9 2012, 18:48
Причина редактирования: [codebox] для длинных простыней!!!
Go to the top of the page
 
+Quote Post
 
Start new topic
Ответов
eisufu
сообщение Jul 13 2012, 10:02
Сообщение #2


Участник
*

Группа: Участник
Сообщений: 33
Регистрация: 29-06-10
Пользователь №: 58 196



сделал так:
CODE

// inet.c
#include "inet.h"
/*drivers*/
#include "main.h"
#include "gate.h"

/*kernel*/
#include "FreeRTOS.h"
#include "portmacro.h"
#include "task.h"
#include "queue.h"
#include "semphr.h"

#include "lwip/mem.h"
#include "lwip/memp.h"
#include "lwip/inet.h"
/*#include "ethernetif.h"*/
/*#include "netconf.h"*/
#include "lwip/tcpip.h"
#include "ppp.h"
#include "lwip/sio.h"

#include <stdio.h>
#include <stdarg.h>
#include <string.h>
#include <ctype.h>

#define RX_BUF_SIZE 1504

static xQueueHandle xRxedChars;

void COM1_IRQHandler(void) {
portBASE_TYPE xHigherPriorityTaskWoken = pdFALSE;
if (USART_GetITStatus(COM1_USART, USART_IT_RXNE) == SET) {
u8_t c =
(USART_ReceiveData(COM1_USART) & ((1 << SERIAL_RS485_BITS) - 1));
xQueueSendFromISR(xRxedChars, &c, &xHigherPriorityTaskWoken);
}
portEND_SWITCHING_ISR(xHigherPriorityTaskWoken);
}

#define MODEM_TEXT_IO_LENGTH 256

#define SIO_SERIAL_PORT NULL
#define PPP_CONNECTION_TIMEOUT 30000 / portTICK_RATE_MS
#define MODEM_READ_TIMEOUT 200 / portTICK_RATE_MS

static
int modem_putchar(int c) {
while (USART_GetFlagStatus(COM1_USART, USART_FLAG_TXE) != SET) {
continue;
}
USART_SendData(COM1_USART, c);
return c;
}

/*static
int modem_printf(const char * fmt, ...) {
static char tx_buf[MODEM_TEXT_IO_LENGTH];
int count;
{
va_list args;
va_start(args, fmt);
count = vsnprintf(tx_buf + 0, sizeof(tx_buf), fmt, args);
va_end(args);
}
for (int i = 0; i < count; ++i) {
if (modem_putchar(tx_buf[i]) < 0) {
return i;
}
}
return count;
}*/

static
int modem_getch(void) {
u8_t c;
if (xQueueReceive(xRxedChars, &c, 0) == pdFALSE) {
return -1;
}
return c;
}

static
int modem_exchange(char * AT_command) {
static u8 rx_buf[MODEM_TEXT_IO_LENGTH];
int len;
sio_write(SIO_SERIAL_PORT, (u8 *) AT_command, strlen(AT_command));
sio_read(SIO_SERIAL_PORT, rx_buf + 0, sizeof(rx_buf)); // discard echo if present
sio_write(SIO_SERIAL_PORT, (u8 *) "\r\n", 2);
len = sio_read(SIO_SERIAL_PORT, rx_buf + 0, sizeof(rx_buf));
if (len > 0) {
int code;
if (sscanf((char *) &rx_buf, "%i", &code) == 1) {
vTaskDelay(100 / portTICK_RATE_MS);
return code;
}
}
return -1;
}

static
int connected;

static
void linkStatusCB(void * ctx, int errCode, void * arg) {
int * connected = (int *) ctx;
struct ppp_addrs * addrs = arg;
switch (errCode) {
case PPPERR_NONE: {
/* We are connected */
*connected = 1;
printf("ip_addr = %s\r\n", inet_ntoa(addrs->our_ipaddr));
printf("netmask = %s\r\n", inet_ntoa(addrs->netmask));
printf("dns1 = %s\r\n", inet_ntoa(addrs->dns1));
printf("dns2 = %s\r\n", inet_ntoa(addrs->dns2));
break;
}
case PPPERR_CONNECT: {
printf("lost connection\r\n"); /* just wait */
break;
}
default: {
/* We have lost connection */
*connected = 0;
break;
}
}
}

static
void hw_init(void) {
USART_InitTypeDef USART_InitStructure;
USART_InitStructure.USART_BaudRate = 57600;
USART_InitStructure.USART_WordLength = USART_WordLength_8b;
USART_InitStructure.USART_StopBits = USART_StopBits_1;
USART_InitStructure.USART_Parity = USART_Parity_No;
USART_InitStructure.USART_HardwareFlowControl =
USART_HardwareFlowControl_None;
USART_InitStructure.USART_Mode = (USART_Mode_Rx | USART_Mode_Tx);
com_init(COM1, &USART_InitStructure);
USART_ITConfig(COM1_USART, USART_IT_RXNE, ENABLE);
}

static
void tcpip_init_done(void * arg) {
if (arg != NULL) {
*((int *) arg) = 1;
}
}

#define PPP_AUTH_USERNAME "mts"
#define PPP_AUTH_PASSWORD "mts"

static
void inetTask(void * pvParameters) {
(void) pvParameters;
int setup = 0;
int pd = -1;
tcpip_init(tcpip_init_done, &setup);
while (setup == 0) {
vTaskDelay(100 / portTICK_RATE_MS);
}
pppInit();
hw_init();
for (;;) {
vTaskDelay(1000 / portTICK_RATE_MS);
if (modem_exchange("AT Z0 E0 V0") != 0) { // OK
continue;
}
if (modem_exchange("AT S0=0") != 0) { // OK
continue;
}
if (modem_exchange("AT +CGDCONT=1,\"IP\",\"internet.mts.ru\"") != 0) { // OK
continue;
}
if (modem_exchange("AT DT*99***1#") != 1) { // CONNECT
continue;
}
pppSetAuth(PPPAUTHTYPE_ANY, PPP_AUTH_USERNAME, PPP_AUTH_PASSWORD);
connected = 0;
pd = pppOverSerialOpen(SIO_SERIAL_PORT, linkStatusCB, &connected);
if (!(pd < 0)) {
portTickType ticks = xTaskGetTickCount();
do {
vTaskDelay(100 / portTICK_RATE_MS);
if (connected != 0) {
printf("!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!\r\n");
break;
}
} while (xTaskGetTickCount() < ticks + PPP_CONNECTION_TIMEOUT);
if (connected != 0) {
printf("can run\r\n");
}
pppClose(pd);
} else {
printf("could not connect\r\n");
}
printf("RECONNECT\r\n");
}
#if 0
for (;;) {
vTaskDelay(100 / portTICK_RATE_MS);
}
#else
vTaskDelete(NULL);
#endif
}

void inet_init(void) {
xRxedChars = xQueueCreate(RX_BUF_SIZE, sizeof(u8_t));
xTaskCreate(inetTask, (signed char *) "inetTask", configMINIMAL_STACK_SIZE,
NULL, tskIDLE_PRIORITY, (xTaskHandle *) NULL);
}

u32_t sys_jiffies(void) {
return xTaskGetTickCount();
}

static __attribute__ ((noinline))
void print_dump(u8_t * data, u32_t len, const char * prefix) {
int i, r, l, p;
static u8_t line[0x10];
u8_t c;
l = 0;
for (i = 0; i < len; ++i) {
c = *(data + i);
r = (i % 0x10);
if (isgraph© != 0) {
*(line + r) = c;
} else {
*(line + r) = '.';
}
if (i == 0) {
p = printf("%s", prefix);
} else if (r == 0) {
printf("%*s", p, "");
}
if (i + 1 == len) {
printf("%02hhX %*.*s", c, r + 1 + (46 - l), r + 1, line + 0);
l = 0;
} else if (r == 0x0F) {
printf("%02hhX %.16s\r\n", c, line + 0);
l = 0;
} else if (r == 7) {
l += printf("%02hhX ", c);
} else {
l += printf("%02hhX ", c);
}
}
}

static int read_abort = 0;

u32_t sio_read(sio_fd_t fd, u8_t * data, u32_t len) {
(void) fd;
int i;
for (i = 0; i < len; ++i) {
int c = modem_getch();
if (c < 0) {
break;
}
data[i] = c;
if (read_abort != 0) {
read_abort = 0;
break;
}
}
printf("rx dump (%d/%d):\r\n", i, len);
print_dump(data, i, ""); // "rcvd " ~pppdump format
printf("\r\n");
return i;
}

void sio_read_abort(sio_fd_t fd) {
read_abort = 1;
}

u32_t sio_write(sio_fd_t fd, u8_t * data, u32_t len) {
(void) fd;
printf("tx dump (%d/%d):\r\n", len, len);
print_dump(data, len, ""); // "sent "
printf("\r\n");
for (u32_t i = 0; i < len; ++i) {
modem_putchar(data[i]);
}
return len;
}


CODE

/**
******************************************************************************
* @file lwipopts.h
* @author MCD Application Team
* @version V1.0.0
* @date 31-October-2011
* @brief lwIP Options Configuration.
* This file is based on Utilities\lwip_v1.3.2\src\include\lwip\opt.h
* and contains the lwIP configuration for the STM32F4x7 demonstration.
******************************************************************************
* @attention
*
* THE PRESENT FIRMWARE WHICH IS FOR GUIDANCE ONLY AIMS AT PROVIDING CUSTOMERS
* WITH CODING INFORMATION REGARDING THEIR PRODUCTS IN ORDER FOR THEM TO SAVE
* TIME. AS A RESULT, STMICROELECTRONICS SHALL NOT BE HELD LIABLE FOR ANY
* DIRECT, INDIRECT OR CONSEQUENTIAL DAMAGES WITH RESPECT TO ANY CLAIMS ARISING
* FROM THE CONTENT OF SUCH FIRMWARE AND/OR THE USE MADE BY CUSTOMERS OF THE
* CODING INFORMATION CONTAINED HEREIN IN CONNECTION WITH THEIR PRODUCTS.
*
* <h2><center>&copy; COPYRIGHT 2011 STMicroelectronics</center></h2>
******************************************************************************
*/

#ifndef __LWIPOPTS_H__
#define __LWIPOPTS_H__

/**
* SYS_LIGHTWEIGHT_PROT==1: if you want inter-task protection for certain
* critical regions during buffer allocation, deallocation and memory
* allocation and deallocation.
*/
#define SYS_LIGHTWEIGHT_PROT 1

#define ETHARP_TRUST_IP_MAC 0
#define IP_REASSEMBLY 1
#define IP_FRAG 0
#define ARP_QUEUEING 0

/**
* NO_SYS==1: Provides VERY minimal functionality. Otherwise,
* use lwIP facilities.
*/
#define NO_SYS 0

/* ---------- Memory options ---------- */
/* MEM_ALIGNMENT: should be set to the alignment of the CPU for which
lwIP is compiled. 4 byte alignment -> define MEM_ALIGNMENT to 4, 2
byte alignment -> define MEM_ALIGNMENT to 2. */
#define MEM_ALIGNMENT 4

/* MEM_SIZE: the size of the heap memory. If the application will send
a lot of data that needs to be copied, this should be set high. */
#define MEM_SIZE (4*1024)

/* MEMP_NUM_PBUF: the number of memp struct pbufs. If the application
sends a lot of data out of ROM (or other static memory), this
should be set high. */
#define MEMP_NUM_PBUF 8
/* MEMP_NUM_UDP_PCB: the number of UDP protocol control blocks. One
per active UDP "connection". */
#define MEMP_NUM_UDP_PCB 2
/* MEMP_NUM_TCP_PCB: the number of simulatenously active TCP
connections. */
#define MEMP_NUM_TCP_PCB 2
/* MEMP_NUM_TCP_PCB_LISTEN: the number of listening TCP
connections. */
#define MEMP_NUM_TCP_PCB_LISTEN 5
/* MEMP_NUM_TCP_SEG: the number of simultaneously queued TCP
segments. */
#define MEMP_NUM_TCP_SEG 16
/* MEMP_NUM_SYS_TIMEOUT: the number of simulateously active
timeouts. */
#define MEMP_NUM_SYS_TIMEOUT 6


/* ---------- Pbuf options ---------- */
/* PBUF_POOL_SIZE: the number of buffers in the pbuf pool. */
#define PBUF_POOL_SIZE 24

/* PBUF_POOL_BUFSIZE: the size of each pbuf in the pbuf pool. */
#define PBUF_POOL_BUFSIZE 512


/* ---------- TCP options ---------- */
#define LWIP_TCP 1
#define TCP_TTL 255

/* Controls if TCP should queue segments that arrive out of
order. Define to 0 if your device is low on memory. */
#define TCP_QUEUE_OOSEQ 1

/* TCP Maximum segment size. */
#define TCP_MSS (1500 - 40) /* TCP_MSS = (Ethernet MTU - IP header size - TCP header size) */

/* TCP sender buffer space (bytes). */
#define TCP_SND_BUF (5*TCP_MSS)

/* TCP_SND_QUEUELEN: TCP sender buffer space (pbufs). This must be at least
as much as (2 * TCP_SND_BUF/TCP_MSS) for things to work. */

#define TCP_SND_QUEUELEN (2* TCP_SND_BUF/TCP_MSS)

/* TCP receive window. */
#define TCP_WND (2*TCP_MSS)


/* ---------- ICMP options ---------- */
#define LWIP_ICMP 1


/* ---------- DHCP options ---------- */
/* Define LWIP_DHCP to 1 if you want DHCP configuration of
interfaces. DHCP is not implemented in lwIP 0.5.1, however, so
turning this on does currently not work. */
#define LWIP_DHCP 0


/* ---------- UDP options ---------- */
#define LWIP_UDP 1
#define UDP_TTL 255


/* ---------- Statistics options ---------- */
#define LWIP_STATS 0
#define LWIP_PROVIDE_ERRNO 1


/*
--------------------------------------
---------- Checksum options ----------
--------------------------------------
*/

/*
The STM32F4x7 allows computing and verifying the IP, UDP, TCP and ICMP checksums by hardware:
- To use this feature let the following define uncommented.
- To disable it and process by CPU comment the the checksum.
*/
#define CHECKSUM_BY_HARDWARE


#ifdef CHECKSUM_BY_HARDWARE
/* CHECKSUM_GEN_IP==0: Generate checksums by hardware for outgoing IP packets.*/
#define CHECKSUM_GEN_IP 0
/* CHECKSUM_GEN_UDP==0: Generate checksums by hardware for outgoing UDP packets.*/
#define CHECKSUM_GEN_UDP 0
/* CHECKSUM_GEN_TCP==0: Generate checksums by hardware for outgoing TCP packets.*/
#define CHECKSUM_GEN_TCP 0
/* CHECKSUM_CHECK_IP==0: Check checksums by hardware for incoming IP packets.*/
#define CHECKSUM_CHECK_IP 0
/* CHECKSUM_CHECK_UDP==0: Check checksums by hardware for incoming UDP packets.*/
#define CHECKSUM_CHECK_UDP 0
/* CHECKSUM_CHECK_TCP==0: Check checksums by hardware for incoming TCP packets.*/
#define CHECKSUM_CHECK_TCP 0
#else
/* CHECKSUM_GEN_IP==1: Generate checksums in software for outgoing IP packets.*/
#define CHECKSUM_GEN_IP 1
/* CHECKSUM_GEN_UDP==1: Generate checksums in software for outgoing UDP packets.*/
#define CHECKSUM_GEN_UDP 1
/* CHECKSUM_GEN_TCP==1: Generate checksums in software for outgoing TCP packets.*/
#define CHECKSUM_GEN_TCP 1
/* CHECKSUM_CHECK_IP==1: Check checksums in software for incoming IP packets.*/
#define CHECKSUM_CHECK_IP 1
/* CHECKSUM_CHECK_UDP==1: Check checksums in software for incoming UDP packets.*/
#define CHECKSUM_CHECK_UDP 1
/* CHECKSUM_CHECK_TCP==1: Check checksums in software for incoming TCP packets.*/
#define CHECKSUM_CHECK_TCP 1
#endif


/*
----------------------------------------------
---------- Sequential layer options ----------
----------------------------------------------
*/
/**
* LWIP_NETCONN==1: Enable Netconn API (require to use api_lib.c)
*/
#define LWIP_NETCONN 1

/*
------------------------------------
---------- Socket options ----------
------------------------------------
*/
/**
* LWIP_SOCKET==1: Enable Socket API (require to use sockets.c)
*/
#define LWIP_SOCKET 0

/*
-----------------------------------
---------- DEBUG options ----------
-----------------------------------
*/

#define LWIP_DEBUG 1


/*
---------------------------------
---------- OS options ----------
---------------------------------
*/

#define TCPIP_THREAD_STACKSIZE configMINIMAL_STACK_SIZE
#define TCPIP_MBOX_SIZE 5
#define DEFAULT_UDP_RECVMBOX_SIZE 2000
#define DEFAULT_TCP_RECVMBOX_SIZE 2000
#define DEFAULT_ACCEPTMBOX_SIZE 2000
#define DEFAULT_THREAD_STACKSIZE configMINIMAL_STACK_SIZE
#define TCPIP_THREAD_PRIO (configMAX_PRIORITIES - 3)

#define LWIP_COMPAT_MUTEX 1
#define LWIP_SO_RCVTIMEO 1
#define PPP_SUPPORT 1
#define PAP_SUPPORT 1
#define CHAP_SUPPORT 0
#define MD5_SUPPORT 0
#define PPP_THREAD_PRIO (configMAX_PRIORITIES - 3)
#define PPP_THREAD_STACKSIZE configMINIMAL_STACK_SIZE
#define PPP_DEBUG LWIP_DBG_ON

#endif /* __LWIPOPTS_H__ */

/******************* © COPYRIGHT 2011 STMicroelectronics *****END OF FILE****/

на что лог следующий:
CODE

lcp_init: xmit_accm=0 0 0 0
upap_init: 0
tx dump (11/11):
41 54 20 5A 30 20 45 30 20 56 30 AT.Z0.E0.V0
rx dump (0/256):

tx dump (2/2):
0D 0A ..
rx dump (0/256):

tx dump (11/11):
41 54 20 5A 30 20 45 30 20 56 30 AT.Z0.E0.V0
rx dump (2/256):
30 0D 0.
tx dump (2/2):
0D 0A ..
rx dump (0/256):

tx dump (11/11):
41 54 20 5A 30 20 45 30 20 56 30 AT.Z0.E0.V0
rx dump (2/256):
30 0D 0.
tx dump (2/2):
0D 0A ..
rx dump (0/256):

tx dump (11/11):
41 54 20 5A 30 20 45 30 20 56 30 AT.Z0.E0.V0
rx dump (2/256):
30 0D 0.
tx dump (2/2):
0D 0A ..
rx dump (0/256):

tx dump (11/11):
41 54 20 5A 30 20 45 30 20 56 30 AT.Z0.E0.V0
rx dump (2/256):
30 0D 0.
tx dump (2/2):
0D 0A ..
rx dump (0/256):

tx dump (11/11):
41 54 20 5A 30 20 45 30 20 56 30 AT.Z0.E0.V0
rx dump (2/256):
30 0D 0.
tx dump (2/2):
0D 0A ..
rx dump (0/256):

tx dump (11/11):
41 54 20 5A 30 20 45 30 20 56 30 AT.Z0.E0.V0
rx dump (2/256):
30 0D 0.
tx dump (2/2):
0D 0A ..
rx dump (0/256):

tx dump (11/11):
41 54 20 5A 30 20 45 30 20 56 30 AT.Z0.E0.V0
rx dump (2/256):
30 0D 0.
tx dump (2/2):
0D 0A ..
rx dump (0/256):

tx dump (11/11):
41 54 20 5A 30 20 45 30 20 56 30 AT.Z0.E0.V0
rx dump (2/256):
30 0D 0.
tx dump (2/2):
0D 0A ..
rx dump (0/256):



не катит отсутствие задержки

не успевает ответить модем

вот кусок ppp.c:
Код
static void
pppInputThread(void *arg)
{
  int count;
  PPPControlRx *pcrx = arg;

  while (lcp_phase[pcrx->pd] != PHASE_DEAD) {
    count = sio_read(pcrx->fd, pcrx->rxbuf, PPPOS_RX_BUFSIZE);
    if(count > 0) {
      pppInProc(pcrx, pcrx->rxbuf, count);
    } else {
      /* nothing received, give other tasks a chance to run */
      sys_msleep(2);
    }
  }
  vTaskDelete(NULL);
}
#endif /* PPPOS_SUPPORT && PPP_INPROC_OWNTHREAD */


вообще если верить lwip/sio.h, то sio_read должна блокировать до победного, пока другой поток не сделает read_abort = 0;

*точнее не вызовет sio_read_abort();

до этого делал кольцевой буфер на COM-порту, но тоже с таймаутом - хоть обмен шёл

разбирался с протоколом - выяснил, что провайдер отвечает NAK, а каковы причины - не ясно

если ставить 0xFFFF таймаут на ожидание символов, то поток с FSM залипает навечно, если 0, то ничего не получает из канала связи. так что оставил 200. картина следующая:
CODE
lcp_init: xmit_accm=0 0 0 0
upap_init: 0
tx dump (11/11):
41 54 20 5A 30 20 45 30 20 56 30 AT.Z0.E0.V0
rx dump (0/256):

tx dump (2/2):
0D 0A ..
rx dump (2/256):
33 0D 3.
tx dump (11/11):
41 54 20 5A 30 20 45 30 20 56 30 AT.Z0.E0.V0
rx dump (0/256):

tx dump (2/2):
0D 0A ..
rx dump (2/256):
30 0D 0.
tx dump (7/7):
41 54 20 53 30 3D 30 AT.S0=0
rx dump (0/256):

tx dump (2/2):
0D 0A ..
rx dump (2/256):
30 0D 0.
tx dump (36/36):
41 54 20 2B 43 47 44 43 4F 4E 54 3D 31 2C 22 49 AT.+CGDCONT=1,"I
50 22 2C 22 69 6E 74 65 72 6E 65 74 2E 6D 74 73 P","internet.mts
2E 72 75 22 .ru"
rx dump (0/256):

tx dump (2/2):
0D 0A ..
rx dump (2/256):
30 0D 0.
tx dump (13/13):
41 54 20 44 54 2A 39 39 2A 2A 2A 31 23 AT.DT*99***1#
rx dump (0/256):

tx dump (2/2):
0D 0A ..
rx dump (2/256):
31 0D 1.
pppOverSerialOpen: unit 0: Connecting
pppStart: unit 0
ppp_set_xaccm[0]: outACCM=0 0 0 0
ppp_send_config[0]: outACCM=FF FF FF FF
ppp_recv_config[0]: inACCM=0 0 0 0
lcp_lowerup: asyncmap=0 0 0 0
LCP: lowerup state 0 (LS_INITIAL) -> 2 (LS_CLOSED)
auth_reset: 0
lcp_addci: L opt=2 0
lcp_addci: L opt=5 34DE8CCF
lcp_addci: opt=7
lcp_addci: opt=8
pppWrite[0]: len=45
tx dump (45/45):
7E FF 7D 23 C0 21 7D 21 7D 21 7D 20 7D 34 7D 22 ~.}#.!}!}!}.}4}"
7D 26 7D 20 7D 20 7D 20 7D 20 7D 25 7D 26 34 DE }&}.}.}.}.}%}&4.
8C CF 7D 27 7D 22 7D 28 7D 22 57 8D 7E ..}'}"}(}"W.~
fsm_sdata(LCP): Sent code 1,1,20.
LCP: sending Configure-Request, id 1
LCP: open state 2 (LS_CLOSED) -> 6 (LS_REQSENT)
pppStart: finished
rx dump (99/1504):
7E FF 7D 23 C0 21 7D 21 7D 24 7D 20 7D 39 7D 22 ~.}#.!}!}$}.}9}"
7D 26 7D 20 7D 20 7D 20 7D 20 7D 23 7D 25 C2 23 }&}.}.}.}.}#}%.#
7D 25 7D 25 7D 26 7D 35 55 54 3D 7D 27 7D 22 7D }%}%}&}5UT=}'}"}
28 7D 22 D6 DD 7E 7E FF 7D 23 C0 21 7D 22 7D 21 (}"..~~.}#.!}"}!
7D 20 7D 34 7D 22 7D 26 7D 20 7D 20 7D 20 7D 20 }.}4}"}&}.}.}.}.
7D 25 7D 26 34 DE 8C CF 7D 27 7D 22 7D 28 7D 22 }%}&4...}'}"}(}"
BC E4 7E ..~
pppInProc[0]: got 99 bytes
pppInput[0]: LCP len=25
fsm_input(LCP):1,4,25
fsm_rconfreq(LCP): Rcvd id 4 state=6 (LS_REQSENT)
lcp_reqci: rcvd ASYNCMAP=0 CHAP C223,5 MAGICNUMBER (1555543D) PCOMPRESSION
lcp_reqci: ACCOMPRESSION
lcp_reqci: returning CONFACK.
pppWrite[0]: len=54
tx dump (54/54):
7E FF 7D 23 C0 21 7D 22 7D 24 7D 20 7D 39 7D 22 ~.}#.!}"}$}.}9}"
7D 26 7D 20 7D 20 7D 20 7D 20 7D 23 7D 25 C2 23 }&}.}.}.}.}#}%.#
7D 25 7D 25 7D 26 7D 35 55 54 3D 7D 27 7D 22 7D }%}%}&}5UT=}'}"}
28 7D 22 5B D1 7E (}"[.~
fsm_sdata(LCP): Sent code 2,4,25.
pppInput[0]: packet processed
pppInput[0]: LCP len=20
fsm_input(LCP):2,1,20
fsm_rconfack(LCP): Rcvd id 1 state=8 (LS_ACKSENT)
lcp_acki: Ack
ppp_send_config[0]: outACCM=0 0 0 0
ppp_recv_config[0]: inACCM=0 0 0 0
link_established: unit 0; Lowering up all protocols...
upap_lowerup: init 0 clientstate s=0
IPCP: lowerup state 0 (LS_INITIAL) -> 2 (LS_CLOSED)
pppWrite[0]: len=29
tx dump (29/29):
FF 03 80 21 01 01 00 16 03 06 00 00 00 00 81 06 ...!............
00 00 00 00 83 06 00 00 00 00 6E DB 7E ..........n.~
fsm_sdata(IPCP): Sent code 1,1,22.
IPCP: sending Configure-Request, id 1
IPCP: open state 2 (LS_CLOSED) -> 6 (LS_REQSENT)
pppInput[0]: packet processed
rx dump (65/1504):
7E FF 7D 23 C0 21 7D 2B 7D 25 7D 20 7D 28 7D 35 ~.}#.!}+}%}.}(}5
55 54 3D 2E DC 7E 7E C2 23 01 01 00 23 10 B0 2C UT=..~~.#...#..,
46 E2 DE 4A 20 6D CA 6C 13 63 96 74 4B 90 55 4D F..J.m.l.c.tK.UM
54 53 5F 43 48 41 50 5F 53 52 56 52 B0 4D 7E 33 TS_CHAP_SRVR.M~3
0D .
pppInProc[0]: got 65 bytes
pppInput[0]: LCP len=8
fsm_input(LCP):11,5,8
fsm_input(LCP): default:
pppInput[0]: packet processed
pppInput[0]: rejecting unsupported proto 0xc223 len=35
pppWrite[0]: len=49
tx dump (49/49):
7E FF 03 C0 21 08 02 00 29 C2 23 01 01 00 23 10 ~...!...).#...#.
B0 2C 46 E2 DE 4A 20 6D CA 6C 13 63 96 74 4B 90 .,F..J.m.l.c.tK.
55 4D 54 53 5F 43 48 41 50 5F 53 52 56 52 51 CB UMTS_CHAP_SRVRQ.
7E ~
fsm_sdata(LCP): Sent code 8,2,41.
rx dump (0/1504):

rx dump (0/1504):

rx dump (0/1504):

rx dump (0/1504):

rx dump (0/1504):

rx dump (0/1504):

rx dump (0/1504):

rx dump (0/1504):

rx dump (0/1504):

rx dump (0/1504):

rx dump (0/1504):

rx dump (0/1504):

rx dump (0/1504):

rx dump (0/1504):

rx dump (0/1504):

rx dump (0/1504):

rx dump (0/1504):

rx dump (0/1504):

rx dump (0/1504):

rx dump (0/1504):

rx dump (0/1504):

rx dump (0/1504):

rx dump (0/1504):

rx dump (0/1504):

rx dump (0/1504):

rx dump (0/1504):

rx dump (0/1504):

rx dump (0/1504):

IPCP: timeout resending Config-Request state=6 (LS_REQSENT)
pppWrite[0]: len=30
tx dump (30/30):
7E FF 03 80 21 01 01 00 16 03 06 00 00 00 00 81 ~...!...........
06 00 00 00 00 83 06 00 00 00 00 6E DB 7E ...........n.~
rx dump (0/1504):

fsm_sdata(IPCP): Sent code 1,1,22.
IPCP: sending Configure-Request, id 1
rx dump (0/1504):

rx dump (0/1504):

rx dump (0/1504):

rx dump (0/1504):

rx dump (0/1504):

rx dump (0/1504):

rx dump (0/1504):

rx dump (0/1504):
Go to the top of the page
 
+Quote Post

Сообщений в этой теме
- eisufu   STM32 lwIP PPPoS   Jul 9 2012, 16:53
- - AlexandrY   Такое ощущение, что не договорились про ACCM. Верн...   Jul 10 2012, 09:26
- - kan35   Не похоже на мой лог. Попробую пальцем в небо: У в...   Jul 10 2012, 09:51
|- - eisufu   Цитата(kan35 @ Jul 10 2012, 15:51) Не пох...   Jul 12 2012, 11:22
- - kan35   как я понимаю нужно оставить что то одно или CHAP ...   Jul 12 2012, 13:13
|- - eisufu   RE: STM32 lwIP PPPoS   Jul 13 2012, 05:23
|- - kan35   Сделайте во первых MD5_SUPPORT=0 PAP_SUPPORT=1 CHA...   Jul 13 2012, 05:33
- - eisufu   вот. CODElcp_init: xmit_accm=0 0 0 0 upap_init: 0...   Jul 13 2012, 06:02
|- - kan35   опять в логе вижу слово CHAP - его быть не должно...   Jul 13 2012, 06:24
- - eisufu   RE: STM32 lwIP PPPoS   Jul 13 2012, 10:02
- - eisufu   спасибо за попытку помочь.   Jul 13 2012, 17:15
|- - kan35   Цитата(eisufu @ Jul 13 2012, 21:15) спаси...   Jul 13 2012, 19:20
- - eisufu   у меня на данный момент модем Huawei E173. проблем...   Jul 16 2012, 10:10
- - eisufu   RE: STM32 lwIP PPPoS   Jul 17 2012, 03:35
- - kan35   Да, интернет на SIM карте надо было проверить в пе...   Jul 17 2012, 04:09
- - eisufu   убрал. покопался в настройках lwIP. оказалось, что...   Jul 17 2012, 05:53
- - eisufu   уже удаётся. премного благодарен вам, kan35 остало...   Jul 17 2012, 08:16


Reply to this topicStart new topic
1 чел. читают эту тему (гостей: 1, скрытых пользователей: 0)
Пользователей: 0

 


RSS Текстовая версия Сейчас: 21st July 2025 - 19:49
Рейтинг@Mail.ru


Страница сгенерированна за 0.01473 секунд с 7
ELECTRONIX ©2004-2016