Main Site Documentation

Saving data from fez to laptop without sd card


#1

I wanna save my datas to excel over the bluetooth module. Has anybody got like that application or code? I created a gadgeteer project and wanted to embad a new code into my existing code.


#2

The simplest way is to send your data as ascii over serial port profile and log the data in hyper terminal or teraterm on the pc


#3

Hi,
you can use my FEZ/PC Bluetooth File Transfer application

https://www.ghielectronics.com/community/codeshare/entry/823

Notice: If you have a 64 bit Version of Windows on your PC, you must open Visual Studio as Administrator that the 32feet.net can be used.

Edit: Didn’t notice that you don’t have the data in a file, but perhaps you can use parts of the code anyway.


#4

@ hagster - hi thank you for answer. I used teraterm and could to print values, but i want to save datas to excel.


#5

@ RoSchmi - Hi thank you for answer. Can i use that app without sd card because i havn’t. and can i save datas to excel over that application?


#6

The code on the FEZ Side must be changed, but it should not be to hard to change it to transfer a file from Ram instead of SD-Card


#7

Saving as a native Excel file is complex. You can save as a comma seperated variable (CSV) file. Excel will open this fine.


#8

@ hagster - Can i save my fez datas to csv file by teraterm?


#9

@ RoSchmi - it’s quite complicated.can you give me any suggestion how i can change that to without Sd card?


#10

BluetoothFtpClient is the appliaction for the PC. No changes should be required there.

Bluetooth_Ftp_Server is the application for the Spider.

You must select your Mainboard here:


//This application can be used on different mainboards
//The actually not used mainboards are outcommented
//#define Cobra_2
//#define CerbuinoBee

    #define Spider

//#define Raptor

then, if you have no SD-Card, outcomment the code that initializes the SD-Card



/*
                // SD-Card stuff for Spider
                //*******************************************************************************************
                
                #if Spider || Raptor
                    //Mount SD-Card
                    sdCard.MountSDCard();
                    System.Threading.Thread.Sleep(500);
                    String rootDirectory = sdCard.GetStorageDevice().RootDirectory;
                    if (VolumeInfo.GetVolumes()[0].IsFormatted)
                    {
                        _root = VolumeInfo.GetVolumes()[0].RootDirectory;
                        string[] files = Directory.GetDirectories(_root);
                        for (int i = 0; i < files.Length; i++)
                        {
                            // Debug.Print(files[i]);
                        }
                    }
                    else
                    {
                        Debug.Print("Cannot use SD-Card");
                    }
                #endif
                
                //******************************************************************************************
                */


the bluetooth module should be on socket 8, otherwise change


const int MySocketNumber = 8; 

then your applications should compile and the devices should connect over bluetooth (see video)


#11

@ RoSchmi - in the video you wrote “ftp President Secretservice”. what should i write? Because i wrote Pulse values and got that


#12

then outcomment the line

// _root = NormalizeDirectory(ud.StartDirectory);

in the BtFtpServer.cs class


 // Find user
            UserData ud;
            for (int i = 0; i < _users.Count; i++)
            {
                ud = (UserData)_users[i];
                if (ud.Username == Username)
                {
                    if (ud.Password == Password)
                    {
                        _permissions = ud.Permissions;

                      //  _root = NormalizeDirectory(ud.StartDirectory);

                        _dir = _root;
                        DebugLine("User '" + Username + " logged in");
                        DebugLine("Directory is now " + _dir);
                        return true;
                    }
                    else
                    {
                        DebugLine("User '" + Username + " login failed; incorrect password");
                        return false;
                    }
                }
            }

now you should be able to connect with the command

ftp RoSchmi Password (don#t Forget to check the ftp-mode Checkbox)

then not file dependent commands should work

like

cmd gelb


#13

If you want to write an excel file the simple way with formations, you could just save an html page with an single table and name the file .xls.
Never tried it my self, but it should work.
If you need no formations, use csv, as already suggested.


#14

in the Server the possible Passwords i used were

ftp President SecretService

and

RoSchmi password

you can include other combinations in the code of the Server (see program)


#15

then you must search this code section in the BtFtpServer.cd Class
here the selected file is send over the BT-Connection. You must adapt this code that your file from the Ram is transferred.


private void FTP_RETR(string Param)
        {
            byte[] b = new byte[2048];
            FileStream iFile;
            long lRemain;
            if (!_permissions.CanDownload)
                client.Send(Encoding.UTF8.GetBytes("500 RETR not allowed for this user\n"));
            else
            {
                string sFile = NormalizeFile(Param);
                DebugLine("?? " + sFile);
                if (!File.Exists(sFile))
                    client.Send(Encoding.UTF8.GetBytes("500 " + RemoveRoot(sFile) + " does not exist\n"));
                else
                {
                    try
                    {
                        client.Send(Encoding.UTF8.GetBytes("150 opening data connection for " + FixPath(sFile) + "\n"));
                        Thread.Sleep(1000);
                        // Send File in Chunks
                        iFile = new FileStream(sFile, FileMode.Open, FileAccess.Read);
                        lRemain = iFile.Length;

                        while (lRemain > 0)
                        {
                            if (lRemain < 2048)
                                b = new byte[lRemain];

                            DebugLine("## Sending " + b.Length + " bytes; " + lRemain + " remain...");
                            iFile.Read(b, 0, b.Length);
                            //client.Send(Encoding.UTF8.GetBytes("125 Send Data \n"));
                            client.Send(b);
                            lRemain -= b.Length;
                            Thread.Sleep(400);
                        }
                        iFile.Close();
                       
                        Thread.Sleep(1000);
                        client.Send(Encoding.UTF8.GetBytes("226 Transfer complete.\n"));
                    }
                    catch (Exception)
                    {
                        client.Send(Encoding.UTF8.GetBytes("456 Transfer failed!\n"));
                    }
                }
            }
        }


I am away now for a while, bye


#16

@ Reinhard Ostermeier - I had pulse oximeter module and every foour seconds i get values from module. and I want to save values to excel or csv file over the bluetooth module that my fez doesn’t connect to laptop with usb hub. I’m not programist. i’m just try to find out the simple way for solving that problem.


#17

Well if it’s just for saving the data in a format excel can open, then I would use CSV.
Every line is a row.
Columns are separated by comma ‘,’.
Any program like Excel (OpenOffice clac, …) can open and save this format.


#18

Hi,
there are at least two different ways you can use.
The first way is that you collect your data in a data structure as a file, an Array or an ArrayList. If you are ready with collecting data you stop collecting and transfer all your data in one batch in a file on your PC. For this way you can adapt my my BtFtp Program.

The second way is, that you “stream” your data over the Bluetooth Connection, catch the incoming data with a program on your PC and write the data to a file when you want to stop collecting.

Did you get my BtFtp Programm working?


#19

@ RoSchmi - Hi. yes it worked but it didn’t send any data to pc because i havn’t xml doc or any data collection so i get momentary values. and i don’t know how i can collect them.Should i make another project for data collection or i can solve it with adding a few line code to my gadgeteer project.


#20

I can send you another PC project that has the functions you want. If you send me a direct message with your E-Mail address, I can send it as zip file.