[Solved] Sending commands via TCP did not work

Home Forums V-Control General [Solved] Sending commands via TCP did not work

Viewing 5 posts - 1 through 5 (of 5 total)
  • Author
  • #639

    tried to start a task via TCP remote service, listening on 10101, which did not work for me.

    Used were the following lines under raspbian:

    echo “405scrRunTask5Shutdown_All_PCs6” > /dev/tcp/
    echo “(4)0(5)scrRunTask(5)Shutdown_All_PCs(6)” > /dev/tcp/
    echo “(4)2(5)H(5)(6)” > /dev/tcp/

    And the result was always a lost connection.

    • This topic was modified 7 years, 3 months ago by Dierk Walter.
    • This topic was modified 6 years, 8 months ago by Dierk Walter.

    Hi Marcus, thank you for joining us.
    The message “lost connection” is impossible if you are using V-Control remote services. If V-Control act as remote server it could not loose a connection because the client decides to connect or not. Only the client can lose a connection. A server only offers a connection. If a client disconnects, then the connection is ended, but from the servers point of view the connection is not lost, the client simply ended it.
    I suspect that you have set up a device, probably a generic device, that should connect to your Raspberry Pi. In that case you need a TCP sever on your raspberry, which is impossible to establish by echo commands (as far as I know and surely not as you did in your example).

    If you use the Raspberry Pi as TCP client (and your demo code suggests that this is what you want to do), you need to set up V-Control as remote server. Select “Configure -> Options” from V-Controls main menu and select the tab “TCP”. Choose a port and check the box “Enable TCP Services”.
    Now V-Control is ready to receive commands by its remote control protocol. The protocol is not pure ASCII code. I’m not so familiar with Linux bash, but I know that sending a command such as

    echo “(4)0(5)scrRunTask(5)Shutdown_All_PCs(6)” > /dev/tcp/

    could not work. The reason is that the command and parameter separators in the V-Control remote protocol are not ASCII characters. As explained here http://v-control.com/wiki/doku.php/remoteprotocolgeneral you have to send the digital value as separator.

    If you type
    echo “(4)0(5)scrRunTask(5)Shutdown_All_PCs(6) > /dev/tcp/

    in your Linux terminal, you send the braces and the “4” as ASCII code. “4” is ASCII code 52. You need to send 4 as value, and no braces. It is explained in the documentation (possibly not clear enough). You have to send values in braces as digital value. I don’t know how to to this in a bash, an example in BASIC language looks like this:

    Dim s as string
    s = chr(4) + “0” + chr(5) + “scrRunTask” + chr(5) + “Shutdown_All_PCs” + chr(6)

    There is also a Tutorial explaining the difference using remote services and device events here: http://v-control.com/wiki/doku.php/tutorials:multiple_v-io_boxes_for_push_button_events


    Hello Dierk,

    thank you for your suggestions.

    And indeed, I used the remote server of V-Control.
    I will try to modify the string and post the result here.




    Hello again,

    I wrote a Python script to send the string via TCP socket:


    import socket
    import sys

    # Create a TCP/IP socket
    sock = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
    server_address = (‘’, 10101)

    s = chr(4) + “0” + chr(5) + “scrRunTask” + chr(5) + “Shutdown_All_PCs” + chr(6)

    # Send data
    print >>sys.stderr, ‘sending “%s”‘ % s

    print >>sys.stderr, ‘closing socket’

    This works for me 😉

    Thanks again for your support and your patience, Dierk!


    Hi Marcus,

    thank you for sharing your code.


Viewing 5 posts - 1 through 5 (of 5 total)
  • You must be logged in to reply to this topic.