Example #1
0
client = ControlPortClient('node-1',47000)

try:
    # retrieve the manifest
    manifest  = client.getManifest()

    phyLayerBuildId = None

    # find the PHY component build id for the lowest NEM instance
    for buildId,componentType,_ in  manifest[min(manifest)]:
        if componentType == 'PHY':
            phyLayerBuildId =  buildId
            break

    # build a mapping of parameter names to data types
    parameterType = {}

    for name,values in client.getConfiguration(phyLayerBuildId).items():
        if values:
            # second values tuple item is the data type
            parameterType[name]=values[0][1]

    # update the phy rxpower setting - updateConfiguration wants a
    # list of (name,data type,values) entries
    client.updateConfiguration(phyLayerBuildId,
                               (('txpower',parameterType['txpower'],(txPowerdBm,)),))

finally:
    # terminate the connection
    client.stop()
# BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
# LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
# CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
# LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
# ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
# POSSIBILITY OF SUCH DAMAGE.
#

try:
    from emane.shell import ControlPortClient
except:
    from emanesh import ControlPortClient

from pprint import pprint

# create a control port connection to a running emulator instance
client = ControlPortClient('node-1', 47000)

try:
    # retrieve the manifest
    manifest = client.getManifest()

    # target the smallest build id component contained in the smallest
    # NEM id running in the emulator
    pprint(
        client.getConfiguration(min([x[0] for x in manifest[min(manifest)]])))

finally:
    # terminate the connection
    client.stop()