#!/usr/bin/env python2 # # DO NOT HAND_HACK! THIS FILE IS GENERATED # This code is generated by scons. Do not hand-hack it! # # This is the CGI that processes the form return from GPS information form. # # The wackiness with output_sample_com happens because the user has to click # through twice - once to review and once to submit. Thus the content has # to be embedded as a hidden field - and base64-armored, because it might # otherwise have stuff in it that isn't legal in HTML attribute values. # import sys, os, smtplib, base64 from email.mime.text import MIMEText from email.mime.multipart import MIMEMultipart from email.encoders import encode_base64 import cgi import cgitb; cgitb.enable() # for troubleshooting # All information on the project siting, mailing # lists, and originating host lives here. website = 'https://gpsd.io/' to_address = 'gpsd-dev@lists.nongnu.org' servaddr = 'www@thyrsus.com' # Get form value, send mail on submission form = cgi.FieldStorage() print "Content-type: text/html" print "" if form.has_key('output_sample_content'): output_sample_content = base64.b64decode(form.getvalue('output_sample_content')) else: output_sample_content = '' if not output_sample_content and form.has_key('output_sample_file'): fileitem = form['output_sample_file'] if fileitem.filename: output_sample_content = fileitem.file.read() def hasRequiredElements(form): for fld in ("submitter", "vendor", "model", "techdoc"): if not form.getvalue(fld): return False return not not output_sample_content formfields = ("submitter", "vendor", "model", "techdoc", "packaging", "chipset", "firmware", "nmea", "interfaces", "usbchip", "tested", "rating", "configurable", "output_sample_file", "output_sample_content", "location", "date", "sample_notes", ) if hasRequiredElements(form) and form.getvalue("action") == "Send Report": report = MIMEMultipart() report['Subject'] = 'New device report' report['To'] = to_address report.preamble = "Part 1 is form data, part 2 is the sample" # Render the form data as an entry for gpscap.ini msg = "[%s]\n" % form.getvalue('model').strip() for field in formfields: if form.getvalue(field) and not field == 'model' and not field.startswith('output_sample'): msg += "%s: %s\n" % (field, form.getvalue(field)) report.attach(MIMEText(msg)) # Decorate the log data with some canned headers. # Omitted: nmea, notes, techdoc, tested, usbchip, configurable, header = '' header += "# Name: %s %s\n" \ % (form.getvalue('vendor'), form.getvalue('model')) for fld in ("chipset", "firmware", 'date', 'submitter', 'location'): if form.has_key(fld) and form.getvalue(fld): header += "# %s = %s\n" % (fld.capitalize(), form.getvalue(fld)) if form.has_key('sample_notes') and form.getvalue('sample_notes'): header += "# Notes: %s\n" % form.getvalue('sample_notes') header += "type = device\n" content = MIMEText(header + output_sample_content) encode_base64(content) report.attach(content) # Ship it. msg = report.as_string() smtp = smtplib.SMTP("localhost") #smtp.set_debuglevel(1) try: smtp.sendmail(servaddr, [to_address], msg) smtp.quit() print "

New device report accepted.

\n" print "

Your report on the %s %s was successfully recorded. Thanks for helping improve GPSD.\n" \ % (form.getvalue('vendor'), form.getvalue('model')) except smtplib.SMTPSenderRefused, e: print "

Your submission failed.

\n" print "

The error code was %s: %s

" % (e.code, e.response) sys.exit(0) # Everything below here is page generation defaults = {} for key in formfields: if key in form.keys(): defaults[key] = form.getvalue(key).strip() else: defaults[key] = "" defaults['request_uri'] = os.getenv('REQUEST_URI') defaults["website"] = website defaults["to_address"] = to_address defaults["servaddr"] = servaddr defaults['output_sample_content'] = output_sample_content defaults['armored_sample_content'] = base64.b64encode(output_sample_content) print '''\

GPSD Receiver Reporting Form

Please use this form to report gpsd successes or failures with GPS and AIS units, and also to upload a sample of the receiver\'s output so we can add it to our regression tests and ensure continued support of the device.

Information gathered so far:

