Skip to content

Conversation

@JakeLardinois
Copy link

Fredrik,
You did a great job on that webserver! I am currently using it on a Netduino 3 WiFi that I integrated with a push cart, scale, scanner and label printer. Your software works flawlessly and makes publishing pages to it a snap! Soon I'll be adding functionality to the webserver that allows file uploads; I've got it in beta testing on my ScaleIndicatorPrinter project. Thank you for the server and the input. I am flattered that you are going to incorporate some of the changes I made.

When HTTP request was being built, the http headers were loaded out of
order.  The header that was used to build the RequestLine and URI
required the 'Host' header which was loaded in a subsequent iteration of
the While loop. This resulted in an exception being thrown when the URI
was created.  I resolved this by adding all of the other HTTP headers
first and then loading the RequestLineAndURI after the While loop
completed.
Also, the method that was used to add the headers to the
HeaderCollection in the RequestContext didn't have a constructor for the
HeaderCollection class and so a null exception was thrown as soon as a
header was attempted to add to the HeaderCollection.  I created a
default constructor for the RequestContext Class (Just as was done for
the ResponseContext Class) which solved this issue. I noticed that the
default code had a HeaderCollection constructor in the SetHeaders(),
however this method wasn't utilized.
Added a ToHexString extension method for Byte Arrays.  Changed the
NetworkInterfaceLocator() method so that it would use the new
ToHexString extension method when writing out the MAC address so that it
would be displayed in Hexidecimal instead of its previously displayed
decimal value.
I was having a problem with serializing quotation marks using the
JsonSerializer class.  I implemented Json.NetMF package and implemented
it's serialization method in the Controller Class instead; this
corrected the problem.
Integrated an SDCard Class to help stave off any possible concurrency
update issues that may be encountered from reading and writing the
SDCard.  Implemented a FileController class that can be inherited
instead of Controller when the Rinsen.WebServer.FileAndDirectoryServer
Project is integrated with a Rinsen.WebServer project.
leveraged the JsonSerializer class to inherit from Json.NETMF so that
JSON serialization implementation could remain unchanged.
I added an SDCardContents Directory for use in serving up the
filemanager.html page that shows an ajax post to upload a text file to
the Netduino
@JakeLardinois
Copy link
Author

I added a SDCard manager to help deal with any possible concurrency update issues that could occur from reading/writing to the SDCard.
I added a FileController class that can be inherited from in a Controller class (when the Rinsen.WebServer.FileAndDirectoryServer is being utilized) to augment the uploading of files via http to the SDCard. Along with that I added some default files for the SDCard to serve up, including filemanager.html which shows how to perform an ajax post to upload a file to the file controller.
I also cleaned up the code for utilizing Json.NETMF for serialization so that the initial implementation would be followed through.

Used the .ToUpper() method to perform case insensitive matches on
content types base on file extensions in the FileAndDirectoryService
Class. Replaced Method text matches with enum implementation of the
value.
@Rinsen
Copy link
Owner

Rinsen commented Dec 9, 2015

Good work!
I will hopefully have time to test this later today, I am really excited to see all of this run on the hardware and test it out! :)

I have tried to do some tests in the emulator but can´t make it load any programs main method in Windows 10 with VS2015 for some reason that I don´t understand...

I moved the function GetMoreBytes to an extension method instead of in
the SDCardMagager Class
Implemented ContentType Enums, ContentSubtype enums. Fixed issues with
my SDCard class needing to be static and moved extension methods all
into one File on Rinsen.WebServer
@JakeLardinois
Copy link
Author

 Ahh yes good ole "Upgrades"!  I still haven't done the Windows 10 install because I don't want to keep getting stuck on little things like that.  My rig is working very well right now, but I know I'll have to bit the bullet sooner than later...
I added some more fixes including the use of enums for ContentType and ContentSubType.  I Created a class that would hold the two ContentType enums so that I could override the ToString() method and have it properly output to the headers.  I also fixed an issue with my SDCard class in Rinsen.FileServer where it needed to be an instance method in order to be continually accessed.  I started work on binary file uploads and would like to finish them up soon, but my Job is starting to get in the way :)

@Rinsen
Copy link
Owner

Rinsen commented Dec 10, 2015

New versions can for sure be a pain :) I had to install VS2013 yesterday because I cant get it to run in 2015... But that will hopefully solve my issues so I can try to run some code :)

And yes, time is always a big issue :)

Ajax post Data is now written to file with no gaps in data.
Files are now saved to the SDCard as Byte Arrays which allows for
Uploads of any file type.
I had an issue where the the boundary data was not removed in files that
could be read within the first pass of the buffer.
@JakeLardinois
Copy link
Author

