Esempio n. 1
0
def stdinHnd(fd, clientData):
    global done
    input = sys.stdin.readline()

    if (input[0] == 'q' or input[0] == 'Q'):
        IPC.IPC_disconnect()
        done = True
    elif (input[0] == 'm' or input[0] == 'M'):
        i1 = 42
        print "\n  IPC_publishData(%s, %d)" % (MSG1, i1)
        IPC.IPC_publishData(MSG1, i1)
    elif (input[0] == 'r' or input[0] == 'R'):
        t1 = T1()
        t1.i1 = 666
        t1.status = SendVal
        t1.matrix = ((0.0, 1.0, 2.0), (1.0, 2.0, 3.0))
        t1.d1 = 3.14159
        print "\n  IPC_queryResponseData(%s, %s, IPC_WAIT_FOREVER, %s)" % \
              (QUERY1, t1, T1.__name__)
        (r1, ret) = IPC.IPC_queryResponseData(QUERY1, t1, IPC.IPC_WAIT_FOREVER,
                                              T1)
        print "\n  Received response"
        IPC.IPC_printData(IPC.IPC_msgFormatter(RESPONSE1), sys.stdout, r1)
    else:
        print "stdinHnd [%s]: Received %s" % (clientData, input),
Esempio n. 2
0
def queryHandler(msgRef, t1, clientData):
    print "queryHandler: Receiving %s [%s]",  \
   (IPC.IPC_msgInstanceName(msgRef), clientData)
    IPC.IPC_printData(IPC.IPC_msgInstanceFormatter(msgRef), sys.stdout, t1)

    # Publish this message -- all subscribers get it
    str1 = "Hello, world"
    print '\n  IPC.IPC_publishData(%s, "%s")' % (MSG2, str1)
    IPC.IPC_publishData(MSG2, str1)

    t2 = T2()
    t2.str1 = str1
    # Variable length array of one element
    t2.t1 = [T1()]
    t2.t1[0] = t1
    t2.count = 1
    t2.status = ReceiveVal

    # Respond with this message -- only the query handler gets it
    print "\n  IPC.IPC_respondData(%s, %s, %s)" % (msgRef, RESPONSE1, t2)
    IPC.IPC_respondData(msgRef, RESPONSE1, t2)