Continue to Site

Welcome to our site!

Electro Tech is an online community (with over 170,000 members) who enjoy talking about and building electronic circuits, projects and gadgets. To participate you need to register. Registration is free. Click here to register now.

  • Welcome to our site! Electro Tech is an online community (with over 170,000 members) who enjoy talking about and building electronic circuits, projects and gadgets. To participate you need to register. Registration is free. Click here to register now.

How to transfer text files bewtween pic18f2620 & ftp ser

Status
Not open for further replies.

haseeb123

New Member
hello

Im planning on a new project.

I want to setup a simple ftp communication from the pic to an ftp server.
Data to be sent will be simple txt files and no picture.
The pic is a PIC18F2620. I plan on using a GPRS modem that can support ftp protocol such as the Cinterion BG2 wireless module.
I will be using the CCS compiler.

Please can someone point me in the right direction on how to achieve
this task?

Haseeb
 
If the Cinterion module supports ftp, I would expect its documentation to at least point you in the right direction. What does it say about ftp?

You could find that other manufacturers work in the same way, so look at other GSM/GPRS modules to see how they do ftp.
 
Hello


I have now managed to read in 'OK' replies from the modem successfully and I have confirmed this with the texting
mode as that works brilliantly. I can read in modem replies successfully via hyper terminal.


Anyway my main problem is with ftp and I’m enclosing in the program code for you all to have a look at.


Basically I just want to send some data (byte or a string) from my PIC to my ftp site and would like to have that
appear in the ftp root directory as a standard txt file.


From my source code, going all the way down and just before ‘problem 1’, I’m getting OK replies from the modem.
But from ‘Problem 1 ’ and ‘Problem 2’ I’m getting ERROR messages. I’m using CCS compiler and PIC18F2620 with internal
OSC @ 4MHz. The modem im using is the Cinterion BG2 modem and it supports ftp.


Please can you help me to achieve this ftp task.


Thank you
Haseeb


Code:
#include <18F2620.h>


#fuses INTRC_IO,NOWDT,NOPROTECT,NOLVP,NOPUT, NOPBADEN  

// Set Speed to 4Mhz
#use delay(clock=4000000)

// RS232 to Modem
#use rs232(baud=9600, xmit=PIN_C6, rcv=PIN_B5, STREAM=Modem)
// RTS232 to User Port
#use rs232(baud=9600, xmit=PIN_B4, rcv=PIN_C7, STREAM=User)
 