Implemented Binary File upload. All files that get uploaded are now written to the SD Card as Byte Arrays; this allows the uploading of files that couldn't be decoded with UTF8. It is slow and I had to kind of brute force the thing, but it works rather reliably and should also be able to handle multiple file uploads as well... The code could use some refining and I should divert any text Content Types to instead use the faster UTF8 method, but those will be future tasks :)
Oh yeah! Also it collects any other html elements that are posted and places their post values in a FormCollection object for use after the files have been uploaded.

@JakeLardinois
Copy link
Author

Fredrik, I spoke too soon, cause it was unreliable when I switched to files that are loaded in multiple passes :) So I just put a fix in place.
I do notice that when the files are being uploaded that no other web requests can be processed. Also, I'm guessing that one of the major bottlenecks during the file upload is the ReceiveUntil() extension method doing byte comparison until it gets a match... I mean, it takes a good 15-20 minutes to upload an 90kb picture... I don't know when I'll get a chance to work on some more of these... I've got to get started on a project for work... Total Bummer!

@JakeLardinois
Copy link
Author

What do you think of these? Would you prefer me to clean out my fork and then just pull incremental changes into it so that you can test before committing?

@Rinsen
Copy link
Owner

Rinsen commented Dec 15, 2015

I will probably have some hours to spend on this tomorrow so I will get back to you after that :)

A busy time both at work and at home now before Christmas :)

@JakeLardinois
Copy link
Author

It's a shame how work always has to get in the way of fun :)
Just don't be shy in asking if you need me to do something or do something different. I'm happy to be able to contribute.
BTW - Merry X-mas!

  --Jake

@Rinsen
Copy link
Owner

Rinsen commented May 19, 2016

Hi!

I have slooowly been looking into this and its a lot of good things 👍

I have one thing that I can´t include because it will break existing code for me and others. It´s the change from strings to enums in response types and I personally don´t like like having external constants as build in enums, but I still like the idea of having nice compiler support when writing code that I guess you are after here :)
But if it is okay with you I will pull all the other things and leave these out? I could maybe see if it is possible to add them as extension methods in some way.

And I should have asked you in the beginning to give me a few smaller pull request instead of this huge one to make it easier to follow all the changes :)

And it really makes me sad to see such an awesome thing as the Netduino product/community slowly dying :/

@JakeLardinois
Copy link
Author

Hey Fredrik! Thanks for the kind words; take what you feel would be good to incorporate and leave the rest. That is fine.
Yeah the netduino is a cool little device, but I guess it is being surpassed by Arduino and/or Pi... But that's technology, "cool one day, old news the next"!
Sorry it took so long for me to respond, but I started a new job and haven't been really active on side projects... But, yeah, I probably should've done a better job sending out pull requests. The one thing that I didn't have time to optimize was how it needs to keep checking the bytes for the Request.Boundary (inside the FileController) in order to know when to stop writing the bytes to file... It's a real performance killer!
You can close this request whenever your ready, or just let me know and I will.
BTW - You really did some great work on this project!! Good Job 👍

@Rinsen
Copy link
Owner

Rinsen commented Aug 6, 2016

Hi!

I am not that fast either and my Netduino have run its last code since I fried it, so not much more will happen here. And of course it is always nice to get new toys and the Pi is really really nice!

The only sad thing is that the end was so fast and because of a failed project..

Ant thanks for that feedback! Its really fun and gives a lot of motivation to see things I have done come to life and use in projects that I don´t own! :)

@JakeLardinois
Copy link
Author

Fredrik,
It's been a long time! But I recently received an email from Wilderness Labs and thought of you. They appear to have acquired Netduino and picked up working with the .Net Micro Framework. It looks like this tech is getting some new life breathed into it; I thought you'd find it interesting :).

Regards,
Jake

@Rinsen
Copy link
Owner

Rinsen commented Nov 7, 2018

Hi!
Time flies by for sure, I feel that the technology in Netduino is way to old to be a fun platform today. But Wilderness labs have an interesting project on kickstarer that I will keep an eye on!

https://www.hanselman.com/blog/NETCoreAndNETStandardForIoTThePotentialOfTheMeadowKickstarter.aspx

Let's hope it goes way better that the agent smart watch...!

/Fredrik

@JakeLardinois
Copy link
Author

LOL Totally!
Yeah, I saw that pop up on Kickstarter and pledged the $50 so I could get my hands on one of those. I also bought up the Cart Scale parts from the employer at my last job. In my "free" time I was thinking I'd port the code over and get it running on the Meadow Board :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants