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");
......
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.
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);
#include <SdioF4.h>
#include <Ethernet_STM32.h>
How do I test receiving a file from an FTP server without writing to SD card ?
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;
}
[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.
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.
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.