-
Notifications
You must be signed in to change notification settings - Fork 2
Description
The vsd script is a great addition to ADTPro. However opening a Telnet session might not be the most straight forward thing to do in every scenario. Therefore I created a simplistic web front-end for vsd. I see two primary usage scenarios:
- Upload a new disk image from a PC to the 'disks' directory using SMB and then use a web browser on that PC to mount it right away as virtual disk.
- Sort of "replace" the second serial connection between the A2 and the RPi with an Ethernet connection: Use an A2 Ethernet card (LANceGS, Uthernet, Uthernet II) and the Contiki web browser to mount a different disk image as virtual disk from the A2. Below there's a screenshot showing how the Contiki web browser renders the web front-end for vsd.
The web front-end makes use of the web server capabilities built into the standard Python libraries. So it doesn't depend on any additional installation:
#!/usr/bin/python
import BaseHTTPServer, subprocess, urlparse
class Handler(BaseHTTPServer.BaseHTTPRequestHandler):
def do_GET(self):
url = urlparse.urlsplit(self.path)
if url.path != '/':
self.send_error(404)
return
if url.query:
query = dict(urlparse.parse_qsl(url.query))
if 'vsd1' in query:
subprocess.call(['vsd', '-1', query['vsd1']])
if 'vsd2' in query:
subprocess.call(['vsd', '-2', query['vsd2']])
try:
vsd1 = subprocess.check_output(['vsd', '-1'])[17:-1]
vsd2 = subprocess.check_output(['vsd', '-2'])[17:-1]
except subprocess.CalledProcessError:
vsd1 = ""
vsd2 = ""
self.send_response(200)
self.send_header('Content-type', 'text/html')
self.end_headers()
self.wfile.write('<html>\n')
self.wfile.write(' <head>\n')
self.wfile.write(' <title>A2CLOUD</title>\n')
self.wfile.write(' <meta name="viewport" content="width=device-width, initial-scale=1">\n')
self.wfile.write(' </head>\n')
self.wfile.write(' <body style="font-family:sans-serif;">\n')
self.wfile.write(' <h2>A2CLOUD</h2>\n')
self.wfile.write(' <form action="/"><p>Drive 1\n')
self.wfile.write(' <input type="text" name="vsd1" value="' + vsd1 + '" size="60" maxlength="120">\n')
self.wfile.write(' <input type="submit" name="s" value="Mount">\n')
self.wfile.write(' </form>\n')
self.wfile.write(' <form action="/"><p>Drive 2\n')
self.wfile.write(' <input type="text" name="vsd2" value="' + vsd2 + '" size="60" maxlength="120">\n')
self.wfile.write(' <input type="submit" name="s" value="Mount">\n')
self.wfile.write(' </form>\n')
self.wfile.write(' </body>\n')
self.wfile.write('</html>')
httpd = BaseHTTPServer.HTTPServer(('', 80), Handler)
httpd.serve_forever()Beside using the HTML form it is as well possible to mount a disk image by specifying it right in the URL like http://<ip addr of Raspple II/?vsd1=<disk image name to mount in drive 1> which allows for further scenarios.
The web front-end can be started together with the ADTPro server by saving it as /usr/local/bin/webvsd.py, making it executable and adding it to adtpro-start right after the call to adtpro.sh as sudo nohup webvsd.py &> /dev/null &.
