Python上出现“以下参数必填:操作”错误

时间:2018-09-24 12:30:58

标签: python ethernet

我是Python的初学者,所以对不起这个基本问题。 (对不起,我的英语) 我尝试使用此github code块进行Profinet通信。如果我这样拨打main.py:

python main.py -i discover

比我有这个错误:

usage: main.py [-h] -i INTERFACE
               {discover,get-param,set-param,read,read-inm0-filter,read-inm0,read-inm1,write-inm1}
               [target] [param] [value] [additional1] [additional2]
main.py: error: the following arguments are required: action

然后我尝试使用此行:

python server.py -i eth0

我有这个错误:

Traceback (most recent call last):
  File "server.py", line 20, in <module>
    s = ethernet_socket(args.i, 0x8892)
  File "/home/name/Documents/profinet-master/util.py", line 25, in ethernet_socket
    s = socket(AF_PACKET, SOCK_RAW)
  File "/usr/lib/python3.6/socket.py", line 144, in __init__
    _socket.socket.__init__(self, family, type, proto, fileno)
PermissionError: [Errno 1] Operation not permitted

那就是etherneth_socket:

def ethernet_socket(interface, ethertype):
    s = socket(AF_PACKET, SOCK_RAW)
    s.bind((interface, ethertype))
    return s

如何使用此代码或如何调用此python代码。请帮我谢谢你。

0 个答案:

没有答案