pyinterface : Interface PCI ボードドライバ

これは何か

  • pyinterface は、株式会社 Interface が提供するPCIボードのLinux/Python向けドライバです (pyinterfaceはInterface社とは関係ありません)
  • PCIのI/Oポートに直接アクセスするため、公式のドライバを使わずに動作します
    • 公式ドライバではサポート外の最新のLinuxディストリビューションでも利用可能です
    • I/Oポートアクセスに PortIO モジュールを使用しています

動作環境

  • Linux (x86 architecture)
  • Python 3.0+

必要なモジュール

使い方

インストール方法

pip install pyinterface

初めの一歩

pyinterface では、PCIのI/Oポートに直接アクセスするために、iopl を使用するため、root権限を必要とします。以下の例は、sudo ipython などとしてroot権限で実行してください。

import pyinterface

board_name = 2724  # 使用するボードの型番 : 例. PCI/CPZ-2724 (DIOボード)
rsw_id = 2         # 本体ボードに設定しているRSW1の番号 : 例. 2 を設定している

# ボードを open
b = pyinterface.open(board_name, rsw_id)

# digital input 状況を取得
b.input_byte('IN1_8')
>>> [0, 0, 0, 0, 0, 0, 0, 0]

# digital output を設定
b.output_byte([0, 1, 0, 1, 0, 0, 1, 1], 'OUT25_32')
>>> 000000CA

ボード別の使用方法

以下のボードについて、ドライバを提供しています。

API ドキュメント

pyinterface package

Submodules

pyinterface.core module
pyinterface.core.bit2bytes(bit_str)
pyinterface.core.bytes2bit(bytes_data)
pyinterface.core.bytes2list(bytes_data)
class pyinterface.core.flagged_bytes(bytes, bit_flag=(), fmt='')

ベースクラス: object

bit_flag = ()
bytes = b''
fmt = ''
print()
set_flag(flag)
set_fmt(fmt)
to_bit()
to_dictlist()
to_flags()
to_float()
to_hex()
to_int()
to_list()
to_uint()
unpack(fmt='')
class pyinterface.core.interface_driver(pci_config)

ベースクラス: object

bar = []
bit_flags_in = ()
bit_flags_out = ()
board_id = -1
config = None
get_board_id()
get_log(in_out, bar_num, offset)
log_bytes_in = []
log_bytes_out = []
read(bar_num, offset, size)
set_flag(bar_num, offset, flag)
write(bar_num, offset, data)
pyinterface.core.list2bytes(bit_list)
pyinterface.pci2724 module

PCI/CPZ-2724 DIO ボードのドライバです。

class pyinterface.pci2724.pci2724_driver(pci_config)

ベースクラス: pyinterface.core.interface_driver

available_input_byte_ranges = ['IN1_8', 'IN9_16', 'IN17_24', 'IN25_32']
available_input_dword_ranges = ['IN1_32']
available_input_word_ranges = ['IN1_16', 'IN17_32']
available_output_byte_ranges = ['OUT1_8', 'OUT9_16', 'OUT17_24', 'OUT25_32']
available_output_dword_ranges = ['OUT1_32']
available_output_word_ranges = ['OUT1_16', 'OUT17_32']
bit_flags_in = ((('IN1', 'IN2', 'IN3', 'IN4', 'IN5', 'IN6', 'IN7', 'IN8'), ('IN9', 'IN10', 'IN11', 'IN12', 'IN13', 'IN14', 'IN15', 'IN16'), ('IN17', 'IN18', 'IN19', 'IN20', 'IN21', 'IN22', 'IN23', 'IN24'), ('IN25', 'IN26', 'IN27', 'IN28', 'IN29', 'IN30', 'IN31', 'IN32'), ('', '', '', '', '', '', '', ''), ('', '', '', '', '', '', '', ''), ('', '', '', '', '', '', '', ''), ('', '', '', '', '', '', '', ''), ('IRIN2', '', '', '', '', 'STB2', 'ACKR2', 'ACK2'), ('IRIN1', '', '', '', 'LF', 'ACK1', 'STBR1', 'STB1'), ('TD1', 'TD2', 'TD3', 'TD4', '', '', '', ''), ('PORT0', 'PORT1', 'PORT2', 'PORT3', '', '', '', ''), ('SIG1', 'SIG2', 'SIG3', 'SIG4', 'SIGT', 'SIGR', 'SIGRR', ''), ('SIG1', 'SIG2', 'SIG3', 'SIG4', 'SIGT', 'SIGR', '', ''), ('SIG1', 'SIG2', 'SIG3', 'SIG4', 'EDS1', 'EDS2', 'EDS3', 'EDS4'), ('BID0', 'BID1', 'BID2', 'BID3', '', '', '', '')),)
bit_flags_out = ((('OUT1', 'OUT2', 'OUT3', 'OUT4', 'OUT5', 'OUT6', 'OUT7', 'OUT8'), ('OUT9', 'OUT10', 'OUT11', 'OUT12', 'OUT13', 'OUT14', 'OUT15', 'OUT16'), ('OUT17', 'OUT18', 'OUT19', 'OUT20', 'OUT21', 'OUT22', 'OUT23', 'OUT24'), ('OUT25', 'OUT26', 'OUT27', 'OUT28', 'OUT29', 'OUT30', 'OUT31', 'OUT32'), ('', '', '', '', '', '', '', ''), ('', '', '', '', '', '', '', ''), ('', '', '', '', '', '', '', ''), ('', '', '', '', '', '', '', ''), ('', '', '', 'PO10', 'PO11', 'PO12', 'ACK10', 'ACK11'), ('', '', '', 'PO20', 'PO21', 'PO22', 'STB20', 'STB21'), ('TCTRL1', 'TCTRL2', 'TCTRL3', 'TCTRL4', 'SCK1', 'SCK2', 'SCK3', ''), ('PORT0', 'PORT1', 'PORT2', 'PORT3', '', '', '', ''), ('SIG1', 'SIG2', 'SIG3', 'SIG4', 'SIGT', 'SIGR', '', ''), ('SIG1', 'SIG2', 'SIG3', 'SIG4', 'SIGT', 'SIGR', '', ''), ('SIG1', 'SIG2', 'SIG3', 'SIG4', 'EDS1', 'EDS2', 'EDS3', 'EDS4'), ('', '', '', '', '', '', '', '')),)
get_ack_status()
get_board_id()
get_latch_status()
get_reset_in_status()
get_stb_status()
initialize()
input_byte(range_)
input_dword(range_)
input_point(start, num)
input_word(range_)
num_input = 64
num_output = 64
output_byte(range_, data)
output_dword(range_, data)
output_point(data, start)
output_word(range_, data)
set_ack_pulse_command(ack='', pulse='')
set_latch_status(enable='')
set_stb_pulse_command(stb='', pulse='')
pyinterface.pci6204 module
exception pyinterface.pci6204.InvalidChannelError

