I've seen wifi routers host html webpages over ethernet cables. This eliminates the need for a PC app/software and the device can be configured using a PC web browser. I want to do something similar, but NOT using ethernet. I'm using Nuvoton NANO120LE3BN which has USB device. Is it possible to host a html webpage when the M0-cortex is connected to a PC/MAC as a USB device. Does Keil have a stack for doing this? If we do this do we need a driver on the PC ( Windoews 7/8 or MAC OSX)?
Your web browser cares about retrieving web pages from a networked server - you enter a host name when you specify the URL in the browser. If the web browser instead gets a file name, then it can show a HTML page from a disk, but a disk file is static - you need to interface with a web server to get dynamic content. In the end, the concept of the World Wide Web is all about networking.
It's possible to have a USB-connected device show up as a networked device, since it's possible to have USB-connected network cards, WiFi routers etc. But it isn't simple. It's easier to have your device show up as a HID or serial port and to ship a Windows application that hosts a local web server and retrieves the page content from the USB-connected device.
not necessarily...
If you point your browser at an HTML file on your disk, then edit the file with a separate application, save it, then "refresh" the page in the browser - you will see the changed content!
You can code the HTML to have the browser automatically refresh: www.htmlcodetutorial.com/.../index_tagsupp_4.html
There may be some issues with OS caching and file locking, though...
It's all a question of the definition of static/dynamic.
Constant reload of a file is regularly used to pick up the latest log lines from a running program, or to re-display the contents of a state file.
But it doesn't send information to the server, so the file doesn't get updated with dynamic content based on the client (unless that state file shows number of bytes sent out by the file server). So the file content retrieved isn't really dynamically produced based on user actions.
The closest you could get would be to have the web browser retrieve sequences of different file names, and have the file server understand the names served and take the file names as commands to regenerate files based on the sequence of files retrieved. But it would suffer quite a long list of severe disadvantages.
In the end, dynamic information - instead of just page reloads - makes use of two-way interaction.
I wanted to make this process simple. Instead of the user editing the HTML file. We can place a Save Config button on the page. So this is what I find we can do: 1) User plugs in the device. A Drive(mass storage) shows up with an html page inside. User opens the page. 2) The user can edit few config parameters, if he/she wants to. 3) User presses the "save config" button. This saves a config file in the Downloads folder. 4) User drags this config file into the Drive(mass storage).
I have following questions: A) Will above method work? Can we send data to the device by dragging a config file into it? B) Do we require Mac or Windows specific code for this? C) Considering we have 128k flash (16k SRAM), would the boilerplating (Win and Mac installers) code, FAT file system, USB mass storage class and HTML page fit in and run well? D) How can we use Keil to help us with this? Does Keil provide any stacks for this?
Ethernet over USB (Gadget)
blackfin.uclinux.org/doku.php:usb-gadget:ethernet
The USB peripheral will enumerate to the host as an Ethernet device, using the "usbnet" driver with Linux hosts or Microsoft's RNDIS driver with Windows hosts. Set it up like any other two-host Ethernet link; bridging it to the LAN from the USB host may be the easiest way to run. Linux hosts do this with CONFIG_BRIDGE and tools like “brctl”. Windows XP hosts have a GUI for bridging; it comes up when the RNDIS driver creates a second network link.
Search result of 'ethernet over usb stm32'
my.st.com/.../Flat.aspx
When Per Westermark said "But it isn't simple. It's easier to have your device show up as a HID or serial port and to ship a Windows application that hosts a local web server and retrieves the page content from the USB-connected device.", I chucked out the web server approach.
I'd like to go with the USB mass storage approach described in my previous post. Please comment on it. I'd a few questions regarding it which I've asked in my previous post. Need your valuable f/b on those.
> I'd like to go with the USB mass storage approach described in my previous post.
Mass Storage class (MSC) approach also suffers pains around browser/OS differences. The JavaScript, running on the browser, can read a local setting file from the MSC drive (HTML5 FileReader API), but there is limitation when the script writes back the edited data to a file (HTML5 WriteFile API).
a) currently FileWriter API is supported on limited browsers. status.modern.ie/filewriter b) FileWriter can’t directly write back to the MSC drive, it can write just to "sandbox" folder (such as download folder).
Another problem of MSC approach is, the device can’t know exact timing when the file is updated. Writing to a FAT file system involves - write to file sectors - update of Directory - update of FAT All of above actions appear as WRITE10 SCSI command to the device, in unpredictable order. Additional "Eject" action by user may notify to the MSC device, over SCSI START/STOP command.
> Communication to USB device with PC web browser.
As discussed above, a web (HTML) and DHCP server on a virtual net over USB RNDIS is a popular solution, which gives better user experience. - Since XP SP3, Windows support RNDIS without any additional "driver (INF file)" installation, when your USB device gives MS OS descriptor for RNDIS. msdn.microsoft.com/.../gg463179.aspx - MacOSX requires RNDIS driver http://joshuawise.com/horndis
Another approaches found in this field are, - Browser plug-in, helper ActiveX (OCX) or JAVA applet - Local web server on the PC, which communicates with the USB device.
These methods are fine, when you restrict target browser/OS.
Tsuneo