Barst的接口。
项目描述
PyBarst是Barst客户端API的Python绑定。
本项目为Barst服务器项目提供Python接口。Barst是一个服务器,提供对实验室常用硬件的访问,例如FTDI USB设备、RTV相机、串行端口等。
轮子包含Barst可执行文件,因此不需要单独安装。可执行文件路径可在pybarst.dep_bins中找到。
更多信息:http://matham.github.io/pybarst/index.html
要安装https://matham.github.io/pybarst/installation.html
使用示例
启动服务器
>>> # create a local server instance with a pipe named TestPipe. Since not >>> # provided, the executable is searched for in pybarst.dep_bins and in >>> # Program Files. >>> server = BarstServer(pipe_name=r'\\.\pipe\TestPipe') >>> # now actually create the server and start it running >>> server.open_server() >>> # Connect to a server running on remote computer named PC_Name using a pipe named TestPipe >>> server2 = BarstServer(pipe_name=r'\\PC_Name\pipe\TestPipe') >>> # now open the connection to the remote server >>> server2.open_server()
获取当前服务器时间
>>> server.clock() (1.5206475727928106, 13045896424.049448)
使用RTV-4视频卡的示例
>>> from pybarst.core.server import BarstServer >>> from pybarst.rtv import RTVChannel >>> server = BarstServer(pipe_name=r'\\.\pipe\TestPipe') >>> server.open_server() >>> print(server.get_manager('rtv')) {'version': 1080L, 'chan': 1, 'chan_id': 'RTVMan'} >>> # for the code below, there should be a RTV-4 like device connected, with >>> # a port 0 available >>> rtv = RTVChannel(server=server, chan=0, video_fmt='full_NTSC', frame_fmt='rgb24', lossless=False) >>> rtv.open_channel() >>> rtv.set_state(state=True) >>> # data is a buffer containing the raw image data >>> time, data = rtv.read() >>> print(time, len(data), rtv.buffer_size) (12865.015067682945, 921600, 921600L) >>> time, data = rtv.read() >>> print(time, len(data), rtv.buffer_size) (12865.048412758983, 921600, 921600L) >>> # remove any data queued, otherwise read will return any waiting data >>> rtv.set_state(state=False, flush=True)
使用Windows串行端口的示例
>>> from pybarst.core.server import BarstServer >>> from pybarst.serial import SerialChannel >>> server = BarstServer(pipe_name=r'\\.\pipe\TestPipe') >>> server.open_server() >>> print(server.get_manager('serial')) {'version': 498139398L, 'chan': 0, 'chan_id': 'SerMan'} >>> # for this example, COM3 should have a loopback cable connected to it. >>> serial = SerialChannel(server=server, port_name='COM3', max_write=32, max_read=32) >>> serial.open_channel() >>> time, val = serial.write(value='How are you today?', timeout=10000) >>> print(time, val) (1931.5567431509603, 18) >>> # read the exact number of chars written. >>> time, val = serial.read(read_len=len('How are you today?'), timeout=10000) >>> print(time, val) (1931.5607736011307, 'How are you today?') >>> serial.close_channel_server()
项目详情
下载文件
下载适用于您的平台的文件。如果您不确定选择哪个,请了解更多关于安装包的信息。
源代码发行版
PyBarst-2.1.zip (13.5 kB 查看散列值)
构建版本
PyBarst-2.1-cp34-cp34m-win32.whl (2.1 MB 查看哈希值)
PyBarst-2.1-cp27-cp27m-win32.whl (2.1 MB 查看哈希值)
关闭
PyBarst-2.1.zip 的哈希值
算法 | 哈希摘要 | |
---|---|---|
SHA256 | 2aba478094c35f3c79eff72fe3cc6f6ae01ee1dc142e36a9da9e189b0e5e2213 |
|
MD5 | ec5d8bfa683b0b1c209e316e5b780665 |
|
BLAKE2b-256 | 4d649acf748a552246f36397b8e094fddab2276ef4c93fecfc05d36c91d77659 |
关闭
PyBarst-2.1-cp34-cp34m-win_amd64.whl 的哈希值
算法 | 哈希摘要 | |
---|---|---|
SHA256 | 0c71d3b3b29b555d02013f856d6afec15d9a04218dff258e728c59e1322df9c3 |
|
MD5 | faf72fe0ba5f96c326ff22404cccaa80 |
|
BLAKE2b-256 | 2dccbd8774f703a8629070e8396dfa9cbac0f73c3d43d37665c01a693010abdb |
关闭
PyBarst-2.1-cp34-cp34m-win32.whl 的哈希值
算法 | 哈希摘要 | |
---|---|---|
SHA256 | 9a38bd4f4b2d566cd56f9cd033e0707f3cf690e3450ddf16b600633a5714ddb4 |
|
MD5 | fe72a8931314d348ce8ea08737350e37 |
|
BLAKE2b-256 | 96b174cbb8d108d2f51749e9817b6620e81e63363447f3499bce1099f381913d |
关闭
PyBarst-2.1-cp27-cp27m-win_amd64.whl 的哈希值
算法 | 哈希摘要 | |
---|---|---|
SHA256 | 6797d489791bf34accca30123885b640dd7b2f27f29e00dd6167cc6144651c89 |
|
MD5 | 6295fdfd1193b59a3466501de707b884 |
|
BLAKE2b-256 | 3721a21a8e59ac0e58fd26fcc296e9dc1faee421a944796be04c721e3420261c |
关闭
PyBarst-2.1-cp27-cp27m-win32.whl 的哈希值
算法 | 哈希摘要 | |
---|---|---|
SHA256 | cc2c0b184de0b1ab7c4eab3108f90a4e431c456208101741a809033d22498026 |
|
MD5 | 4bba4797b210c6cbac2a9ea03b145d4a |
|
BLAKE2b-256 | 6fef1afc99d660c7df51ed5d128dce94a71e1cb60dd85a5cdd6d3e0fa6ff85de |