ベースクラス: Exception

class pyinterface.pci6204.pci6204_driver(pci_config)

ベースクラス: pyinterface.core.interface_driver

available_ch = [1, 2]
bit_flags_in = ((('CD0', 'CD1', 'CD2', 'CD3', 'CD4', 'CD5', 'CD6', 'CD7'), ('CD8', 'CD9', 'CD10', 'CD11', 'CD12', 'CD13', 'CD14', 'CD15'), ('CD16', 'CD17', 'CD18', 'CD19', 'CD20', 'CD21', 'CD22', 'CD23'), ('CD24', 'CD25', 'CD26', 'CD27', 'CD28', 'CD29', 'CD30', 'CD31'), ('SEL0', 'SEL1', 'MD0', 'MD1', 'DIR', 'EQS', '', ''), ('A', 'B', 'Z', 'L1', 'L2', 'L3', '', ''), ('U/D', 'CBF', 'EQ', 'EXLTS', 'EQF', 'PERR', '', ''), ('', '', '', '', '', '', '', ''), ('L2', 'L3', 'EQ', 'EXLT', 'C/B', 'PERR', '', ''), ('L2', 'L3', 'EQ', 'EXLT', 'C/B', 'PERR', '', ''), ('', '', '', '', '', '', '', ''), ('', '', '', '', '', '', '', ''), ('', '', '', '', '', '', '', ''), ('', '', '', '', '', '', '', ''), ('', '', '', '', '', '', '', ''), ('', '', '', '', '', '', '', ''), ('CD0', 'CD1', 'CD2', 'CD3', 'CD4', 'CD5', 'CD6', 'CD7'), ('CD8', 'CD9', 'CD10', 'CD11', 'CD12', 'CD13', 'CD14', 'CD15'), ('CD16', 'CD17', 'CD18', 'CD19', 'CD20', 'CD21', 'CD22', 'CD23'), ('CD24', 'CD25', 'CD26', 'CD27', 'CD28', 'CD29', 'CD30', 'CD31'), ('SEL0', 'SEL1', 'MD0', 'MD1', 'DIR', 'EQS', '', ''), ('A', 'B', 'Z', 'L1', 'L2', 'L3', '', ''), ('U/D', 'CBF', 'EQ', 'EXLTS', 'EQF', 'PERR', '', ''), ('', '', '', '', '', '', '', ''), ('L2', 'L3', 'EQ', 'EXLT', 'C/B', 'PERR', '', ''), ('L2', 'L3', 'EQ', 'EXLT', 'C/B', 'PERR', '', ''), ('', '', '', '', '', '', '', ''), ('', '', '', '', '', '', '', ''), ('', '', '', '', '', '', '', ''), ('', '', '', '', '', '', '', ''), ('', '', '', '', '', '', '', ''), ('', '', '', '', '', '', '', '')), (('TD1', 'TD2', 'TD3', 'TD4', '', '', '', ''), ('', '', '', '', 'SIGT', '', '', ''), ('', '', '', '', 'SIGT', '', '', ''), ('', '', '', '', '', '', '', ''), ('', '', '', '', '', '', '', ''), ('', '', '', '', '', '', '', ''), ('', '', '', '', '', '', '', ''), ('', '', '', '', '', '', '', ''), ('', '', '', '', '', '', '', ''), ('', '', '', '', '', '', '', ''), ('', '', '', '', '', '', '', ''), ('', '', '', '', '', '', '', ''), ('', '', '', '', '', '', '', ''), ('', '', '', '', '', '', '', ''), ('', '', '', '', '', '', '', ''), ('BID0', 'BID1', 'BID2', 'BID3', '', '', '', '')))
bit_flags_out = ((('WD0', 'WD1', 'WD2', 'WD3', 'WD4', 'WD5', 'WD6', 'WD7'), ('WD8', 'WD9', 'WD10', 'WD11', 'WD12', 'WD13', 'WD14', 'WD15'), ('WD16', 'WD17', 'WD18', 'WD19', 'WD20', 'WD21', 'WD22', 'WD23'), ('WD24', 'WD25', 'WD26', 'WD27', 'WD28', 'WD29', 'WD30', 'WD31'), ('SEL0', 'SEL1', 'MD0', 'MD1', 'DIR', 'EQS', '', ''), ('P/L', '/EN', '', '', '', '', '', ''), ('CC0', 'CC1', '', '', '', '', '', ''), ('CLS0', 'CLS1', 'LTS0', 'LTS1', 'ZP', '', '', ''), ('', '', '', '', '', '', '', ''), ('L2', 'L3', 'EQ', 'EXLT', 'C/B', 'PERR', '', ''), ('', '', '', '', '', '', '', ''), ('', '', '', '', '', '', '', ''), ('', '', '', '', '', '', '', ''), ('', '', '', '', '', '', '', ''), ('', '', '', '', '', '', '', ''), ('', '', '', '', '', '', '', ''), ('WD0', 'WD1', 'WD2', 'WD3', 'WD4', 'WD5', 'WD6', 'WD7'), ('WD8', 'WD9', 'WD10', 'WD11', 'WD12', 'WD13', 'WD14', 'WD15'), ('WD16', 'WD17', 'WD18', 'WD19', 'WD20', 'WD21', 'WD22', 'WD23'), ('WD24', 'WD25', 'WD26', 'WD27', 'WD28', 'WD29', 'WD30', 'WD31'), ('SEL0', 'SEL1', 'MD0', 'MD1', 'DIR', 'EQS', '', ''), ('P/L', '/EN', '', '', '', '', '', ''), ('CC0', 'CC1', '', '', '', '', '', ''), ('CLS0', 'CLS1', 'LTS0', 'LTS1', 'ZP', '', '', ''), ('', '', '', '', '', '', '', ''), ('L2', 'L3', 'EQ', 'EXLT', 'C/B', 'PERR', '', ''), ('', '', '', '', '', '', '', ''), ('', '', '', '', '', '', '', ''), ('', '', '', '', '', '', '', ''), ('', '', '', '', '', '', '', ''), ('', '', '', '', '', '', '', ''), ('', '', '', '', '', '', '', '')), (('TCTRL1', 'TCTRL2', 'TCTRL3', 'TCTRL4', 'SCK1', 'SCK2', 'SCK3', ''), ('', '', '', '', '', '', '', ''), ('', '', '', '', 'SIGT', '', '', ''), ('', '', '', '', '', '', '', ''), ('', '', '', '', '', '', '', ''), ('', '', '', '', '', '', '', ''), ('', '', '', '', '', '', '', ''), ('', '', '', '', '', '', '', ''), ('', '', '', '', '', '', '', ''), ('', '', '', '', '', '', '', ''), ('', '', '', '', '', '', '', ''), ('', '', '', '', '', '', '', ''), ('', '', '', '', '', '', '', ''), ('', '', '', '', '', '', '', ''), ('', '', '', '', '', '', '', ''), ('', '', '', '', '', '', '', '')))
comparator = {1: 0, 2: 0}
disable_count(ch=1)
enable_count(ch=1)
get_board_id()
get_comparator(ch=1)
get_counter(ch=1)
get_mode(ch=1)
get_status(ch)
get_z_mode(ch=1)
initialize()
latch(ch=1)
latch_status = {1: 0, 2: 0}
reset(ch=1)
set_comparator(count, ch=1)
set_comparator_mode(ch=1)
set_counter(count, ch=1)
set_counter_mode(ch=1)
set_mode(mode='', direction=0, equal=0, latch=0, ch=1)
set_z_mode(clear_condition=None, latch_condition=None, z_polarity=None, l_polarity=None, ch=1)
pyinterface.tools module
pyinterface.tools.open(board_name, board_id)

Module contents