python-3.x - 通过 RS-422 串行端口控制摄像机
问题描述
我目前正在研究并编写一个简单的程序来通过串行端口控制相机,更具体地说是 RS-422。我从制造商那里得到了相机控制协议文档。我已经阅读和测试了几天,但不幸的是,我还没有成功。我使用 Python (3.7) 来加快测试速度。下面是我的示例代码:
import serial
ser_port = serial.Serial(
port='COM4',
baudrate=9600,
parity=serial.PARITY_NONE,
stopbits=serial.STOPBITS_ONE,
bytesize=serial.EIGHTBITS
)
sccp_cmd_null = [0x00]
sccp_cmd = [0xE7, 0x40, 0x11, 0x43, 0x00, 0x00] # Chroma Key "GREEN"
if ser_port.isOpen():
# Try sending a break code first
try:
print("Sending Break Code: ", serial.to_bytes(sccp_cmd_null))
ser_port.write(serial.to_bytes(sccp_cmd_null))
except:
print("Failed Sending Break Code!")
# Try Sending The Commands
try:
print("Sending Commands: ", serial.to_bytes(sccp_cmd))
ser_port.write(serial.to_bytes(sccp_cmd))
except:
print("Failed Sending Commands!")
ser_port.close()
请注意,这是我第一次编写处理串行端口的代码。
提前感谢那些可以提供帮助的人^_^
解决方案
推荐阅读
- android - 清单合并失败并出现多个错误,请参阅日志 React-native react-native-braintree-dropin-ui
- excel - 如何根据 vba 中另一个文本框的数据填充组合框中的数据
- .net-core - 在 MVC 表单中以 Excel 格式下载 SSRS 报告 提交
- webpack - Webpack、Babel、MobX 和编译器假设
- python - 忽略exec中的外部变量
- windows - 系统上下文具有所有权限,但无法通过 Azure 中的运行命令访问共享文件夹中的文件。为什么不?
- java - 使用 Oracle SQL 从应用连接的多个表中获取数据
- html - 如何绑定到 Angular 中的数据检查和数据未检查
- java - JNA:通过 jdk-11 64 位调用 dll 的 COM 方法时内存访问无效
- javascript - 如何延迟 3 个 ajax 调用之一?