''' if form.getvalue("vendor"): print "Vendor is "+cgi.escape(form.getvalue("vendor"))+"
\n"; else: print "No vendor.
\n"; if form.getvalue("model"): print "Model is "+cgi.escape(form.getvalue("model"))+"
\n"; else: print "No model specified.
\n"; if form.getvalue("techdoc"): print "Document URL specified.
\n"; else: print "No document URL.
\n"; if output_sample_content: print "Output sample uploaded"; else: print "No output sample.
\n"; if form.getvalue("submitter"): print "Contact address is "+cgi.escape(form.getvalue("submitter"))+"
\n"; else: print "No contact address.
\n"; print "
"; if form.getvalue("packaging"): print "Packaging type is "+cgi.escape(form.getvalue("packaging"))+"
\n"; else: print "No packaging type specified.
\n"; if form.getvalue("chipset"): print "Chipset is "+cgi.escape(form.getvalue("chipset"))+"
\n"; else: print "Chipset not specified.
\n"; if form.getvalue("firmware"): print "Firmware is "+cgi.escape(form.getvalue("firmware"))+"
\n"; else: print "Firmware not specified.
\n"; if form.getvalue("nmea"): print "NMEA version is "+cgi.escape(form.getvalue("nmea"))+"
\n"; else: print "NMEA version not specified.
\n"; if form.getvalue("interfaces"): print "Interface type is "+cgi.escape(form.getvalue("interfaces"))+"
\n"; if form.getvalue("interfaces") == "USB": if form.getvalue("usbchip"): print "USB chip is "+cgi.escape(form.getvalue("usbchip"))+"
\n"; else: print "No USB chip specified.
\n"; else: print "No interface type specified.
\n"; if form.getvalue("tested"): print "Tested with GPSD version "+cgi.escape(form.getvalue("tested"))+"
\n"; else: print "No GPSD version specified.
\n"; print "
"; if form.getvalue("rating"): print "GPSD compatibility is "+cgi.escape(form.getvalue("rating"))+"
\n"; else: print "No GPSD compatibility specified.
\n"; if form.getvalue("noconfigure") == 'yes': print "Device can be sent catatonic by baud-rate changes.
\n"; elif form.getvalue("noconfigure") == 'no': print "Device handles baud-rate changes correctly.
\n"; else: print "How baud-rate changes are handled is unspecified.
\n"; if form.getvalue("notes"): print "Technical notes have been entered.
\n"; else: print "No technical notes.
\n"; if form.getvalue("location"): print "Sample location "+cgi.escape(form.getvalue("location"))+"
\n"; else: print "No sample location specified.
\n"; if form.getvalue("date"): print "Sample date "+cgi.escape(form.getvalue("date"))+"
\n"; else: print "No sample date specified.
\n"; if form.getvalue("sample_notes"): print "Notes on the sample have been entered.
\n"; else: print "No notes on the sample.
\n"; print "
"; if hasRequiredElements(form): print '

The report is ready to be submitted.

' else: print '

Required fields are missing; please fill them in.

' print '''

Fields marked Important! have to be filled in for the report to be useful. These are: submitter contact address, vendor, model, documentation URL, and output sample. Other fields represent things we might be able to find out ourselves, but which are easier for you to determine. Every bit of information you can give us about your receiver will help make the support for it more reliable.


Receiver type identification

Important! Identify the vendor and model of your device.

Example: Haicom and 303S.

Vendor: 

Model:  

Important! We need a URL pointing to a technical manual for the device. You can usually find this on the vendor\'s website by giving a search engine the product name. If it\'s not linked directly from the vendor\'s page for the individual product, look under "Technical Support" or "Product support" on the vendor\'s main page.

Example: http://www.haicom.com.tw/gps303s.shtml

URL of a technical manual:

It is useful to have an indication of how the receiver is packaged.

Packaging:

''' % defaults packagetypes = ( ('mouse', 'A "mouse" is a standalone sensor in a display-less case ' 'designed to be used as a peripheral cabled to a computer.'), ('dongle', 'A "dongle" is a standalone sensor in a display-less case ' 'resembling a thumb drive intended to be plugged directly ' 'into a USB port.'), ('handset', 'A "handset" is a standalone unit with a display and ' 'human-usable controls.'), ('handsfree', 'A "handsfree" is a hands-free unit with display designed ' 'for mounting on a car windshield or boat console.'), ('survey', 'A "survey" unit is packaged for field-survey use.'), ('OEM module','An "OEM module" is an un-cased circuit board with edge ' 'connectors.'), ('chipset', 'A "chipset" is a bare chip or chips packaged for surface ' 'mount.'), ('other', 'None of the above'), ) for (ptype, plegend) in packagetypes: print '%s
' % (ptype, plegend) print '''

Please identify the device chipset and firmware version, if possible. You may be able to get this from the display of xgps; look for a Device Type field or at the window title bar. Alternatively, you may find it in the technical manual.

Example: SiRF-II and 2.31ES.

Chipset:  

Firmware: 

Please identify, if possible, the NMEA version the receiver emits. You may be able to get this information from the technical manual. Likely values are 2.0, 2.2, 2.3, 3.0, and 2000 for NMEA2000 devices. If the GPS emits only a vendor binary protocol, leave this field blank.

NMEA version emitted: 


Interfaces

Please identify the receiver\'s interface type (USB, RS-232, Bluetooth, Compact Flash, CAN bus, etc.). If the receiver has adapters that support other interfaces, tell us the one you have and mention the adapters in the "Technical Notes" box. If it has an exotic interface not listed here, select "Other" and tell us about it in "Technical Notes".

