×

Discussion Board

Results 1 to 5 of 5
  1. #1
    Registered User
    Join Date
    Sep 2005
    Posts
    30

    Thumbs up [announce] Sync & run made easy

    Software you'll need:


    Once you have installed the above things do the following (respecting the order!)
    • install the tcs60fs.sis on your phone
    • extract tcp_serial_redirect.py from pyserial-2.2.zip and run it with the following params (note: substitute com5 with your bt virtual port)
      c:/>tcp_serial_redirect.py -p com5 -b 115200
    • run tcs60fs on your phone and connect to the computer
      (don't forget to run first the tcp_serial_redirect.py and don't close it)


    Using control.py:
    • PUT files to the phone:
      usage: control.py -p <local_file_with_path> <phone_filename_and_filename>
    • GET files from the phone:
      usage: control.py -g <phone_filename_with_path> <local_file_with_path>
    • EVAL expressions on the phone
      usage: control.py -e "<expression>"
    • EXECFILE files on the phone:
      usage: control.py -xf <phone_path_with_executable_filename>
    • EXEC commands on the phone
      usage: control.py -x "<command> "


    Samples:
    control.py -p c:/my_prog.py c:/test.py
    control.py -e "print 'hello'"
    control.py -xf c:/test.py
    control.py -x "print 'hello world'\n"
    control.py -g 'c:/test.py' pcfile.py

    note that the possibilities are infinite since you can execute script code on the phone
    That is all!

    BTW, Now you can use this as a tool in your favourite editor and just donwload and execute your prog by just pressing a you favourite key

    I hope you like it! let me know if you use it!

    Code:
    #control.py source code
    
    import os
    import socket
    import sys, getopt
    import StringIO
    import shutil
    import binascii
    
    def xsend(cmd,data):	
        import binascii
        s.send(  cmd +'\n')
        if data:
            print "sending data"
            s.send('Content-Length: '+str(len(data))+'\n'+'CRC32: '+str(binascii.crc32(data))+'\n')
            s.send(data)
    
    def readline():
        d=[]
        while 1:
            c=s.recv(1)
            d.append(c)
            # We support just sane line-endings here.
            if c=='\n':
                break
        return ''.join(d)
    
    def recvdata():
        print "Waiting for data..."
        header_lines=[readline() for x in range(2)]
        header=dict([x.rstrip().split(': ') for x in header_lines])
        content_length=int(header['Content-Length'])
        crc32=int(header['CRC32'])
        print("Content-Length: %d"%content_length)
        recvbytes=0
        content=[]
        print "Receiving data..."
        while recvbytes<content_length:
            recvstring=s.recv(min(content_length-recvbytes,2048))
            recvbytes+=len(recvstring)
            print "Received: %d bytes (%3.1f%%)\r"%(recvbytes,(100.*recvbytes/content_length)),
            content.append(recvstring)
        print "Received %d bytes."%recvbytes
        content=''.join(content)
        if crc32 != binascii.crc32(content):
            print "*** CRC error!"
        return content
    
    def PrintResult():
        res = eval(recvdata())
        print '-----------begin-----------'
        print "%i Errors" % res[0]
        if res[0]>0:
            t = res[1]
            for i in t:
                print ">",i,
        print '------------end------------'
    
    
    HOST = 'localhost'    # The remote host
    PORT = 7777              # The same port as used by the server
    s = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
    s.connect((HOST, PORT))
    
    print "control.py by Raul Aguaviva"
    
    args = sys.argv[1:]
    
    
    if args[0] == '-p':
        print 'put!!!!!!!!'
        try:
            f=open(args[1],'rb')
            datos = f.read()
            f.close()      
            xsend ("put " + args[2],datos)
        except:
            print "can't find file:", args[1]
    elif args[0] == '-g':
        print 'get!!!!!!!!'
        xsend ("get "+ args[1],0)
        try:
            datos = recvdata()
            f=open(args[2],'wb')
            f.write(datos)
            f.close()      
        except:
            print "can't find file:", args[1]
    elif args[0] == '-e':
        print 'eval!!!!!!!!'
        xsend ("eval", repr(args[1]))
        PrintResult()
    elif args[0] == '-x':
        t = args;
        t.pop(0)
        xx = ' '.join(t)
        print 'exec!!!!!!!!'
        xsend ("exec", repr(xx))
        PrintResult()
    elif args[0] == '-xf':
        t = args;
        t.pop(0)
        xx = ' '.join(t)
        print 'execfile!!!!!!!!'
        #cmd = "try:\n    execfile('"+xx+"',globals())\nexcept:\n    print 'error'\n"
        cmd = "execfile('"+xx+"',globals())"
        xsend ("exec", repr(cmd))  #  "execfile('caca',globals())"
        PrintResult()
    else:
        print "command " + args[0] + "not found" 
    
    s.close()
    Last edited by xchip; 2006-05-29 at 21:35. Reason: adding cyke64 comments

  2. #2
    Registered User
    Join Date
    Feb 2005
    Location
    Belgium (Europe)
    Posts
    1,352

    Re: [announce] Sync & run made easy

    Quote Originally Posted by xchip
    Software you'll need:

    You have forgotten for Windows (pywin32 !)
    http://sourceforge.net/project/showf...ease_id=403008

    Quote Originally Posted by xchip
    Once you have installed the above things do the following (respecting the order!)
    • install the tcs60fs.sis on your phone
    • extract tcp_serial_redirect.py from pyserial-2.2.zip and run it with the following params (note: substitute com5 with your bt virtual port)
      c:/>extract tcp_serial_redirect.py -p com5 -b 115200
    • Read as c:/>tcp_serial_redirect.py -p com5 -b 115200

      Quote Originally Posted by xchip
    • run tcs60fs on your phone and connect to the computer
      (don't forget to run first the tcp_serial_redirect.py)
  3. Quote Originally Posted by xchip

    Using control.py:
    • uploading files to the phone:
      usage: control.py -p <localfile_with_path> <phone_path_and_filename>
      example: control.py -p c:/my_prog.py c:/test.py
    • executing files on the phone:
      usage: control.py -xf <phone_path_with_executable_filename>
      example: c:/>control.py -xf c:/test.py
    • executing commands on the phone
      usage: control.py -x "<command> "
      example: c:/>control.py -x "print 'hellow world'\n"
    Could you send another option ?
    downloading files to the phone:
    usage: control.py -p <phone_path_and_filename> <localfile_with_path>
    example: control.py -d e:/test.py c:/my_prog.py

    It's mandatory to use two command line windows for use control.py ? (the other was tcp_redirect_serial !)

    You have forgotten your -e (eval ) !
    Quote Originally Posted by xchip
    BTW, Now you can use this as a tool in your favourite editor and just donwload and execute your prog by just pressing a key

    I hope you like it! let me know if you use it!

    Thanks to you ! Now we have many choices (PUTOOLS , BT console etc .) I try your app and it works !
Last edited by cyke64; 2006-05-29 at 19:10. Reason: suggestion : downloading file
pys60 1.4.5 and 2.0.0, pygame, PyS60 CE on E90 and 5800 !

Find my pys60 extension modules on cyke64.googlepages.com
Reply With Quote Reply With Quote

  • #3
    Registered User
    Join Date
    Sep 2005
    Posts
    30

    Re: [announce] Sync & run made easy

    Quote Originally Posted by cyke64
    You have forgotten for Windows (pywin32 !)
    http://sourceforge.net/project/showf...ease_id=403008

    [.....]

    Thanks to you ! Now we have many choices (PUTOOLS , BT console etc .) I try your app and it works !
    Hey cyke64,

    Thanks for your comments, I updated the original post with all your suggestions.

    Thanks!

  • #4
    Registered User
    Join Date
    Feb 2005
    Location
    Belgium (Europe)
    Posts
    1,352

    Re: [announce] Sync & run made easy

    Hey Raul ,

    Same remarks for this app too :-)

    http://aguaviva.googlepages.com/s60pythondevelopment
    http://aguaviva.googlepages.com/control.zip

    I notice an error on your site

    # GET files to the phone:

    * usage: control.py -p <localfile_with_path> <phone_path_with_filename>

    must be corrected by
    # GET files to the phone:

    * usage: control.py -g <localfile_with_path> <phone_path_with_filename>
    pys60 1.4.5 and 2.0.0, pygame, PyS60 CE on E90 and 5800 !

    Find my pys60 extension modules on cyke64.googlepages.com

  • #5
    Registered User
    Join Date
    Sep 2005
    Posts
    30

    Re: [announce] Sync & run made easy

    Quote Originally Posted by cyke64
    Hey Raul ,
    I notice an error on your site
    Fixed! BTW, have you found a simpler way to sync and run?

  • Similar Threads

    1. Mail Sync for S60 / S60 3rd Devices
      By bmenke in forum PC Suite API and PC Connectivity SDK
      Replies: 4
      Last Post: 2006-09-17, 06:24
    2. Cannot Sync through bluetooth or usb on 6630
      By Un6rand3d in forum Bluetooth Technology
      Replies: 0
      Last Post: 2004-12-10, 09:14
    3. easy code can't run in NOKIA !
      By mayongfeng in forum Mobile Java General
      Replies: 1
      Last Post: 2004-08-19, 08:34
    4. sync of pictures with 7650 Problem...
      By ncretin in forum OMA DM/DS/CP
      Replies: 0
      Last Post: 2004-04-13, 09:08
    5. Replies: 1
      Last Post: 2003-06-05, 20:50

    Posting Permissions

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