Connection to FTP server

Go To Last Post
23 posts / 0 new
Author
Message
#1
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

hello everyone,

 

I'm trying to connect my atxmega256a3bu to ftp server using enc28j60

 

i am already using it to post/receive  sensor data and configuration data from my server.....

 

now i want to download file from my ftp server.

 

 

how should i go with this???

Last Edited: Wed. Oct 21, 2020 - 09:49 AM
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 1

Mehul9 wrote:
how should i go with this???
Umm, implement the FTP protocol ? (that is https://tools.ietf.org/html/rfc354 )

 

(presumably the "post/receive" you mention is using HTTP not FTP protocol?)

 

PS back in the day there were software stacks for ENC28J60 such as "lwiP" that included protocols like FTP

 

PPS do people still really use EC28J60 all these years later??

 

EDIT: see for example: https://github.com/matwey/lwip-e... see also: https://lwip.fandom.com/wiki/LwI...

 

EDIT2: particularly interesting.. .https://github.com/gezedo/lwftp

 

EDIT3: Oh and I forgot to mention TFTP - probably worth a look "Trivial FTP" is a "cut down" version of FTP with just basic functionality (but the key thing is it can send/receive files): https://tools.ietf.org/html/rfc1350

Last Edited: Wed. Oct 21, 2020 - 10:04 AM
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

hi clawson,

 

this is the first time i'm working with ethernet code...i'll take time for me to digest all this..

 

could i reuse the http flow for the ftp by making the specific changes or ftp connection is totally different.

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Mehul9 wrote:
this is the first time i'm working with ethernet code.

I would strongly suggest that you don't start doing it on a microcontroller!

 

Spend time on a PC or similar to get familiar with the protocols and how they work.

 

You can use things like curl to help:

 

https://curl.haxx.se/

 

https://ec.haxx.se/usingcurl/usingcurl-ftp

 

Learn how to use diagnostic tools like Wireshark:

 

https://www.wireshark.org/

 

Top Tips:

  1. How to properly post source code - see: https://www.avrfreaks.net/comment... - also how to properly include images/pictures
  2. "Garbage" characters on a serial terminal are (almost?) invariably due to wrong baud rate - see: https://learn.sparkfun.com/tutorials/serial-communication
  3. Wrong baud rate is usually due to not running at the speed you thought; check by blinking a LED to see if you get the speed you expected
  4. Difference between a crystal, and a crystal oscillatorhttps://www.avrfreaks.net/comment...
  5. When your question is resolved, mark the solution: https://www.avrfreaks.net/comment...
  6. Beginner's "Getting Started" tips: https://www.avrfreaks.net/comment...
Last Edited: Wed. Oct 21, 2020 - 01:22 PM
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

thanks awneil,

 

first time means not first time with ftp protocol...

 

i have worked with ftp+php, atxmega+ftp+gsm,etc...

 

this my first time with ftp on atxmega using ethernet as connectivity medium...

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

and yet you're asking questions which show that you haven't understood how those things actually work.

 

FTP works over TCP/IP

 

The whole point of the layered structure is that TCP/IP neither knows nor cares what transport is used below it - so, if you've done it over GSM, it'll be the same over Ethernet. Or WiFi. Or dial-up. Or Avian Carriers, Or ...

Top Tips:

  1. How to properly post source code - see: https://www.avrfreaks.net/comment... - also how to properly include images/pictures
  2. "Garbage" characters on a serial terminal are (almost?) invariably due to wrong baud rate - see: https://learn.sparkfun.com/tutorials/serial-communication
  3. Wrong baud rate is usually due to not running at the speed you thought; check by blinking a LED to see if you get the speed you expected
  4. Difference between a crystal, and a crystal oscillatorhttps://www.avrfreaks.net/comment...
  5. When your question is resolved, mark the solution: https://www.avrfreaks.net/comment...
  6. Beginner's "Getting Started" tips: https://www.avrfreaks.net/comment...
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 1

As others have pointed out, ENC28J60 is ancient, buggy, and will require a TCP/IP stack on top.

 

I suggest you have a look at WIZnet's W5200 or W5500 devices for a modern SPI -> Ethernet interface with built-in TCP/IP stack. There are plenty of cheap preassembled modules (WIZ820io for example) and plenty of example software to get you started.

 

Steve

 

Maverick Embedded Technologies Ltd. Home of Maven and wAVR.

Maven: WiFi ARM Cortex-M Debugger/Programmer

wAVR: WiFi AVR ISP/PDI/uPDI Programmer

https://www.maverick-embedded.co...

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

 ... or a microcontroller with built-in Ethernet ...

Top Tips:

  1. How to properly post source code - see: https://www.avrfreaks.net/comment... - also how to properly include images/pictures
  2. "Garbage" characters on a serial terminal are (almost?) invariably due to wrong baud rate - see: https://learn.sparkfun.com/tutorials/serial-communication
  3. Wrong baud rate is usually due to not running at the speed you thought; check by blinking a LED to see if you get the speed you expected
  4. Difference between a crystal, and a crystal oscillatorhttps://www.avrfreaks.net/comment...
  5. When your question is resolved, mark the solution: https://www.avrfreaks.net/comment...
  6. Beginner's "Getting Started" tips: https://www.avrfreaks.net/comment...
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

 

Mehul9 wrote:
could i reuse the http flow for the ftp by making the specific changes or ftp connection is totally different.
If this is about posting data to a server then a technique I've used in the past are HTTP parameters.

Say you do a

GET www.google.com HTTP/1.1

then obviously that only delivers the requested item and while there is an HTTP POST mechanism one way to "get stuff to the server" even though you are just getting is something like:

GET www.google.com?name=cliff&location=Finchingfield&occupation=drunk& etc. etc.

when I do that I still get the same data/page returned:

 

 

but the server, in it's HTTP logs now has "name=cliff&location=Finchingfield&occupation=drunk". 

 

You can get "fancier" with this if you like. Say I want to send this file:

 

 

That's a very small version of:

 

 

but I wanted to reduce the size of the data simply for illustration. So how do I get that sea of pixels attached to an HTTP GET request? Well I could use a tool like:

 

http://www.webutils.pl/UUencode

 

(which can easily be done in micro code too) to "uuencode" the binary. So the data for my little picture becomes:

 

MB5!.1PT*&@H````-24A$4@```!@````6"`8```#:?5R(`````7-21T(`KLX<
MZ0````1G04U!``"QCPO\804````)<$A9<P``"Q,```L3`0":G!@````'=$E-
M10?;"P\1("U6(=:;```&C$E$051(2RV528Q<Y16%OS?4>_6JZM5</52[>G#/
MC:=N.]A)4&*&!"G(N[!D$8'81%:41?:E[%"(R")SQ"8)"$61D1698##!$YA`
MX[0-N-T=FQ[20_5<0]<\_+E=\$I5);WWO_O?<\X]YT=]?;WZZU?4R82K)N..
M^M,?_ZK^_O8=]?)+OU)O7;S0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R:>*+):3VR\_N4JSC3#1F6`V
MDZ,FW1X@WY+Q[`SYT&2C4EM8/WVRV8/53?X/`+WE6FV3HX@`````245.1*Y"
"8((`
`

and now I make my GET request:

GET www.google.com?name=cliff&location=Finchingfield&occupation=drunk&picture=MB5!.1PT*&@H````-24A$4 etc. etc

and I have managed to deliver the data to the HTTP log of the server. Now it's a bit trickier than this as that data, even though uuencode is supposed to be typeable/transmittable does contain some punctuation (like '&' for example) which might be interpreted as part of a GET request so I might want to change the encoding slightly. Another approach is "base64 encode". With that the picture data (or any binary I wanted to send) would become (using https://www.base64encode.org/ for example):

 

iVBORw0KGgoAAAANSUhEUgAAABgAAAAWCAYAAADafVyIAAAAAXNSR0IArs4c6QAAAARnQU1BAACx
jwv8YQUAAAAJcEhZcwAACxMAAAsTAQCanBgAAAAHdElNRQfbCw8RIC1WIdabAAAGjElEQVRISy2V
SYxc5RWFvzfUe/Wq6tVcPVS7enDPjaduO9hJUGKGBCnIu7BkEYHYRFaURfal7FCIyCJzxCYJCEWR
kRWZYDDBE5hA47QNuN0dmx7SQ/VcQ9c8/Lld8EpVJb33v/vfc84950d9fb3661fUyYSrJuOO+tMf
/6r+/vYd9fJLv1JvXbzQfn7u7HfVsZirTnZF1HjYUa+mf6rOP3tOnT5+RM1eeV2FQPWGAiph6Wps
eFD5XVdFIhGl8/Xlj8S4n61QwcPo2ASOqeMPhpi+drP9PNnTjY7C1DUMTWN9dZ2G3DEtD2/+4x1s
j05xf5/vnJnixedfIBYMymow//BSGkurc3vmLmWlkfP4SfX0kNmusuMLU44muPTGXwj5LDym1t7A
I9+N3QK1lkZTqsw+XKPZbHH+xecID03iJAbwB/zky2V0raGoFgo0SwU0+RjysqDE7+jtrrz+ANNv
X6aa3Wx3bmpNQQd1KViu1KhLUz3eMj9+4TkSI1NE+k5gqhYLS0uYpok+v7DA/NIae4Uy8j65bI5G
tdIu4lgBWvtZlpcX2Nrcpnt4jGa8r41yN5cnV64Scx2SQ1N0j58inDrG4PAxvvj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G1vZTPOiTsBNO
GyJIrVYjs7bOzsYahXyOZ588w8bKCjfF5V/uVtmQxN8rNXn8yafIN314k6Ns1yxh12BTkvXi5Sts
rS4Q7+hq67eytUel0foKgS7dt5pNSVKdSqVKf28vyaiPhN/DJx9+SM106OvvY2xkFNuxWc6VuHTp
La69f405MdnMzAwVyW27WWYtk8EXCBKQ6cqXqhhen5tWUlygoB2kn26gaiV+8L3HiUfDhCQibl2/
zv92CswtLHJfqLv8599ReTiNY+u0NIO7D5fES0WU7mFb0thvm5hOgJjPRAtF4uqgsGrJJlK81Wrh
FXF/9PQZGsUsG2sbB26k2oRwwMHWGhRbOq4YK1uF2wuZdmxXypW2uapCy8Fw+NyQmHcXvSEmU00h
TYKi2ajLv5KgqhMffARLpmqoJ0Q06jKWCmP7bAyJ85phk9nb587iupwjkjlywARsg1TET9Rvy72S
CA2HuyJoATekxG1y5MkJKxpoQtWB4OOHU8QsyaeKLJaT2y8/uUqzjTDRmWA2k6Mm3R4g35Lx7Az5
0GSjUltYP32y2YPVTf4PAL3lWm2To4gAAAAASUVORK5CYII=

So the GET request would be:

GET www.google.com?name=cliff&location=Finchingfield&occupation=drunk&picture=iVBORw0KGgoAAAANSUhEUgAAABgAAAAWCAYAAADafVyI etc etc

By the same technique you could convey anything to an HTTP server - even if it only supports GET

 

I've used this technique in the past to convey almost 4K of data on requests which told us what a population of about 250,000 units had been doing with their time each day - it did make for astronomically large HHTP logs on the server though !

 

Last Edited: Wed. Oct 21, 2020 - 02:49 PM
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

clawson wrote:
one way to "get stuff to the server" even though you are just getting is something like:

GET www.google.com?name=cliff&location=Finchingfield&occupation=drunk& etc. etc.

@ Mehul9  - for more on that, see:  https://www.jmarshall.com/easy/http/http_footnotes.html#getsubmit

 

Commonly, this would be used in conjunction with CGI: https://www.jmarshall.com/easy/cgi/

 

 

Top Tips:

  1. How to properly post source code - see: https://www.avrfreaks.net/comment... - also how to properly include images/pictures
  2. "Garbage" characters on a serial terminal are (almost?) invariably due to wrong baud rate - see: https://learn.sparkfun.com/tutorials/serial-communication
  3. Wrong baud rate is usually due to not running at the speed you thought; check by blinking a LED to see if you get the speed you expected
  4. Difference between a crystal, and a crystal oscillatorhttps://www.avrfreaks.net/comment...
  5. When your question is resolved, mark the solution: https://www.avrfreaks.net/comment...
  6. Beginner's "Getting Started" tips: https://www.avrfreaks.net/comment...
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Mehul9 wrote:
... using enc28j60
fyi, ENC28J60 is in Microchip's TCP/IP stack.

Mehul9 wrote:
how should i go with this???
Given a socket interface, can roll your own FTP code as that's not of great difficulty (medium difficulty); TFTP may be enough.

μC/OS is OSS so could look at its network stack.

Another form of socket is WebSocket (WebSocket server, WebSocket client one of which is a web browser); a WebSocket server can fit in some XMEGA.

 


AN1921 Microchip TCP/IP Lite Stack | Application Notes | Microchip Technology Inc. via Ethernet of Everything | Microchip Technology

AN_2396 AVR460: Embedded Web Server on megaAVR devices

RFC Index (IETF)

Micrium µC/OS to be open source | AVR Freaks

µC/TCP-IP - µC/TCP-IP Documentation - Micrium Documentation

https://github.com/SiliconLabs?q=ftp&type=&language=

https://github.com/SiliconLabs?q=tftp&type=&language=

Efficient web server technology for resource-constrained microcontrollers - Embedded.com (WebSocket)

GitHub - saleae/Simple-WebSocket-Server (C++)

 

"Dare to be naïve." - Buckminster Fuller

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

There's Aruduino Arduino code for WIZnet.

CP2201 is mentioned in AoE.

DAVICOM has Ethernet controllers; DM9000 for bus-wide, DM9051 (SPI) has Linux code.

 

P.S.

W6100 adds IPv6 and 4 sockets (8 total)

 


Arduino Ethernet Library 2.0.0

CP220x Ethernet Controllers - Silicon Labs

The Art of Electronics 3rd Edition | by Horowitz and Hill (page 1081, #20 in second column)

DAVICOM 聯傑國際

CASIX (AVR and DAVICOM DM9000)

W6100 | WIZnet Co., Ltd.

https://www.mouser.com/WIZnet/_/N-1yzp36r?Keyword=w6100&FS=True

https://octopart.com/search?q=w6100&currency=USD&specs=0&manufacturer_id=3237 (WIZnet)

 

"Dare to be naïve." - Buckminster Fuller

Last Edited: Wed. Oct 21, 2020 - 05:01 PM
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

When there are devices like the ESP8266/ESP32 available at a couple of USD, why would you bother with the enc? Granted they use WiFi, but the whole barrier with the required protocols has been overcome for you.

 

I am frequently amazed at what functionality people have squeezed out of an ESP8266. Look at projects like Tasmota.

 

As for ftp - as mentioned by others, it sits on top of tcp. Like Cliff, I'd just use http to send/grab the file if you have that implemented already. Whether you use a ENC28J60 or whatever, it makes little difference to implementing a higher level protocol. 

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

the board on which i'm working was designed in 2013/14 with communication interfaces 

 

Gsm -- Quectel m66

 

ethernet -- enc28j60

 

and wifi -- HF-LPT100 ....

 

Im building FOTA support in all this devices 

for GSM my work is done...

 

now i have started with ethernet ....

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

again, all of them should provide you with a TCP/IP transport - so things above that (like FTP, HTTP) should not need to know or care which physical transport is being used.

 

EDIT

 

Also, as the others have said, if you've already got HTTP working - why not just use that?

 

You could certainly do FOTA over HTTP.

Top Tips:

  1. How to properly post source code - see: https://www.avrfreaks.net/comment... - also how to properly include images/pictures
  2. "Garbage" characters on a serial terminal are (almost?) invariably due to wrong baud rate - see: https://learn.sparkfun.com/tutorials/serial-communication
  3. Wrong baud rate is usually due to not running at the speed you thought; check by blinking a LED to see if you get the speed you expected
  4. Difference between a crystal, and a crystal oscillatorhttps://www.avrfreaks.net/comment...
  5. When your question is resolved, mark the solution: https://www.avrfreaks.net/comment...
  6. Beginner's "Getting Started" tips: https://www.avrfreaks.net/comment...
Last Edited: Fri. Oct 23, 2020 - 08:31 AM
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

sorry awneil,

 

my mistake .......i am not using http

 

actually i'm using tcp port 3003  and on our side we have a java listener on server..... listening for our custom packet structure....

 

 

bwt...before going deep into ftp i have a basic question....

 

previously in my gsm code(as per my chipset ability)... i was downloading the whole file to my gsm chipset memory...and then reading to my atmega external flash memory(200 bytes at a time[250bytes max capacity]).

 

so i want to know that is it possible to  read a file from ftp bytes by bytes...(200 bytes at a time then store in external flash)...till end of file???

 

 

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Mehul9 wrote:
actually i'm using tcp port 3003  and on our side we have a java listener on server..... listening for our custom packet structure....

So why can't you just keep doing that?

 

Again, TCP port 3003 neither knows nor cares whether the underlying transport is GSM or WiFi or Ethernet or ...

Top Tips:

  1. How to properly post source code - see: https://www.avrfreaks.net/comment... - also how to properly include images/pictures
  2. "Garbage" characters on a serial terminal are (almost?) invariably due to wrong baud rate - see: https://learn.sparkfun.com/tutorials/serial-communication
  3. Wrong baud rate is usually due to not running at the speed you thought; check by blinking a LED to see if you get the speed you expected
  4. Difference between a crystal, and a crystal oscillatorhttps://www.avrfreaks.net/comment...
  5. When your question is resolved, mark the solution: https://www.avrfreaks.net/comment...
  6. Beginner's "Getting Started" tips: https://www.avrfreaks.net/comment...
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

yes that's better.....because the packet structure is also custom and i have full control over it..

 

 

but like have said...just want to know...

 

1) from ftp server can i open and read a file byte by byte(200 bytes at a time)?

 

Last Edited: Fri. Oct 23, 2020 - 11:42 AM
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Mehul9 wrote:
1) from ftp server can i open and read a file byte by byte(200 bytes at a time)?
If it's 200 bytes why do you need to use FTP? Why can't you do an HTTP GET? Obviously the server has to be configured to deliver files by HTTP GET but most can.

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Mehul9 wrote:
1) from ftp server can i open and read a file byte by byte(200 bytes at a time)?

It's an open protocol; the specification is publicly available - clawson has already given you the link - so why not take a look at it?

 

But FTP = File Transfer Protocol - so, if you don't want to transfer the data as a File, why choose a protocol where that is its key function?

Top Tips:

  1. How to properly post source code - see: https://www.avrfreaks.net/comment... - also how to properly include images/pictures
  2. "Garbage" characters on a serial terminal are (almost?) invariably due to wrong baud rate - see: https://learn.sparkfun.com/tutorials/serial-communication
  3. Wrong baud rate is usually due to not running at the speed you thought; check by blinking a LED to see if you get the speed you expected
  4. Difference between a crystal, and a crystal oscillatorhttps://www.avrfreaks.net/comment...
  5. When your question is resolved, mark the solution: https://www.avrfreaks.net/comment...
  6. Beginner's "Getting Started" tips: https://www.avrfreaks.net/comment...
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

hi clawson,

 

my binary file is sitting on ftp server...

 

rather than going with http, like awneil said i would with my current connection(TCP port 3003)

 

just for knowledge want to know.. that is it possible to open and read the content of files from ftp server bytes by bytes..

 

secondly....i dont think that if i try to directly download a file from ftp(using get cmd), i would be able to store it in external flash...()even rx buffer size is limited...

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

You can read the byte stream from the FTP server into a buffer that is <= the file size, and then write it out to ... EEPROM ? 

 

Assuming the TCP/IP stack you're using follows the usual API, you will have a socket read() function that you call repeatedly once the connection has been established and (assuming FTP) the login/password have been provided and accepted. The common prototype for read() is:

 

ssize_t read(int fildes, void *buf, size_t nbyte);

 

This reads a maximum of nbyte bytes into a buffer you provide. It may read less than this amount, e.g. at end-of-file. So, just loop until you have received all the bytes you are expecting, or EOF, or an error.

 

If you're really short of memory, you could read a byte at a time. 

 

The are millions of C socket client examples online.

 

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Mehul9 wrote:
my binary file is sitting on ftp server...
Believe me it is going to be about a million times easier simply to make the same file that's sitting on the server visible to both HTTP and FTP servers than it is to add an FTP protocol to a client that doesn't yet have it. Personally I'd always aim for the easy, safe, simple solution if I were you!