''' % defaults ifline = '%s' print "" for itype in ('USB', 'Bluetooth', 'Compact Flash', 'RS-232', 'TTL', 'CAN', 'Other'): print ifline % (itype, itype) print "
" print '''

If your device is USB, it probably uses a USB-to-serial adapter chip. Try to find out what this is by looking at the output of lsusb(1).

''' cline = '%s' print "" for ctype in ('PL2303', 'UC-232A', 'FTDI', 'Cypress M8', 'CP210x', 'Other'): print cline % (ctype, ctype) print "
" print '''

GPSD compatibility

Please tell us what version you tested with. If you used a published release, give us the full release number, like 3.5. If you built your code from our development repository, please give the revision ID.

GPSD version: 

Please rate how well this receiver functions with GPSD:

''' % defaults ratings = ( ("excellent", "Excellent -- gpsd recognizes the receiver rapidly and reliably, reports are complete and correct."), ("good", "Good -- gpsd has minor problems or lag recognizing the device, but reports are complete and correct."), ("fair", "Fair -- Reports have minor dropouts or problems, including occasional transient nonsense values."), ("poor", "Poor -- Reports frequently have values that are wrong or nonsense."), ("broken", "Broken -- gpsd frequently, or always, fails to recognize the device at all."), ("other", "Other -- See Technical Notes."), ) rateline = '%s
' for (rtype, rlegend) in ratings: if defaults['packaging'] == rtype: print rateline % (rtype, " checked", rlegend) else: print rateline % (rtype, "", rlegend) print '

Device sanity when probed or speed-switched:
' sanity = (('sane', 'Sane: accepts baud-rate changes and probes.'), ('insane', 'Insane: goes catatonic on baud-rate changes and probes.')) saneline = '%s
' for (stype, slegend) in sanity: if defaults['configurable'] == stype: print saneline % (stype, " checked", slegend) else: print saneline % (stype, "", slegend) print '''


Technical notes

Now tell us the things that didn\'t fit in the rest of the form. Appropriate things to put here include how to read any LEDs or other unlabeled indicators on the device, a warning that the product has been discontinued, a list of alternate interfaces, descriptions of errors in the documentation, descriptions of special abilities such as the ability to vary the sampling interval, and a note if it\'s an OEM module rather than a retail product. Anything else you think we need to know should go here too.


Output sample

Important! We need a sample of the output from your receiver - not the gpsd logfile, just raw output. We\'ll use this for mechanical regression testing, which is your best guarantee that support for your device won\'t get broken in a future release. Please be advised that these logs will be sent to a publicly archived mailing list, and will be available in the public code repository.

Almost all receivers will simply start throwing data to your port immediately when they\'re plugged in. You should normally be able to capture this output to a file with the gpscat utility.

There will be some unusual cases in which this isn\'t possible, because the device needs some kind of activation sequence written to it before it will start reporting. Some Garmin GPSes (the ones that speak Garmin binary protocol rather than NMEA) are like this. If you think you have one of these, ask for help on GPSD\'s development mailing list.

A log file is most useful when it contains (a) some sentences generated when the receiver has no fix, (b) some sentences representing a fix with the unit stationary, and (c) some sentences representing a fix with the unit moving.

There is some auxiliary data we like to have in our regression-test files.

Location of the log capture. A good format would include your nearest city or other landmark, state/province, country code, and a rough latitude/longitude. A GPS will give an exact location; we want this as a sanity check.

Example: Groningen, NL, 53.2N 6.6E

Location: 

Year-Month-Day of the log capture (the receiver will give us hour/minute/second).

Example: 2011-05-14.

Date: 

Finally, add any notes you want to about how the sample was taken. One good thing to put here would a description of how the unit was moving while the log was being captured. If the sentence mix changes between "fix" and "no fix" states, that too is a good thing to note.


Contact information

Important! We need a valid email address for you in case we need to ask you followup questions about the device. While we won\'t use your address for anything other than asking you questions about your receiver, and maybe asking you to test specific changes, this device report will be sent to the gpsd-dev list which is publicly archived.

Example: Eric Raymond <esr@thyrsus.com>

Name and email address:

(It is not actually very likely we will contact you, but we need to be able to do it if we can find no other way of getting information about the device. Expect to hear from us if your receiver is obsolescent or exotic and the information you provide in the rest of this form turns out to be insufficient. Or if your browser is broken enough to botch the output-sample upload.)


''' % defaults print "

To see what you have entered so far, click Review\n"; # Must have all critical fields to ship if hasRequiredElements(form): print '''

Click the Send Report button to send your report to the GPSD developers. Eventually, your report is likely to appear on our Hardware page.

Reset Form
''' % defaults else: print '''

Required fields are missing; please fill them in.

Reset Form
''' % defaults print '''
''' # The following sets edit modes for GNU EMACS # Local Variables: # mode: python # fill-column:79 # End: