When I do the following:
s= serial.Serial('/dev/',9600)
# or set a function and pass via command line
s= serial.Serial(arg1,9600)
The code executes without any error.
But, when I use AJAX and POST the parameters to the script
def index(req):
info = req.form
sys.stderr = sys.stdout
s= serial.Serial(info['device'],9600)
An error occurs:
Traceback (most recent call last):
File "/usr/lib/python2.6/dist-packages/mod_python/importer.py", line 1537, in HandlerDispatch
default=default_handler, arg=req, silent=hlist.silent)File "/usr/lib/python2.6/dist-packages/mod_python/importer.py", line 1229, in _process_target
result = _execute_target(config, req, object, arg)File "/usr/lib/python2.6/dist-packages/mod_python/importer.py", line 1128, in _execute_target
result = object(arg)File "/usr/lib/python2.6/dist-packages/mod_python/publisher.py", line 213, in handler
published = publish_object(req, object)File "/usr/lib/python2.6/dist-packages/mod_python/publisher.py", line 425, in publish_object
return publish_object(req,util.apply_fs_data(object, req.form, req=req))File "/usr/lib/python2.6/dist-packages/mod_python/util.py", line 554, in apply_fs_data
return object(**args)File "/var/www/md-result/libs/system/usb-mobile/balance.py", line 23, in index
s= serial.Serial(info,9600),File "/usr/lib/python2.6/dist-packages/serial/serialutil.py", line 154, in __init__
self.port = portFile "/usr/lib/python2.6/dist-packages/serial/serialutil.py", line 201, in setPort
self.portstr = self.makeDeviceName(port)File "/usr/lib/python2.6/dist-packages/serial/serialposix.py", line 297, in makeDeviceName
return device(port)File "/usr/lib/python2.6/dist-packages/serial/serialposix.py", line 34, in device
return '/dev/ttyS%d' % portTypeError: %d format: a number is required, not StringField
I have no idea why it is doing this, I checked the POST parameters passed by printing them and they are coming through.
Any suggestions would be greatly appreciated.
Thanks,
Spogs