×

Discussion Board

Results 1 to 2 of 2
  1. #1
    Registered User
    Join Date
    Jan 2010
    Posts
    1

    TypeError in AJAX POST passed to PySerial

    When I do the following:
    Code:
        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
    Code:
    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['device'],9600),

    File "/usr/lib/python2.6/dist-packages/serial/serialutil.py", line 154, in __init__
    self.port = port

    File "/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' % port

    TypeError: %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

  2. #2
    Super Contributor
    Join Date
    Nov 2007
    Location
    Sertaozinho/Brazil
    Posts
    768

    Re: TypeError in AJAX POST passed to PySerial

    Hi Spog,

    I think you sent a message to the wrong forum, this forum is related to python for S60 devices

    BUT, the error is clear:

    Code:
    return '/dev/ttyS%d' % port
    TypeError: %d format: a number is required, not StringField
    Port has been used as string and it must be a number, see the %d at first line. Please, check your code and how you set the serial port number.

Similar Threads

  1. Replies: 1
    Last Post: 2009-04-20, 17:54
  2. HTTP POST using Nokia 7650
    By mikael_kinnunen in forum Mobile Java Networking & Messaging & Security
    Replies: 8
    Last Post: 2008-08-19, 23:32
  3. Problems with http - POST
    By bigbadwolf in forum Symbian Networking & Messaging (Closed)
    Replies: 13
    Last Post: 2007-01-17, 23:45
  4. Problem with HTTP POST
    By thathoo in forum Mobile Java General
    Replies: 2
    Last Post: 2006-12-18, 18:23

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
×