[En-Nut-Discussion] Problems with ppp and gprs modem TC45

Jarosław Pałka jaroslaw.palka at mrt-system.com.pl
Fri Jan 14 13:53:56 CET 2005


Hi!

We are evaluating Nut/OS for our telemetry solution. We have selfmade ATMega128 board with 64 Kb SRAM equiped with Siemens TC45 and following code isn't working:

#include <stdlib.h>
#include <string.h>
#include <stdio.h>
#include <io.h>
#include <fcntl.h>

#include <sys/socket.h>
#include <sys/osdebug.h>
#include <sys/timer.h>

#include <net/if_var.h>
#include <net/route.h>
#include <net/netdebug.h>

#include <netdb.h>

#include <dev/debug.h>

#include <dev/ppp.h>
#include <dev/chat.h>
#include <dev/usartavr.h>

#define PPPCHAT0 "'' AT\\\\Q3 OK AT+CPIN=3333 OK"

#define PPPCHAT1 "'' AT+CGDCONT=1,\"IP\",\"mrt.pl\" OK"

#define PPPCHAT2 "'' ATD*99***1# CONNECT"

int main(void){
 int rc;
 int pppcom;
 u_long baud1 = 9600;
 u_long baud0 = 115200; 
 u_long timeout = 1000;

 NutRegisterDevice(&devUsartAvr0, 0, 0);
 NutRegisterDevice(&devUsartAvr1, 0, 0);
 NutRegisterDevice(&devPpp, 0, 0); 
 NutRegisterDevice(&devDebug1, 0, 0);

 freopen("uart1", "w", stdout);
 _ioctl(_fileno(stdout), UART_SETSPEED, &baud1);
 printf("Debug output done\n"); 
 
 NutTracePPP(stdout, 1);
 NutTraceTcp(stdout, 1);
 NutTraceChat(stdout,1);

 //TC45 initialization 
 DDRE = (1<<DDE2)|(1<<DDE3)|(1<<DDE4)|(1<<DDE5)|(1<<DDE6);
 PORTE = (1<<PE4)|(1<<PE2)|(1<<PE7);
 NutDelay(250);
 PORTE = (0<<PE4)|(0<<PE2)|(1<<PE7);
 
 NutSleep(6000);

  printf("Open uart...");
  if ((pppcom = _open("ppp:uart0", _O_RDWR | _O_BINARY)) == -1) {
   printf("failed to open  \n");
   for (;;);
  }
  puts("done");
  
 _ioctl(pppcom, UART_SETSPEED, &baud0);

 rc = UART_RTSENABLED | UART_CTSENABLED | UART_DTRENABLED;
 _ioctl(pppcom,UART_SETFLOWCONTROL,&rc);
 
 _ioctl(pppcom,UART_SETREADTIMEOUT,&timeout);

 printf("Sending..."PPPCHAT0);
        if ((rc = NutChat(pppcom, PPPCHAT0)) != 0) {
            printf("no connect, reason = %d\n", rc);
     for(;;){
     }
        }
        puts("done");
 
 NutSleep(4000);
 
 printf("Sending..."PPPCHAT1);
        if ((rc = NutChat(pppcom, PPPCHAT1)) != 0) {
            printf("no connect, reason = %d\n", rc);
     for(;;){
     }
        }
        puts("done");

 NutSleep(4000);

 printf("Sending..."PPPCHAT2);
        if ((rc = NutChat(pppcom, PPPCHAT2)) != 0) {
            printf("no connect, reason = %d\n", rc);
     for(;;){
     }
        }
        puts("done");
 
        printf("Configure PPP...");
        rc = NutNetIfConfig("ppp", 0, 0, 0);
        if (rc != 0) {
            puts("failed");
        }
        puts("done");

  
 for(;;){
 }
 
 return 1;
 
}

and here is debug console output:

Debug output done
Chat trace flags=0x01
Open uart...
[IPCP-OPEN]
[LCP-OPEN]done
Sending...'' AT+CPIN=3333 OKExpect '', got ''
Send 'AT+CPIN=3333'
Expect 'OK', got 'AT+CPIN=3333\x0D\x0D\x0AOK'
done
Sending...'' AT+CGDCONT=1,"IP","mrt.pl" OKExpect '', got ''
Send 'AT+CGDCONT=1,"IP","mrt.pl"'
Expect 'OK', got 'AT+CGDCONT=1,"IP","mrt.pl"\x0D\x0D\x0AOK'
done
Sending...'' ATD*99***1# CONNECTExpect '', got ''
Send 'ATD*99***1#'
Expect 'CONNECT', got 'ATD*99***1#\x0D\x0D\x0ACONNECT'
done
Configure PPP...failed
done

I have enabled RTS/CTS in Nut/OS configuration because this is recommended for this modem in Siemens technical docs.

Can anyone help me?

Thanks,
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.egnite.de/pipermail/en-nut-discussion/attachments/20050114/9e519d4c/attachment.html>


More information about the En-Nut-Discussion mailing list