Please нelp to find the bug – a file transfer from FTP

acronis
Mon Jul 31, 2017 5:43 am
took the example from here: http://playground.arduino.cc/Code/FTP

File transfer to FTP server is excellent.

// #define FTPWRITE

But when I need to read from ftp server and write to the SD card , the file is created on the SD card with 0 length , and the program hangs or loops.
Can’t find what the problem is.

The file is opened for reading via FTP and then FTP gives the error “Connection timed put”

Need help

understand that never goes out of this subroutine:

.......
dclient.stop();
Serial.println(F("Data disconnected"));

serial.print("here goes");
if(!eRcv()) return 0; //comes in here ever comes back

serial.print("here misses");
......


stevestrong
Mon Jul 31, 2017 8:30 am
Shouldn’t you include “Ethernet_STM.h” instead of “Ethernet.h” ?

Do you connect both SD card and Ethernet module to the same SPI1 port?
Check the Ethernet chip select pin.
Alternatively use separate SPI ports.


acronis
Mon Jul 31, 2017 8:42 am
Hello stevestrong .

I use your latest version library https://github.com/stevstrong/Ethernet_STM32
+ https://github.com/stevstrong/Arduino_STM32
+ SDIO viewtopic.php?f=39&t=2215
+ https://github.com/stevstrong/Adafruit_ … 6bit_STM32

board STM32F407VET6 black + w5500 (SPI1) + TFT

#include <Adafruit_TFTLCD_16bit_STM32.h>
#include “SdioF4.h”
#include <Ethernet_STM32.h>
SPIClass mSpi(1);

byte mac[] = { 0x90, 0xA2, 0xDA, 0x00, 0x59, 0x99 };
IPAddress ip( 10, 22, 5, 199 );
IPAddress gateway( 10,22, 1, 1 );
IPAddress subnet( 255, 255, 0, 0 );
IPAddress server( 10,22, 5, 4 );
EthernetClient client;
EthernetClient dclient;

Ethernet.init(mSpi, PA4);
Ethernet.begin(mac, ip, gateway, gateway, subnet);


stevestrong
Mon Jul 31, 2017 8:44 am
Then you should use:
#include <SdioF4.h>
#include <Ethernet_STM32.h>

acronis
Mon Jul 31, 2017 8:47 am
I did everything as written in this thread viewtopic.php?f=39&t=2215

stevestrong
Mon Jul 31, 2017 8:48 am
Did you test separately SDIO and Ethernet?

acronis
Mon Jul 31, 2017 8:53 am
No – not tested.
How do I test receiving a file from an FTP server without writing to SD card ?

acronis
Mon Jul 31, 2017 9:07 am
checked again – the program stops or loops it on the

dclient.stop();
if(!eRcv()) return 0; // <<<<<<<<< this routine

and

client.println(F(“QUIT”));
if(!eRcv()) return 0; // <<<<<<<<<<<<< this routine

byte eRcv()
{
byte respCode;
byte thisByte;

while(!client.available()) delay(1);

respCode = client.peek();

outCount = 0;

while(client.available())
{
thisByte = client.read();
Serial.write(thisByte);

if(outCount < 127)
{
outBuf[outCount] = thisByte;
outCount++;
outBuf[outCount] = 0;
}
}

if(respCode >= '4')
{
efail();
return 0;
}

return 1;
}


stevestrong
Mon Jul 31, 2017 9:24 am
[acronis – Mon Jul 31, 2017 8:53 am] –
No – not tested.
How do I test receiving a file from an FTP server without writing to SD card ?

You should test separately.
You could just print out to serial the received bytes.
I don’t know what eRcv() does, but if it works without, then use it like that.
Check out the warning messages in Arduino IDE.


victor_pv
Mon Jul 31, 2017 12:56 pm
Check this value on that routine:

respCode = client.peek();


stevestrong
Mon Jul 31, 2017 1:10 pm
client.peek() returns a byte, so I don’t see any problem here, which does not mean that it cannot be something wrong with that function.

victor_pv
Mon Jul 31, 2017 4:02 pm
[stevestrong – Mon Jul 31, 2017 1:10 pm] –
client.peek() returns a byte, so I don’t see any problem here, which does not mean that it cannot be something wrong with that function.

Yeah I mean not the return type being invalid, but rather peek returning a value higher than 4 when it is not expected, either due to a bug, or due to some corruption in the communication.


Leave a Reply

Your email address will not be published. Required fields are marked *