FTP Server

For [what feels like] the first time in 2 years I’ve put up some code that’s not Pyxis related.

Pretty fully functional FTP server over on fezzer: http://code.tinyclr.com/project/301/tinyclr-forum-client/

Very good. Nice presentation.
BTW is that Wouter’s NameService class?

Sure is. Left his header & namespace intact. And of course using the name service is optional.

As always, well done

Thanks Gus :smiley:

Might do an FTP client as well if anyone is interested.

Yes, please. I am sure someone will appreciate it.

Good work !

yeah i can see scenarios where i would push not pull files to Fez so client would be great too

Great extension to the NameService class. :smiley:

Really, great job!

i have problems with ftp server… i can connect with username and password but i can not get files list, upload or download and other things from pc application (etc filezilla). only MS command line ftp client can do everything!. any idea?!


PS. it works on panda ii…

FTP will be an app on Gadgetos so I will definitely be working on this but it will have to wait until the core systems are finished. I’ll post a follow up when there is a resolution. In the mean time stick w the commandline.

When I click on the link in the original post I get this site:

correct link: http://code.tinyclr.com/project/256/netmf-ftp-server/


uFTPServer now works with CommandLine FTP, FileZilla, and Windows Explorer FTP.

1 Like

I’ve merged the Wifi adhoc example for the GHI Wifi Module and the uFTPServer example in order to be able to transfer data files on an SD card back and forth between a Wifi link.
Wifi connection works, ftp server autenticates my user name and password. Can create directories and delete them on the SD card, but cannot list files, or transfer any data… Any ideas why? Here is my main code.

namespace wifi_adhoc_host
    /// Add these libraries to your project's References
    /// System
    /// Microsoft.SPOT.Hardware
    /// Microsoft.SPOT.Net
    /// GHIElectronics.NETMF.System
    /// GHIElectronics.NETMF.Net
    using System;
    using System.Threading;
    using System.Net.Sockets;
    using System.Collections;
    using System.Net;
    using Microsoft.SPOT;
    using Microsoft.SPOT.IO;
    using Microsoft.SPOT.Net.NetworkInformation;
    using Microsoft.SPOT.Hardware;
    using GHIElectronics.NETMF.Net;
    using GHIElectronics.NETMF.Hardware;
    using GHIElectronics.NETMF.IO;
    using System.Text;

    public class Program
        static NetworkManager nm;
        static NameService ns;
        static FTPServer ftp;
        static PersistentStorage _sd;

        public static void Main()
            //ChipworkX Developement System V1.5 UEXT header with WiFi RS21 Module: P/N:GHI-WIFIEXP2-298
            //SPI.SPI_module _spi = SPI.SPI_module.SPI2; /*SPI bus*/
            //Cpu.Pin _cs = ChipworkX.Pin.PC9; /*ChipSelect*/
            //Cpu.Pin _ExtInt = ChipworkX.Pin.PA19; /*External Interrupt*/
            //Cpu.Pin _reset = ChipworkX.Pin.PC8; /*Reset*/
            //EMX Developement System V1.3 UEXT header with WiFi RS21 Module: P/N:GHI-WIFIEXP2-298
            //SPI.SPI_module _spi = SPI.SPI_module.SPI1; /*SPI bus*/
            //Cpu.Pin _cs = EMX.Pin.IO2; /*ChipSelect*/
            //Cpu.Pin _ExtInt = EMX.Pin.IO26; /*External Interrupt*/
            //Cpu.Pin _reset = EMX.Pin.IO3; /*Reset*/
            //FEZ Cobra OEM board V1.2 or V1.3 UEXT header with WiFi RS21 Module: P/N:GHI-WIFIEXP2-298
            SPI.SPI_module _spi = SPI.SPI_module.SPI2; /*SPI bus*/
            Cpu.Pin _cs = EMX.Pin.IO2; /*ChipSelect*/
            Cpu.Pin _ExtInt = EMX.Pin.IO26; /*External Interrupt*/
            Cpu.Pin _reset = EMX.Pin.IO3; /*Reset*/

            Debug.Print("Enable WiFi RS2 module");
                //ChipworkX Developement System UEXT header with WiFi RS21 Module: P/N:GHI-WIFIEXP2-298
                            _spi,/*SPI bus*/
                            _cs,  /*ChipSelect*/
                            _ExtInt, /*External Interrupt*/
                            _reset); /*Reset*/
            catch (WiFi.WiFiException e)
                if (e.errorCode == WiFi.WiFiException.ErrorCode.HardwareCommunicationFailure ||
                    e.errorCode == WiFi.WiFiException.ErrorCode.HardwareFirmwareVersionMismatch)
                    //ChipworkX Developement System UEXT header with WiFi RS21 Module: P/N:GHI-WIFIEXP2-298
                                        _spi,/*SPI bus*/
                                        _cs,  /*ChipSelect*/
                                        _ExtInt, /*External Interrupt*/
                                        _reset); /*Reset*/
                                 _spi,/*SPI bus*/
                                 _cs,  /*ChipSelect*/
                                 _ExtInt, /*External Interrupt*/
                                 _reset); /*Reset*/
                else if (e.errorCode == WiFi.WiFiException.ErrorCode.HardwareCommunicationFailure)
                    Debug.Print("Error Message: " + e.ErrorMsg);
                    Debug.Print("Check WiFi module hardware connections and SPI/signals configurations.");

            if (WiFi.IsEnabled)
                Debug.Print("Enabled Successfully. At this point, the on-board LED on RS9110_N_11_21_1_Compatible module is ON.");
                throw new Exception();

            // This event handler checks netowrk avaialblty (Ethernet, WiFi and PPP).
            NetworkChange.NetworkAvailabilityChanged += new NetworkAvailabilityChangedEventHandler(NetworkChange_NetworkAvailabilityChanged);

            //WiFi.StartAdHocHost("Ad-Hoc Test", SecurityMode.Open, "", 10);
            WiFi.StartAdHocHost("FPfuel Wifi WEP", SecurityMode.WEP, "A1CEF53456A1CEF53456AF34DB", 10); // 128bit key (26 Hex numbers)
            //WiFi.StartAdHocHost("Ad-Hoc Test WEP", SecurityMode.WEP, "A1CEF53456A", 10); // 64bit key (10 Hex numbers)
            Debug.Print("Join the other peer of Ad-Hoc connection");
            NetworkInterface[] netif = NetworkInterface.GetAllNetworkInterfaces();
            netif[0].EnableStaticIP("", "", "");
            Debug.Print("Set the other peer's IP to");
            Debug.Print("Try to ping this IP from the other peer");

            // Mount SD card
            Debug.Print(">> Mounting SD...");
            _sd = new PersistentStorage("SD");
            Debug.Print(">> SD MOUNTED");
            VolumeInfo _sdvolumeinfo = new VolumeInfo("SD");
            string rootDirectory = VolumeInfo.GetVolumes()[0].RootDirectory;

            // Start Name Server
            Debug.Print(">> Starting name server...");
            ns = new NameService();
            ns.AddName("ftpserver", NameService.NameType.Unique, NameService.MsSuffix.Default);
            Debug.Print(">> Name server STARTED");

            ftp = new FTPServer("",21,"ftpserver"); 
            ftp.AddLogin("test", "1234", rootDirectory , new FTPServer.UserPermissions(true, true, true, true, true, true)); 
            ftp.AllowAnonymous = true;
            ftp.AnonymousRoot = rootDirectory; 
            ftp.DebugMode = true; 

            //Debug.Print("Disconnect WiFi link.");
            //Debug.Print("Disable WiFi interface");
            //Debug.Print("The end of test");

        static void NetworkChange_NetworkAvailabilityChanged(object sender, NetworkAvailabilityEventArgs e)
            Debug.Print("Network Availability Event Triggered");
            if (e.IsAvailable)
                if (WiFi.IsEnabled)// Make sure that the event is fired by WiFi interface, not other networking interface.
                    if (WiFi.IsLinkConnected)

                        Debug.Print("Ad-Hoc Host started.");
                if (WiFi.IsEnabled)// Make sure that the event is fired by WiFi interface, not other networking interface.
                    if (!WiFi.IsLinkConnected)

                        Debug.Print("WiFi connection was dropped or disconnected!");


