我正在使用python-seabreeze与光谱仪交谈。一些但不是所有可用命令都在 python-seabreeze 中实现。从OceanOptics Flame-T手册中可以看到有如下命令(举例):
.
.
0x09 Request Spectra
0x0A Set Trigger Mode
0x0B Query number of Plug-in Accessories Present
0x0C Query Plug-in Identifiers
0x0D Detect Plug-ins
0x12 LED Status
0x60 General I2C Read
0x61 General I2C Write
0x62 General SPI I/O
0x68 PSOC Read
0x69 PSOC Write
0x6A Write Register Information
0x6B Read Register Information
0x6C Read PCB Temperature
0x6D Read Irradiance Calibration
.
.
从seabreeze/pyseabreeze/protocol.py我可以看到这些命令是这样形成的:
import functoolsimport struct msgs = { code: functools.partial(struct.Struct(msg).pack, code) for code, msg in { 0x01: "<B", # OP_INITIALIZE 0x02: "<BI", # OP_ITIME 0x03: "<BH", # set Strobe/Lamp enable Line 0x05: "<BB", # OP_GETINFO 0x09: "<B", # OP_REQUESTSPEC 0x0A: "<BH", # OP_SETTRIGMODE 0x6A: "<BBH", # OP_WRITE_REGISTER 0x6B: "<BB", # OP_READ_REGISTER 0x71: "<BBB", # OP_TECENABLE_QE 0x72: "<B", # OP_READTEC_QE 0x73: "<Bh", # OP_TECSETTEMP_QE 0xFE: "<B", # OP_USBMODE }.items() } # add more here if you implement new features
例如Request Spectra
,根据手册是0x09
,当它来自 python 时,一条消息
struct.Struct('<B').pack(0x09)
已发送。我试图通过阅读struct format strings来了解发生了什么,我发现这<
意味着“小端”, B
意味着无符号字符,h
意味着短,等等。
从手册中应该如何知道格式是,而格式OP_GETINFO
是?这是什么逻辑?你会把什么格式和为什么?<BB
OP_WRITE_REGISTER
<BBH
0x6C Read PCB Temperature
慕田峪4524236
相关分类