Shop OBEX P1 Docs P2 Docs Learn Events
Setting Variables on the PINK — Parallax Forums

Setting Variables on the PINK

crgwbrcrgwbr Posts: 614
edited 2007-11-02 21:24 in General Discussion
On a robot of mine, I'm planning on using the PINK connected to Prop for communication with my Laptop. However, I need to have a Python program talking to the pink, not a Web Browser. The Python app needs to be able to set the variables in the Pink. Does anyone have any Ideas how this might be done? From python I know you can send and receive packets, but I have never done this before.

Thanks for the Help,
Craig

▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
"... one of the main causes of the fall of the Roman Empire was that, lacking zero, they had no way to indicate successful termination of their C programs." -

"If Python is executable pseudocode, then perl is executable line noise."

"The best accelerator available for a Mac is one that causes it to go at 9.81 m/s2."

"My software never has bugs. It just develops random features."

"Windows isn't a virus, viruses do something."

"Programmers are tools for converting caffeine into code."

"Enter any 11-digit prime number to continue."

Comments

  • Mike GreenMike Green Posts: 23,101
    edited 2007-11-01 15:08
    Usually, the web browser requests a web page using a "GET" command (a type of file request) and the web server sends the whole page as HTML text (essentially a whole file). That's what your Python program will have to do ... send a GET statement and receive a text file. Then your program will have to parse the HTML to extract the variables. Most browsers will let you view the source HTML for the web page being displayed. Set up a PINK with your laptop and look at the page with your browser and switch to HTML source view. You'll see what the PINK actually sends and what you'll have to parse using Python. There are lots of books available on HTML including some good introductory ones ... pretty much any bookstore will have some.
  • crgwbrcrgwbr Posts: 614
    edited 2007-11-01 15:15
    Thanks for the reply. I have been able to fetch HTML with python. I guess my question was more on how to take the HTML, replace the old variable with new ones, and submit those to the PINK.


    thanks,
    Craig

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    "... one of the main causes of the fall of the Roman Empire was that, lacking zero, they had no way to indicate successful termination of their C programs." -

    "If Python is executable pseudocode, then perl is executable line noise."

    "The best accelerator available for a Mac is one that causes it to go at 9.81 m/s2."

    "My software never has bugs. It just develops random features."

    "Windows isn't a virus, viruses do something."

    "Programmers are tools for converting caffeine into code."

    "Enter any 11-digit prime number to continue."
  • Mike GreenMike Green Posts: 23,101
    edited 2007-11-01 15:33
    Look at descriptions of HTTP GET and/or POST commands. These let you set HTML variables when you request a web page. The PINK documentation shows you how these variable names are constructed (from the variable numbers).
  • crgwbrcrgwbr Posts: 614
    edited 2007-11-01 19:04
    Thanks Mike. I did a quick google search and found a python object called ClientForm. It is very simple to use. I'll post the Python Test code if anyone else wants to take a look at it. I think this could be espessily useful to the Internet Controlled Bot that a few people are working on right now.

    Thanks Again,
    Craig

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    "... one of the main causes of the fall of the Roman Empire was that, lacking zero, they had no way to indicate successful termination of their C programs." -

    "If Python is executable pseudocode, then perl is executable line noise."

    "The best accelerator available for a Mac is one that causes it to go at 9.81 m/s2."

    "My software never has bugs. It just develops random features."

    "Windows isn't a virus, viruses do something."

    "Programmers are tools for converting caffeine into code."

    "Enter any 11-digit prime number to continue."
    py
    672B
  • DgswanerDgswaner Posts: 795
    edited 2007-11-02 06:17
    I'm not familiar with python can you tell me how to use this? do I just put this in an HTML file?
    thanks!

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    A complex design is the sign of an inferior designer. - Jamie Hyneman, Myth Buster
  • crgwbrcrgwbr Posts: 614
    edited 2007-11-02 21:24
    No, the Form.py is a client side script. When you run the program (you'll need the python interpreter from python.org) it accesses the default modify variables page on the pink and modifies one of them. You'll need to change the IP address written into the program to match your PINK. But basically, it lets you have a program running on any computer, access and modify variables of the pink, therefore sending commands to your robot.

    I hope this clears it up for you,
    Craig

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    "... one of the main causes of the fall of the Roman Empire was that, lacking zero, they had no way to indicate successful termination of their C programs." -

    "If Python is executable pseudocode, then perl is executable line noise."

    "The best accelerator available for a Mac is one that causes it to go at 9.81 m/s2."

    "My software never has bugs. It just develops random features."

    "Windows isn't a virus, viruses do something."

    "Programmers are tools for converting caffeine into code."

    "Enter any 11-digit prime number to continue."
Sign In or Register to comment.