python模块与sportident主站通信
sireader的Python项目详细描述
sireader是一个python模块,用于与sportident主站通信 读取Sportident卡。sportident主要是一种电子冲孔系统 用于定向运动项目。
Sireader支持两种主要操作模式。可用于整张卡片 读出或在控制站模式下从控制装置发送冲头。第一种模式 通常用于在终点线后读取卡片数据 变成一个事件软件。第二种模式用于从 中间控制。
网站:http://bosco.durcheinandertal.ch/
git存储库:https://github.com/gaudenz/sireader/
用法
Sireader模块中有3个类。sireader是基类 包含共同功能的。它是进口的,便于使用 常数。sireaderread实现经典卡读出。 sireadercontrol实现配置为控件的工作站 不停地挥拳。
首先导入相关类:
from sireader import SIReader, SIReaderReadout, SIReaderControl
sireader只支持所谓的“扩展协议”模式。如果你的 基站不在此模式下,您必须更改协议模式 第一个:
# change to extended protocol mode si.set_extended_protocol()
使用Sportident基站读取卡:
from time import sleep # connect to base station, the station is automatically detected, # if this does not work, give the path to the port as an argument # see the pyserial documentation for further information. si = SIReaderReadout() # wait for a card to be inserted into the reader while not si.poll_sicard(): sleep(1) # some properties are now set card_number = si.sicard card_type = si.cardtype # read out card data card_data = si.read_sicard() # beep si.ack_sicard()
使用基站作为控制发送穿孔:
# configure station si.set_operating_mode(SIReader.M_CONTROL) si.set_station_code(99) si.set_autosend() # connect to station si = SIReaderControl() # poll for new punches punches = si.poll_punch() # reset station configuration si.set_operating_mode(SIReader.M_READOUT) si.set_autosend(False)
最后将站点设置回基本协议:
# change back to basic protocl si.set_extended_protocol(False)
API文档
完整的文档包含在模块源代码中,可以 在线阅读:
http://bosco.durcheinandertal.ch/epydoc-sireader/
此文档是从源代码和 表示Git存储库中的版本。