// print something to console and set device to preoperational
util.print("Test of simple device");
nmt.preopNetwork();
i = 0;

// loop over objects 0x4000 to 0x04010 
for (object = 0x4000; object < 0x4005; object ++) {
    str = "Test object ";
    str = str + object;
    util.print(str);
    
    // write value to object 0x4000..
    result = sdo.write(object, 0x0, i);
    if (result == "SDO_OK") {
        util.print(" Write OK");
    } else {
        util.print(" Write NOT OK");
    }

    // wait a bit to allow device update its internal values
    util.msleep(10);

    // read from 0x4100.. and expect same value
    result = sdo.read(object+0x100, 0x0); 
    if (result == i) {
        util.print("Read OK");
    } else {
        util.print(" Read NOT OK");
    }
    i++;
}

function urk(count) {
    for (i = 0; i < count; i++) {
        nmt.startNetwork();
        nmt.stopNetwork();
        nmt.startNetwork();
    }
}
