![Photo](http://www.gravatar.com/avatar/3ebcf11b13bd8c9cbd20ce40d619e73c?s=100&d=http%3A%2F%2Fforums.netduino.com%2Fpublic%2Fstyle_images%2Fmaster%2Fprofile%2Fdefault_large.png)
Plus SD card slot
#1
Posted 18 October 2011 - 02:37 PM
#2
Posted 18 October 2011 - 04:34 PM
private string path1 = @"\SD\yourfile.txt"; // write 4 lines to a file, overwriting what is there using (StreamWriter file = new StreamWriter(path1)) { for (u = 0; u < 4; u++) { file.Write(u.ToString() + "\n"); } } // position the seek point in the file using (FileStream num = new FileStream(path1, FileMode.Open)) { long offset = inx * 100; num.Seek(offset, SeekOrigin.Begin); b = num.ReadByte(); // read one byte at that location }
In your application, it sounds like you would want to append to an existing file. To do that, set FileMode.Append
#3
Posted 18 October 2011 - 08:51 PM
#4
Posted 18 October 2011 - 08:53 PM
#5
Posted 18 October 2011 - 11:00 PM
Attached Files
#6
Posted 19 October 2011 - 02:09 AM
Further update: The timer server must be unavailable. I tested another address and it connects to an available server. When it cant connect it hangs at the socket.connect(ip) statement. It used to throw an exceoption.
I think you are better off with 4.2 even though it does have issues. I have seen the same things you are seeing with connect hanging, and strange behavior while debugging. But the production release of 4.2 is due out any day now, and the rumor is that these problems have been fixed.
Robert
#7
Posted 19 October 2011 - 06:45 PM
#8
Posted 20 October 2011 - 12:58 PM
#9
Posted 20 October 2011 - 01:19 PM
My code is successfully appending text to a log file in the built-in SD card...thanks for the kickstart Robert.
This leads me to another question. How can this text file be sent to a PC over ethernet so that I don't have to remove the card and plug it in?
If the PC is running Linux, I would run a PHP-supporting Apache web server and transfer the data to it. The Netduino Plus, then takes the role of the web client and sends the data using POST operations. I would code this at the socket level, if I were you, so there is still memory left over for your own code. This is what I am doing for my current project. The coding on both the server side and the client side has turned out to be straight forward. The main issue I needed to overcome was the need for a hardware Watchdog connected to the Netduino (see other posts in these forums for details), as I have found the socket support in the Netduino (at least at the today's state-of-the-art) to occasionally lock up. This approach also has the advantage that the PC can send information/data/commands to the Netduino if desired.
If the PC is running a Windows OS, I would code the PC's server in Python. The Netduino side would be nearly the same, just leave out the HTTPd headers, as they would not be needed. This second approach might be more work for you depending on what languages/systems you are familiar with.
#10
Posted 20 October 2011 - 02:58 PM
#11
Posted 20 October 2011 - 04:55 PM
-- H.L. Mencken, "What I Believe"
#12
Posted 20 October 2011 - 05:29 PM
#13
Posted 20 October 2011 - 08:01 PM
![:)](http://forums.netduino.com/public/style_emoticons/default/smile.png)
-- H.L. Mencken, "What I Believe"
#14
Posted 20 October 2011 - 08:33 PM
When you send the contents of the file, you send the file
HTTP is a protocol many clients speak, not just browsers (for example, http://gnuwin32.sour...ckages/wget.htm is a small commandline utility that can download files over http, . You can also tell a browser to "download" the file and not show it in its own window by sending a Content-Disposition header in the HTTP response. Now, if you wanted to serve multiple files, with a file-explorer-like interface, that'd be a different story, but if you just want so save one file, i'd leave the part on the netduino as-is and just use a tool on your computer to download it.
Stefan
Well, I need to be able to download the file to any standard browser without special code on that end. So I'm guessing I need to have the N+ serve up a download page with a button to start the process. The browser would then display the typical download dialog for the user to decide where to save the file then start the process. There may be some settings files on the SD that would be nice to overwrite from the pc in the event they need to be changed. It would probably need a remote reset after that to update the settings.
#15
Posted 02 December 2011 - 07:24 PM
when using the code
string path1 = @"\SD\yourfile.txt"; // write 4 lines to a file, overwriting what is there using (StreamWriter file = new StreamWriter(path1)) { for (int u = 0; u < 4; u++) { file.Write(u.ToString() + "\n"); } }with references to System.IO and a using- directive to System.IO, I get a System.NotSupportedException.
I'm using the latest 4.2 RC3 firmware.
The microSD card I'm using in my NetduinoPlus is a Sandisk 4GB one.
How can I write a damn file on my SD card?
Thanx.
#16
Posted 02 December 2011 - 10:04 PM
I had what I think is the same problem.
http://forums.netdui...h__1#entry20265
Try another card or try 4.1 firmware.
0 user(s) are reading this topic
0 members, 0 guests, 0 anonymous users