Esempio n. 1
0
def devStFbState(device, resource, fbname, state):
    msg = "#%02XD7%s00%02X%02X$" % (device, str2hex(fbname), state, resource)
    print "Send7: ", msg
    inet.send(msg)
    if (waitOk()):
        return True
    return False
Esempio n. 2
0
def devNewCon(device,
              resource,
              from_fb,
              from_var,
              to_fb,
              to_var,
              size,
              isEvent,
              mvalue=None):
    value = ""
    if (mvalue == None):
        value = ""
    else:
        if (type(mvalue) is int):
            value = "%02X" % (mvalue)
            print "Value = ", value
        else:
            value = "%02X" % (int(mvalue))
            print "Value = ", value
            #print "Only integers are supported for conection with a constant."
            #return
    msg = "#%02XD4%s00%02X%s00%02X%02X%02X%02X%s$" % (
        device, str2hex(from_fb), from_var, str2hex(to_fb), to_var, size,
        resource, isEvent, value)
    print "Send5: ", msg
    inet.send(msg)
    if (waitOk()):
        return True
    return False
Esempio n. 3
0
def devDelInstance(device, resource, name):
    msg = "#%02XE3%s00%02X$" % (device, str2hex(name), resource)
    print "Send6: ", msg
    inet.send(msg)
    if (waitOk()):
        return True
    return False
Esempio n. 4
0
def devNewInst(device, resource, name, type):
    msg = "#%02XD3%s00%s00%02X$" % (device, str2hex(type), str2hex(name),
                                    resource)
    print "Send4: ", msg
    inet.send(msg)
    if (waitOk()):
        return True
    return False
Esempio n. 5
0
def devHasFbType(device, type):
    data = type
    s = len(data)
    #s+2 command+type+00
    msg = "#%02XD6%s00$" % (device, str2hex(type))
    print "Send1: ", msg
    inet.send(msg)
    return waitOk()
Esempio n. 6
0
def devGetFbState(device, resource, fbname, fbtype):
    msg = "#%02XD8%s00%02X$" % (device, str2hex(fbname), resource)
    #print "Send8: ", msg
    inet.send(msg)
    msg = waitMsg()

    #print msg
    msgo = ''
    if (msg != None):
        vars = getVarsOfFb(fbtype)
        for k, v in vars.iteritems():
            if (k[0] != '_' and k[1] != '_'):
                d = ''
                t = 0
                while (t < v['size']):
                    d = d + msg[vars[k]['pos'] * 2 +
                                5] + msg[vars[k]['pos'] * 2 + 5 + 1]
                    t = t + 1

                msgo = msgo + "%s %d\n" % (k, int(d, 16))

    return msgo[:len(msgo) - 1] + ''
Esempio n. 7
0
def devSendFb(device, type):
    f = open(dir_asm + '/' + type + '.hex')
    t = f.read()
    bytes = t.split(' ')
    #create the block
    msg = "#%02XD1%s00%04X$" % (device, str2hex(type), len(bytes))
    print "Send2: ", msg
    inet.send(msg)
    if (not waitOk()):
        return False
    #write on block
    pos = 0
    er_count = 0
    while (len(bytes) > 0):
        #print "--> ",bytes
        c = 0
        bs = bytes[0:10]
        data = ""
        for b in bs:
            if (len(b) > 0 and b != ''):
                data = data + "%02X" % (int(b))
                c = c + 1
        if (c == 0):
            return True
        msg = "#%02XD2%s00%04X%02X%s$" % (device, str2hex(type), pos, c, data)
        #msg = msg+'$'
        print "Send3: ", msg
        inet.send(msg)
        if (waitOk()):
            #del bytes[0:10]
            bytes = bytes[10:]
            pos = pos + c
            er_count = 0
        else:
            er_count = er_count + 1
            if (er_count > 3):
                return False

    return True
Esempio n. 8
0
def devClear(device):
    msg = "#%02XD9$" % (device)
    inet.send(msg)
    if (waitOk()):
        return True
    return False