Ejemplo n.º 1
0
def index():
    dcp.send_discover(s, src)
    resp = [
        dcp.DCPDeviceDescription(mac, blocks)
        for mac, blocks in dcp.read_response(s, src).items()
    ]
    return render_template("discover.html", resp=resp)
Ejemplo n.º 2
0
                    help="use INTERFACE", metavar="INTERFACE")
parser.add_argument("action", choices=("discover", "get-param", "set-param", "read", "read-inm0-filter", "read-inm0", "read-inm1", "write-inm1"))
parser.add_argument("target", nargs='?', help="MAC address of the device")
parser.add_argument("param",  nargs='?', help="parameter to read/write")
parser.add_argument("value",  nargs='?', help="value to write")
parser.add_argument("additional1",  nargs='?', help="additional parameters")
parser.add_argument("additional2",  nargs='?', help="additional parameters")

args = parser.parse_args()


s = ethernet_socket(args.i, 3)
src = get_mac(args.i)

if args.action == "discover":
    dcp.send_discover(s, src)
    dcp.read_response(s, src, debug=True)
elif args.action == "get-param":
    dcp.get_param(s, src, args.target, args.param)
elif args.action == "set-param":
    dcp.set_param(s, src, args.target, args.param, args.value)
elif args.action.startswith("read") or args.action.startswith("write"):
    print("Getting station info ...")
    info = rpc.get_station_info(s, src, args.target)
    con = rpc.RPCCon(info)

    print("Connecting to device ...")
    con.connect(src)
    
    if args.action == "read":
        print(con.read(api=int(args.param), slot=int(args.value), subslot=int(args.additional1), idx=int(args.additional2, 16)).payload)
Ejemplo n.º 3
0
def index():
    dcp.send_discover(s, src)
    resp = [dcp.DCPDeviceDescription(mac, blocks) for mac, blocks in dcp.read_response(s, src).items()]
    return render_template("discover.html", resp=resp)
Ejemplo n.º 4
0
                    choices=("discover", "get-param", "set-param", "read",
                             "read-inm0-filter", "read-inm0", "read-inm1",
                             "write-inm1"))
parser.add_argument("target", nargs='?', help="MAC address of the device")
parser.add_argument("param", nargs='?', help="parameter to read/write")
parser.add_argument("value", nargs='?', help="value to write")
parser.add_argument("additional1", nargs='?', help="additional parameters")
parser.add_argument("additional2", nargs='?', help="additional parameters")

args = parser.parse_args()

s = ethernet_socket(args.i, 3)
src = get_mac(args.i)

if args.action == "discover":
    dcp.send_discover(s, src)
    dcp.read_response(s, src, debug=True)
elif args.action == "get-param":
    dcp.get_param(s, src, args.target, args.param)
elif args.action == "set-param":
    dcp.set_param(s, src, args.target, args.param, args.value)
elif args.action.startswith("read") or args.action.startswith("write"):
    print("Getting station info ...")
    info = rpc.get_station_info(s, src, args.target)
    con = rpc.RPCCon(info)

    print("Connecting to device ...")
    con.connect(src)

    if args.action == "read":
        print(