And here is the debug messages. I used Filezilla ftp client on my other computer to connect via adhoc wifi.

Cannot see the SD card contents…

P.S , I alson notice a huge jump in ping reply time from the Red Pine RS9110 Wifi module after a first successful ftp connection. Before connecting , we get an average of 3-4 mS reply time, and after, it goes up to 85mS…

Any ideas?

Enable WiFi RS2 module
RS21 WiFi module version Number is 4.4.5
WiFi Module’s MAC Address is 03516729150104
Enabled Successfully. At this point, the on-board LED on RS9110_N_11_21_1_Compatible module is ON.
Join the other peer of Ad-Hoc connection
Network Availability Event Triggered
Ad-Hoc Host started.
Set the other peer’s IP to
Try to ping this IP from the other peer

Mounting SD…
Starting name server…
Name server STARTED
[01/01/2009 00:01:32] Listening for connection
[01/01/2009 00:02:03] Accepted a connection from
[01/01/2009 00:02:03] << USER test
[01/01/2009 00:02:03] << PASS 1234
[01/01/2009 00:02:03] User 'test logged in
[01/01/2009 00:02:03] Directory is now \SD
[01/01/2009 00:02:03] << PWD

1 Like

Where can i get the latest version?
I am confused. There are 2 different links.
http://www.tinyclr.com/codeshare/entry/240 The title here is strange.

The first one (http://www.tinyclr.com/codeshare/entry/197) is the FTP server
The second link (http://www.tinyclr.com/codeshare/entry/240) allows you to view this forum on your NETMF device. Not sure if the current version of the forum is compatible or not; haven’t tried lately.

I see the confusion. It looks like I accidentally overwrote the forum code w/ the FTP server. Oops. If I have to forum code around somewhere I’ll re-upload it.

@ Makla - on which mainbord do you want to use the ftp-client? I have it running (with modifications) on spider with SDK 4.1 in an application to monitor the on-time of our oil-burner. If you want to use it on a spider, I could send you the code.

1 Like

Yes, i want to use it on spider. For now. But when i get Cobra II it will probably be moved. Could you please send it to “novice(you_know)svetiduh.si”

I started the FTP server on G400D development board and used FileZilla to connect it. The following errors were returned:

Status: Connecting to…
Status: Connection established, waiting for welcome message…
Status: Insecure server, it does not support FTP over TLS.
Status: Server does not support non-ASCII characters.
Status: Logged in
Status: Retrieving directory listing…
Command: PWD
Response: 257 the current directory is |
Error: Failed to parse returned path.
Error: Failed to retrieve directory listing

Any hints to fix the problem?