-1

I am programming an embedded module to send a file over FTP via a GPRS connection.

The files sometimes upload fine, but equally as often I get a file containing no data with a 0byte file size.

My guess would be something is causing it to dump all the data on the server side, as I am getting print statements showing all the data sending.

I am using C code and currently using a modified example originally provided by sierra wireless "FTP_PUT". This is a simplified example of the closing stage:

dataWritten = wip_write(data_channel, bufferPtr + offset, buffSize - offset);

if(dataWritten != 0)
{
   print("%d bytes sent in this packet",dataWritten);  //appears to send everything
}

offset += dataWritten;
if(offset == bufferSize)
{
   wip_close(data_channel);
}
Dave Engineer
  • 386
  • 1
  • 3
  • 12
  • 1
    You're not giving us any information that would help us diagnose your problem. No relevant code, no description of the system... – Ross Oct 31 '14 at 18:01
  • Wireless transmission errors can be due to multitude of reasons. Explanation on your setup and application/software architecture can help in troubleshooting the issue. – Karthik Balaguru Oct 31 '14 at 18:39
  • Sounds like you either need to modify the server to save partial results, or better change the mechanism. Instead of FTP, try using something simpler and just record each chunk of data as it is received. Have a good retry confirmation and retry mechanism in order to re-establish connection as soon as possible. – Chris Stratton Oct 31 '14 at 19:00

1 Answers1

1

Found the problem, the standard built in function for sierra wireless "wip_close(data_channel)" was not shutting down the line correctly.

The software would start by putting a named file on the FTP server - 0bytes.

Packets appeared to be sending successfully.

When closing down a data channel that uses FTP you must ensure the connection is closed correctly otherwise all the data packets appear to be dropped.

0 bytes is simply because the file was placed there before transferring the packets.

For other sierra wireless users wanting more detail, see below:

Original Code:

handle_events_on_FTP_channel(){

case WIP_CEV_OPEN:
   wip_putFile(control_channel,x,x,x)
   break;

case WIP_CEV_PEER_CLOSE:
   wip_close(data_channel);
   data_channel = NULL;

   wip_close(control_channel);
   control_channel = NULL;
   break;
}

Modified Code:

handle_events_on_FTP_channel(){

case WIP_CEV_OPEN:
   wip_putFile(control_channel,x,x,x)
   break;

case WIP_CEV_PEER_CLOSE:
   wip_close(data_channel);
   data_channel = NULL;

   wip_close(control_channel);
   control_channel = NULL;
   break;

case WIP_CEV_DONE:
   wip_close(control_channel);
   break;
}

Original Code:

handle_events_on_data_channel(){

case WIP_CEV_WRITE:
   wip_write(data_channel,x,x)

   if(ALL_DATA_TRANSMITTED){
      wip_close(data_channel);
      data_channel = NULL;

      wip_close(control_channel);
      control_channel = NULL;
   }
   break;
}

Modified Code:

handle_events_on_data_channel(){

case WIP_CEV_WRITE:
   wip_write(data_channel,x,x)

   if(ALL_DATA_TRANSMITTED){
      wip_shutdown(data_channel,FALSE,TRUE)   //Channel, Input, Output
   }
   break;

case WIP_CEV_PEER_CLOSE:
   wip_close(data_channel);
   data_channel = NULL;
}

n.b. code is modified to be minimal and not character for character the same as the demo but enough is here to make the modifications necessary.

Dave Engineer
  • 386
  • 1
  • 3
  • 12