void Main (void)
{


 char char1;  //variable to store the modem ASCII incoming byte



 //configure I/O directions
  set_tris_A(0b00000001); 
    set_tris_B(0b00100111);     
    set_tris_C(0b11011000);

 

 disable_interrupts(GLOBAL);  // disable all interupts


 
 delay_ms(100); //startup delay



 //turning off all LEDs
 output_low(pin_A1);
 output_low(pin_A2);
 output_low(pin_A3); 
 output_low(pin_A4);



 //Powering up modem...
 output_high(pin_C1);    // Turn on Regulator
 output_high(pin_C5);   // Turn on Pwrkey
 Delay_ms(1000);     // wait 3 sec
 output_low(pin_C5);    // Turn off Pwrkey
 Delay_ms(3000);     // wait 3 sec
 output_high(pin_C5);   // Turn on Pwrkey  
 delay_ms(30000);    // wait for modem to establish connection 




 //modem power up indicator
 output_high(pin_A1);
 delay_ms(500);
 output_low(pin_A1); 
 



 
 
 




 
 // configure apn.......


 fprintf(Modem,"AT^SICS=0,conType,GPRS0\r\n");

 while(TRUE)
 {

  while(!kbhit(Modem));     //wait for char in USART buffer
   
  char1 = fgetc(Modem);   // get user input
      
  if(char1 == 'K')
  {
 
   fprintf(User,"%c",char1); // print to screen   

   delay_ms(100);

   break;
 
  }           

 } 

 fprintf(Modem,"AT^SICS=0,apn,\"greeninternet\"\r\n");

 while(TRUE)
 {

  while(!kbhit(Modem));     //wait for char in USART buffer
   
  char1 = fgetc(Modem);   // get user input
      
  if(char1 == 'K')
  {
 
   fprintf(User,"%c",char1); // print to screen
   
   delay_ms(100);

   break;
 
  }           

 }
 
 fprintf(Modem,"AT^SICS=0,user,userid\r\n");

 while(TRUE)
 {

  while(!kbhit(Modem));    //wait for char in USART buffer
   
  char1 = fgetc(Modem);   // get user input
      
  if(char1 == 'K')
  {
 
   fprintf(User,"%c",char1); // print to screen
   
   delay_ms(100);

   break;
 
  }           

 }

 fprintf(Modem,"AT^SICS=0,passwd,2110\r\n");

 while(TRUE)
 {

  while(!kbhit(Modem));    //wait for char in USART buffer
   
  char1 = fgetc(Modem);   // get user input
      
  if(char1 == 'K')
  {
 
   fprintf(User,"%c",char1); // print to screen
   
   delay_ms(100);

   break;
 
  }           

 } 











 // configure internet sevice..........

 fprintf(Modem,"AT^SISS=0,srvType,none\r\n");

 while(TRUE)
 {

  while(!kbhit(Modem));    //wait for char in USART buffer
   
  char1 = fgetc(Modem);   // get user input
      
  if(char1 == 'K')
  {
 
   fprintf(User,"%c",char1); // print to screen
   
   delay_ms(100);

   break;
 
  }           

 }
 
 fprintf(Modem,"AT^SISS=0,srvType,ftp\r\n");
 
 while(TRUE)
 {

  while(!kbhit(Modem));    //wait for char in USART buffer
   
  char1 = fgetc(Modem);   // get user input
      
  if(char1 == 'K')
  {
 
   fprintf(User,"%c",char1); // print to screen
   
   delay_ms(100);

   break;
 
  }           

 }

 fprintf(Modem,"AT^SISS=0,alphabet,1\r\n");

 while(TRUE)
 {

  while(!kbhit(Modem));    //wait for char in USART buffer
   
  char1 = fgetc(Modem);   // get user input
      
  if(char1 == 'K')
  {
 
   fprintf(User,"%c",char1); // print to screen
   
   delay_ms(100);

   break;
 
  }           

 }

 fprintf(Modem,"AT^SISS=0,conId,0\r\n"); 

 while(TRUE)
 {

  while(!kbhit(Modem));    //wait for char in USART buffer
   
  char1 = fgetc(Modem);   // get user input
      
  if(char1 == 'K')
  {
 
   fprintf(User,"%c",char1); // print to screen
   
   delay_ms(100);

   break;
 
  }           

 } 

 fprintf(Modem,"AT^SISS=0,tcpMR,3\r\n"); 

 while(TRUE)
 {

  while(!kbhit(Modem));    //wait for char in USART buffer
   
  char1 = fgetc(Modem);   // get user input
      
  if(char1 == 'K')
  {
 
   fprintf(User,"%c",char1); // print to screen
   
   delay_ms(100);

   break;
 
  }           

 }
 
 fprintf(Modem,"AT^SISS=0,tcpOT,3000\r\n"); 

 while(TRUE)
 {

  while(!kbhit(Modem));    //wait for char in USART buffer
   
  char1 = fgetc(Modem);   // get user input
      
  if(char1 == 'K')
  {
 
   fprintf(User,"%c",char1); // print to screen
   
   delay_ms(100);

   break;
 
  }           

 }

 fprintf(Modem,"AT^SISS=0,address,\"ftp://232.127.159.192;type=d\"\r\n"); 

 while(TRUE)
 {

  while(!kbhit(Modem));    //wait for char in USART buffer
   
  char1 = fgetc(Modem);   // get user input
      
  if(char1 == 'K')
  {
 
   fprintf(User,"%c",char1); // print to screen
   
   delay_ms(100);

   break;
 
  }           

 }



 // connnect to service...........

 fprintf(Modem,"AT^SISO=0\r\n");  

 while(TRUE)
 {

  while(!kbhit(Modem));    //wait for char in USART buffer
   
  char1 = fgetc(Modem);   // get user input
      
  if(char1 == 'K')
  {
 
   fprintf(User,"%c",char1); // print to screen
   
   delay_ms(5000);

   break;
 
  }           

 }








//problem 1


 fprintf(Modem,"AT^SISS=0,address,\"ftp://232.127.159.192/haseeb;type=a\"\r\n");
 
 while(TRUE)
 {

  while(!kbhit(Modem));    //wait for char in USART buffer
   
  char1 = fgetc(Modem);   // get user input
      
  //if(char1 == 'K')  
  //{
 
   fprintf(User,"%c",char1); // print to screen
   
  // delay_ms(100);

  // break;
 
  //}           

 }




//problem 2

 
 // wait for urc then receive some data.........

 fprintf(Modem,"at^sisr=0,1500\r\n");

 while(TRUE)
 {

  while(!kbhit(Modem));    //wait for char in USART buffer
   
  char1 = fgetc(Modem);   // get user input
      
  //if(char1 == 'K')
  //{
 
   fprintf(User,"%c",char1); // print to screen
   
  // delay_ms(100);

  // break;
 
  //}           

 }

 












 // close connection.........
 //at^sisc=0







 while(TRUE); //stay here forever






}
 
Last edited:
Status
Not open for further replies.

Latest threads

New Articles From Microcontroller Tips

Back
Top