Brian,

Depending on your needs there are three ways to accomplish this. The
first uses the lowest level API, emanesh.ControlPortClient:

[=== begin method 1 ===]

#!/usr/bin/env python
import sys
from emanesh import ControlPortClient, ControlPortException

client = ControlPortClient('localhost', 47000)

# You will need to determine the build Id for the component you wish
# to update. For this example we will search for the first RF Pipe
# radio model.

firstRFPipeBuildId = None

# Retrieve the running component manifest. This is the information
# available from the 'emanesh show' command.
for nemId,components in client.getManifest().items():

    if firstRFPipeBuildId == None:

        for buildId,componentType,plugin in components:

            if plugin == 'rfpipemaclayer':

                # Output for illustrative purposes only
                print 'Found nem id:',\
                    nemId,\
                    'build id:',\
                    buildId,\
                    'type:',\
                    componentType,\
                    'plugin:',\
                    plugin


                # Store the build id
                firstRFPipeBuildId = buildId
                break
    else:
        break

if firstRFPipeBuildId != None:

    try:
        client.updateConfiguration(firstRFPipeBuildId,
                                   [('datarate',
                                     ControlPortClient.TYPE_UINT64,
                                     (1000000,))])
    except ControlPortException as exp:
        print >>sys.stderr,exp

else:
    print >>sys.stderr, "unable to locate RF Pipe radio model instance"

client.stop()

[=== end method 1 ===]

The second method uses emanesh.EMANEShell. This is simpler but requires
you to conform to emanesh syntax:

[=== begin method 2 ===]

#!/usr/bin/env python

from emanesh import EMANEShell

shell = EMANEShell('localhost',47000)

shell.onecmd('set config 1 mac datarate=1000000')

shell.onecmd('exit')

[=== end method 2 ===]

The third method is available if you wish to script a scenario that
changes configuration at set time points. You can use the
emanecommand-eel command:

 # emanecommand-eel /path/to/your/scenario/command.eel

where,

 # cat /path/to/your/scenario/command.eel
 5.0 localhost:47000 emanesh set config 1 mac datarate=1000000

emanecommand-eel uses method 2.

-- 
Steven Galgano
Adjacent Link LLC
www.adjacentlink.com


On 10/22/2014 12:55 PM, Henz, Brian J CIV (US) wrote:
> Classification: UNCLASSIFIED
> Caveats: NONE
> 
> I have been unable to find an example of using the python module 
> emanesh.ControlPortClient
> 
> I would like to change a MAC datarate from python, which I currently do from 
> the command line with:
> 
> [username]$ emanesh 10.10.10.101 "set config 1 mac datarate=1000000"
> 
> Thanks,
>   Brian
> 
> 
> 
> Brian J. Henz, PhD
> U.S. Army Research Laboratory
> ATTN: RDRL-CIH-C
> Advanced Computing and Computational Sciences Division APG, MD 21005
> Phone: 410-278-6531
> Fax: 410-278-4983
> email: [email protected]
> 
> 
> 
> Classification: UNCLASSIFIED
> Caveats: NONE
> 
> 
> _______________________________________________
> emane-users mailing list
> [email protected]
> http://pf.itd.nrl.navy.mil/mailman/listinfo/emane-users
> 
_______________________________________________
emane-users mailing list
[email protected]
http://pf.itd.nrl.navy.mil/mailman/listinfo/emane-users

Reply via email to