def test(alias, dest, connection, address, count, space, verbose):
    cmd = 0x40
    if space == 0xFF:
        cmd = 0x43
    if space == 0xFE:
        cmd = 0x42
    if space == 0xFD:
        cmd = 0x41
    retval = datagram.sendOneDatagram(alias, dest, [
        0x20, cmd,
        (address / 256 / 256 / 256) & 0xFF, (address / 256 / 256) & 0xFF,
        (address / 256) & 0xFF, address & 0xFF, count
    ], connection, verbose)
    if retval != 0:
        return retval
    # read data response
    retval = datagram.receiveOneDatagram(alias, dest, connection, verbose)
    if (type(retval) is int):
        # pass error code up
        return retval
    if retval[0:6] != [
            0x20, cmd | 0x10, (address / 256 / 256 / 256) & 0xFF,
        (address / 256 / 256) & 0xFF, (address / 256) & 0xFF, address & 0xFF
    ]:
        print "Unexpected message instead of read reply datagram ", retval
        return 3
    if verbose: print "read value", retval[6:]
Пример #2
0
def test(alias, dest, connection, verbose):

    # instead of checking the length of the address space (not cleanly required anyway)
    # this assumes a null-terminated string and reads until it gets the null

    address = 0
    result = ""
    chunk = 16
    done = False

    while True:
        # Read from CDI space
        retval = datagram.sendOneDatagram(alias, dest, [
            0x20, 0x43, (address >> 24) & 0xFF, (address >> 16) & 0xFF,
            (address >> 8) & 0xFF, address & 0xFF, chunk
        ], connection, verbose)
        if retval != 0:
            return retval
        # read data response
        retval = datagram.receiveOneDatagram(alias, dest, connection, verbose)
        if (type(retval) is int):
            # pass error code up
            return retval
        if retval[0:2] != [0x20, 0x53]:
            print "Unexpected message instead of read reply datagram ", retval
            return 3
        for c in retval[6:]:
            result = result + chr(c)
            if c == 0:
                done = True
                break
        if done: break
        address = address + chunk

    if verbose: print "   Read CDI result was ", len(result), " bytes"
    if connection.network.verbose:
        print "  Read CDI result ++++++++++\n", result, "\n++++++++++++++++"

    executable = "xmllint --noout --schema ../../specs/schema/cdi.xsd - "

    import subprocess
    process = subprocess.Popen(executable, 1, None, subprocess.PIPE,
                               subprocess.PIPE, subprocess.STDOUT, None, False,
                               True)
    [stdout, stderr] = process.communicate(result)

    if process.returncode != 0:
        print "   CDI data did not validate:  ", stdout
    if process.returncode == 0 and verbose:
        print "   CDI result check:  ", stdout

    return process.returncode
Пример #3
0
def test(alias, dest, connection, verbose) :

    # instead of checking the length of the address space (not cleanly required anyway)
    # this assumes a null-terminated string and reads until it gets the null

    address = 0
    result = ""
    chunk = 16
    done = False
    
    while True :    
        # Read from CDI space
        retval = datagram.sendOneDatagram(alias, dest, [0x20,0x43,(address>>24)&0xFF,(address>>16)&0xFF,(address>>8)&0xFF,address&0xFF,chunk], connection, verbose)
        if retval != 0 :
            return retval
        # read data response
        retval = datagram.receiveOneDatagram(alias, dest, connection, verbose)
        if (type(retval) is int) : 
            # pass error code up
            return retval
        if retval[0:2] != [0x20,0x53] :
            print "Unexpected message instead of read reply datagram ", retval
            return 3
        for c in retval[6:] :
            result = result+chr(c)
            if c == 0 :
                done = True
                break;
        if done : break
        address = address + chunk
        
    if verbose : print "   Read CDI result was ", len(result), " bytes"
    if connection.network.verbose : print "  Read CDI result ++++++++++\n", result,"\n++++++++++++++++"
        
    executable = "xmllint --noout --schema ../../specs/schema/cdi.xsd - "

    import subprocess
    process = subprocess.Popen(executable,1,None,subprocess.PIPE,subprocess.PIPE, 
                    subprocess.STDOUT, None, False, True)
    [stdout, stderr] = process.communicate(result) 
    
    if process.returncode != 0 :
        print "   CDI data did not validate:  ", stdout
    if process.returncode == 0 and verbose :
        print "   CDI result check:  ", stdout

    return process.returncode
Пример #4
0
def test(alias, dest, connection, address, count, space, verbose) :
    cmd = 0x40
    if space == 0xFF :
        cmd = 0x43
    if space == 0xFE :
        cmd = 0x42
    if space == 0xFD :
        cmd = 0x41
    retval = datagram.sendOneDatagram(alias, dest, [0x20,cmd,(address/256/256/256)&0xFF,(address/256/256)&0xFF,(address/256)&0xFF,address&0xFF,count], connection, verbose)
    if retval != 0 :
        return retval
    # read data response
    retval = datagram.receiveOneDatagram(alias, dest, connection, verbose)
    if (type(retval) is int) : 
        # pass error code up
        return retval
    if retval[0:6] != [0x20,cmd|0x10,(address/256/256/256)&0xFF,(address/256/256)&0xFF,(address/256)&0xFF,address&0xFF] :
        print "Unexpected message instead of read reply datagram ", retval
        return 3
    if verbose : print "read value", retval[6:]