Author Topic: TCP CPython communication  (Read 1552 times)

0 Members and 1 Guest are viewing this topic.

MrGlasspoole

  • Jr. Member
  • **
  • Posts: 5
  • Karma: 0
    • View Profile
TCP CPython communication
« on: November 10, 2014, 04:23:00 AM »
Hi,

I'm having some problems with IronPython so i want to use CPython.
The idea is to let VC communicate through TCP with CPython.

From a webpage i can send "VC.On\r\n" and in VC i see "VC.ON:" but VC does not turn into green.
Is there more i need to do?

The other question is how to i send from VC if TCP is running as server and not as client?
I think it must be possible cause in my CMD window i receive "OK" after sending the command above - so VC is sending back!?

Notes:
The whole setup is a little more complicated cause i'm using MQTT and Websockets.
But seeing "VC.ON:" in VC means the CPython asynchat/asyncore <-> VC TCP connection works.

jitterjames

  • Administrator
  • Hero Member
  • *****
  • Posts: 7714
  • Karma: 116
    • View Profile
    • VoxCommando
Re: TCP CPython communication
« Reply #1 on: November 10, 2014, 09:07:07 AM »
Did you try without the \r\n ?

Please post your python code and the XML for the VoxCommando command that creates the TCP server.

To send a message back you can use a client to connect to your python server.

Because of your specialized needs it might make more sense to write a short iron python code to communicate with your cpython.

jitterjames

  • Administrator
  • Hero Member
  • *****
  • Posts: 7714
  • Karma: 116
    • View Profile
    • VoxCommando
Re: TCP CPython communication
« Reply #2 on: November 10, 2014, 09:39:23 AM »
If you use the TCP plugin's simple webserver instead of TCP messages you will get responses back for each action you send as XML including the result generated by the action.

For example, if I send the simple web server this http get request:

Code: [Select]
http://127.0.0.1/api/py.execstring&&result=5*6
I will get the following response:
Code: [Select]
<action>
  <actionString>py.execstring&&result=5*6</actionString>
  <Success>True</Success>
  <Result>30</Result>
</action>