python - python套接字协议不支持
问题描述
我在 RaspberryPi3 上使用了 python-can-isotp,并使用示例代码对其进行了测试,但出现错误。
我的简单代码:
import isotp
s = isotp.socket()
s2 = isotp.socket()
# Configuring the sockets.
s.set_fc_opts(stmin=5, bs=10)
#s.set_general_opts(...)
#s.set_ll_opts(...)
s.bind("vcan0" rxid=0x123 txid=0x456) # We love named parameters!
s2.bind("vcan0", rxid=0x456, txid=0x123)
s2.send(b"Hello, this is a long payload sent in small chunks of 8 bytes.")
print(s.recv())
错误:
File "/usr/local/opt/python-3.7.0/lib/python3.7/socket.py", line 151, in __init__
_socket.socket.__init__(self, family, type, proto, fileno)
OSError: [Errno 93] Protocol not supported
有人可以帮我找到问题的解决方案吗?
解决方案
我按照这些说明(稍作修改)isotp
使用最新的 Raspbian Stretch 在 Raspberry Pi 3B+ 上工作。
这是我执行的命令的确切顺序:
sudo apt update
sudo apt upgrade
git clone https://github.com/hartkopp/can-isotp.git
cd can-isotp
sudo apt install build-essential raspberrypi-kernel-headers
make install
sudo make modules_install
modprobe can
sudo insmod ./net/can/can-isotp.ko
但是,我不在 Python 中使用它。我只是简单地测试了提供用于使用的工具isotp
,例如 egisotpsend
和isotprecv
.
推荐阅读
- naudio - 为什么我的 WASAPI 监听器即使在没有播放的时候也会触发?
- python - 添加变量以显示 wxpython 框架中的任何文本
- vb.net - RichTextBox 行号字体大小调整 - VB.NET
- powershell - Powershell $_ 运算符是一个意外的标记
- mysql - mysql选择查询中的正则表达式
- c++ - 如何使用随机访问文件创建程序来读取和显示文件
- javascript - 每天的完整日历事件数
- jmeter - 在Jmeter上所有样本结束后如何执行BeanShell PostProcessor?
- javascript - 如果位置的“id”有空间,角度数据图不会填充正确的颜色
- sql - 计算特定课程的平均时间