跳转到主要内容

与SportIdent主站通信的Python模块

项目描述

Sireader是一个Python模块,用于与SportIdent主站通信以读取SportIdent卡。SportIdent是一种主要用于定向越野赛事的电子打卡系统。

Sireader支持两种主要操作模式。它可以用于完整的卡片读取,或作为控制站模式从控制台发送打卡。第一种模式通常用于终点线后的卡片读取,将卡片数据读入赛事软件。第二种模式用于从中途控制站获取实时结果。

网站: http://bosco.durcheinandertal.ch/

GIT仓库: https://github.com/gaudenz/sireader/

使用

sireader模块中有3个类。 SIReader 是包含常用函数的基类。导入它以便轻松访问其常量。 SIReaderReadout 实现了传统的卡片读取。 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仓库中的版本。

项目详情


下载文件

下载适合您平台的文件。如果您不确定选择哪个,请了解更多关于安装包的信息。

源代码发行版

sireader-1.1.3.tar.gz (27.1 kB 查看哈希值)

上传时间 源代码

构建发行版

sireader-1.1.3-py2.py3-none-any.whl (26.7 kB 查看哈希值)

上传时间 Python 2 Python 3

支持者