Commit 2310faea authored by Kentaro Hayashi's avatar Kentaro Hayashi

New upstream version 0.1.0

parent 8bcd4b38
......@@ -6,8 +6,8 @@ Takashi Sakamoto
## Introduction
This batch of Python 3 codes consists of modules and scripts to control
Audio and Music units on IEEE 1394 bus, with PyGObject to use libhinawa
APIs with a help of gobject-introspection.
Audio and Music units on IEEE 1394 bus, with a help of PyGObject for
gobject-introspection to libhinawa APIs.
The modules include applications of below specifications:
......@@ -18,7 +18,7 @@ The modules include applications of below specifications:
(Sep. 2004, 1394 Trade Association)
* AV/C Audio Subunit Specification 1.0 (Oct. 2000, 1394 Trade Association)
* AV/C Connection and Compatibility Management Specification 1.1
(Mar. 2003, 1394 Trade Associtation)
(Mar. 2003, 1394 Trade Association)
* Configuration ROM for AV/C Devices 1.0 (Dec. 2000, 1394 Trade Association)
* AV/C Stream Format Information Specification 1.1 - Working draft
revision 0.5 (Apr. 2005, 1394 Trade Association)
......@@ -41,6 +41,8 @@ The modules include applications of below specifications:
* A lexer/parser of configuration ROM on IEEE 1394 bus
* hinawa-bebob-parser
* Plug structure parser for BeBoB firmware
* hinawa-alesis-io-cui
* CUI tool for Alesis iO|14 and iO|26
* hinawa-dg00x-cui
* CUI tool for Digidesign Digi 00x family
* hinawa-dice-common-cui
......@@ -77,7 +79,7 @@ The modules include applications of below specifications:
* https://docs.python.org/3/library/pathlib.html
* PyGObject
* https://gitlab.gnome.org/GNOME/pygobject
* libhinawa with gir support
* libhinawa 1.0.0 or later, with gir support
* https://github.com/takaswie/libhinawa
## License
......
#!/usr/bin/env python3
# SPDX-License-Identifier: GPL-3.0-or-later
# Copyright (C) 2018 Takashi Sakamoto
import sys
import signal
from time import sleep
from hinawa_utils.misc.cui_kit import CuiKit
from hinawa_utils.dice.alesis_io_unit import AlesisIoUnit
def handle_mixer_source_gain(unit, args):
dsts = unit.get_mixer_labels()
srcs = unit.get_mixer_src_labels()
ops = ('set', 'get')
chs = ('0', '1')
if len(args) >= 4:
dst, src, op, src_ch = args[0:4]
if dst in dsts and src in srcs and op in ops and src_ch in chs:
src_ch = int(src_ch)
if op == 'set' and len(args) >= 5:
db = float(args[4])
unit.set_mixer_src_gain(dst, src, src_ch, db)
return True
elif op == 'get':
db = unit.get_mixer_src_gain(dst, src, src_ch)
print('{0:.3f}'.format(db))
return True
print('Arguments for mixer-source-gain')
print(' mixer-source-gain DST SRC OP SRC_CH [DB]')
print(' DST: [{0}]'.format('|'.join(dsts)))
print(' SRC: [{0}]'.format('|'.join(srcs)))
print(' OP: [{0}]'.format('|'.join(ops)))
print(' SRC_CH: [{0}]'.format('|'.join(chs)))
print(' DB: [-60.00-0.00]')
return False
def handle_mixer_source_panning(unit, args):
dsts = unit.get_mixer_labels()
srcs = unit.get_mixer_src_labels()
ops = ('set', 'get')
chs = ('0', '1')
if len(args) >= 4:
dst, src, op, src_ch = args[0:4]
if src in srcs and dst in dsts and src_ch in chs and op in ops:
src_ch = int(src_ch)
if op == 'set' and len(args) >= 5:
balance = float(args[4])
unit.set_mixer_src_balance(dst, src, src_ch, balance)
return True
elif op == 'get':
balance = unit.get_mixer_src_balance(dst, src, src_ch)
print('{:.3f}'.format(balance))
return True
print('Arguments for mixer-source-panning')
print(' mixer-source-panning DST SRC OP SRC_CH [BALANCE]')
print(' DST: [{0}]'.format('|'.join(dsts)))
print(' SRC: [{0}]'.format('|'.join(srcs)))
print(' OP: [{0}]'.format('|'.join(ops)))
print(' SRC_CH: [{0}]'.format('|'.join(chs)))
print(' BALANCE:[0.0-100.0]')
return False
def handle_mixer_source_link(unit, args):
dsts = unit.get_mixer_labels()
srcs = unit.get_mixer_src_labels()
ops = ('set', 'get')
links = ('False', 'True')
if len(args) >= 3:
dst, src, op = args[0:3]
if dst in dsts and src in srcs and op in ops:
if op == 'set' and len(args) >= 4:
link = args[3] == 'True'
unit.set_mixer_src_link(dst, src, link)
return True
elif op == 'get':
print(unit.get_mixer_src_link(dst, src))
return True
print('Arguments for mixer-source-link')
print(' mixer-source-link DST SRC OP [LINK]')
print(' DST: [{0}]'.format('|'.join(dsts)))
print(' SRC: [{0}]'.format('|'.join(srcs)))
print(' OP: [{0}]'.format('|'.join(ops)))
print(' LINK: [{0}]'.format('|'.join(links)))
return False
def handle_mixer_source_mute(unit, args):
dsts = unit.get_mixer_labels()
srcs = unit.get_mixer_src_labels()
ops = ('set', 'get')
chs = ('0', '1')
if len(args) >= 4:
dst, src, op, src_ch = args[0:4]
if src in srcs and dst in dsts and src_ch in chs and op in ops:
src_ch = int(src_ch)
if op == 'set' and len(args) >= 5:
mute = args[4] == 'True'
unit.set_mixer_src_mute(dst, src, src_ch, mute)
return True
elif op == 'get':
print(unit.get_mixer_src_mute(dst, src, src_ch))
return True
print('Arguments for mixer-source-mute')
print(' mixer-source-mute DST SRC OP SRC_CH [MUTE]')
print(' DST: [{0}]'.format('|'.join(dsts)))
print(' SRC: [{0}]'.format('|'.join(srcs)))
print(' OP: [{0}]'.format('|'.join(ops)))
print(' SRC_CH: [{0}]'.format('|'.join(chs)))
print(' MUTE: [False|True]')
return False
def handle_enable_spdif_source(unit, args):
ops = ('set', 'get')
enables = ('False', 'True')
if len(args) >= 1:
op = args[0]
if op == 'set' and len(args) >= 2:
enable = args[1] == 'True'
unit.set_mixer_spdif_src(enable)
return True
elif op == 'get':
print(unit.get_mixer_spdif_src())
return True
print('Arguments for enable-spdif-source:')
print(' enable-spdif-source OP [ENABLE]')
print(' OP: [{0}]'.format('|'.join(ops)))
print(' ENABLE: [{0}]'.format('|'.join(enables)))
return False
def handle_mixer_out_volume(unit, args):
targets = unit.get_mixer_labels()
ops = ('set', 'get')
chs = ('0', '1')
if len(args) >= 3:
target, op, ch = args[0:3]
if target in targets and op in ops and ch in chs:
ch = int(ch)
if len(args) >= 4 and op == 'set':
db = float(args[3])
unit.set_mixer_out_volume(target, ch, db)
return True
elif op == 'get':
db = unit.get_mixer_out_volume(target, ch)
print('{:.3f}'.format(db))
return True
print('Arguments for mixer-out-volume command:')
print(' mixer-out-volume TARGET OP CH [GAIN]')
print(' TARGET: [{0}]'.format('|'.join(targets)))
print(' OP: [{0}]'.format('|'.join(ops)))
print(' CH: [{0}]'.format('|'.join(chs)))
print(' dB: [-60.00-0.00]')
return False
def handle_mixer_out_level(unit, args):
targets = unit.get_mixer_labels()
ops = ('set', 'get')
chs = ('0', '1')
levels = unit.get_level_labels()
if len(args) >= 3:
target, op, ch = args[0:3]
if target in targets and op in ops and ch in chs:
ch = int(ch)
if len(args) >= 4 and op == 'set' and args[3] in levels:
level = args[3]
unit.set_mixer_out_level(target, ch, level)
return True
elif op == 'get':
print(unit.get_mixer_out_level(target, ch))
return True
print('Arguments for mixer-out-level command:')
print(' mixer-out-level TARGET OP CH [LEVEL]')
print(' TARGET: [{0}]'.format('|'.join(targets)))
print(' OP: [{0}]'.format('|'.join(ops)))
print(' CH: [{0}]'.format('|'.join(chs)))
print(' LEVEL: [{0}]'.format('|'.join(unit.get_level_labels())))
return False
def handle_mixer_out_mute(unit, args):
targets = unit.get_mixer_labels()
ops = ('set', 'get')
chs = ('0', '1')
mutes = ('False', 'True')
levels = unit.get_level_labels()
if len(args) >= 3:
target, op, ch = args[0:3]
if target in targets and op in ops and ch in chs:
ch = int(ch)
if len(args) >= 4 and op == 'set' and args[3] in mutes:
mute = args[3] == 'True'
unit.set_mixer_out_mute(target, ch, mute)
return True
elif op == 'get':
print(unit.get_mixer_out_mute(target, ch))
return True
print('Arguments for mixer-out-mute command:')
print(' mixer-out-mute TARGET OP CH [MUTE]')
print(' TARGET: [{0}]'.format('|'.join(targets)))
print(' OP: [{0}]'.format('|'.join(ops)))
print(' CH: [{0}]'.format('|'.join(chs)))
print(' MUTE: [True|False]')
return False
def handle_output_source(unit, args):
targets = unit.get_output_labels()
ops = ('set', 'get')
if len(args) >= 2:
target, op = args[0:2]
if target in targets and op in ops:
srcs = unit.get_output_src_labels(target)
if len(args) >= 3 and args[2] in srcs:
src = args[2]
unit.set_output_src(target, src)
return True
elif op == 'get':
print(unit.get_output_src(target))
return True
print('Arguments for output-source command:')
print(' output-source TARGET OP [SRC]')
print(' TARGET: [{0}]'.format('|'.join(targets)))
print(' OP: [{0}]'.format('|'.join(ops)))
for target in targets:
labels = unit.get_output_src_labels(target)
if len(labels) == 1:
print(' SRC: {0} is fixed to TARGET={1}'.format(labels[0], target))
else:
print(' SRC: [{0}] if TARGET={1} and OP=set'.format('|'.join(labels), target))
return False
def handle_listen_metering(unit, args):
labels = unit.get_meter_labels()
signal.signal(signal.SIGINT, lambda signum, frame: sys.exit())
while True:
meters = unit.get_meters()
for i, label in enumerate(labels):
print('{0}: {1:.3f} dB'.format(label, meters[i]))
print()
sleep(0.5)
return True
cmds = {
'mixer-source-gain': handle_mixer_source_gain,
'mixer-source-panning': handle_mixer_source_panning,
'mixer-source-link': handle_mixer_source_link,
'mixer-source-mute': handle_mixer_source_mute,
'mixer-out-volume': handle_mixer_out_volume,
'mixer-out-level': handle_mixer_out_level,
'mixer-out-mute': handle_mixer_out_mute,
'output-source': handle_output_source,
'listen-metering': handle_listen_metering,
}
fullpath = CuiKit.seek_snd_unit_path()
if fullpath:
unit = AlesisIoUnit(fullpath)
if unit.name == 'iO|26':
cmds['use-spdif-source'] = handle_enable_spdif_source
CuiKit.dispatch_command(unit, cmds)
......@@ -5,6 +5,7 @@
import sys
import errno
from pprint import PrettyPrinter
from struct import unpack
from hinawa_utils.ieee1212.config_rom_lexer import Ieee1212ConfigRomLexer
from hinawa_utils.ieee1394.config_rom_parser import Ieee1394ConfigRomParser
......@@ -27,6 +28,7 @@ else:
print('Invalid operation: {0}'.format(sys.argv[2]))
sys.exit()
# For Echo Audio Fireworks series.
def handle_echoaudio_keys(key_id, type_name, data):
OUI_COMPANIES = {
0x000ff2: 'Loud Technologies Inc.',
......@@ -41,6 +43,7 @@ def handle_echoaudio_keys(key_id, type_name, data):
return None
# For Apple iSight.
def handle_iidc_v1_30_keys(key_id, type_name, data):
if key_id == 0x00 and type_name == 'CSR_OFFSET':
return ['IIDC_COMMAND_REGS_BASE', data]
......@@ -68,12 +71,14 @@ def handle_isight_iris_keys(key_id, type_name, data):
return ['ISIGHT_IRIS_REGS_BASE', data]
return None
# For TASCAM FireWire series.
def handle_teac_keys(key_id, type_name, data):
if key_id == 0x02 and type_name == 'LEAF':
content = data[8:].decode('US-ASCII') + '\0'
return ['MODEL_NAME', content[:content.find('\0')]]
return None
# For Digidesign Digi 00x series.
def handle_microsoft_keys(key_id, type_name, data):
if key_id == 0x01 and type_name == 'LEAF':
width = data[0] >> 4
......@@ -88,6 +93,32 @@ def handle_microsoft_keys(key_id, type_name, data):
return None
# For Cool Stream iSweet.
def handle_ame_root_keys(key_id, type_name, data):
if key_id == 0x06 and type_name == 'IMMEDIATE':
return ['DEVICE_ID', data]
return None
def handle_iidc_v1_04_keys(key_id, type_name, data):
if key_id == 0x00 and type_name == 'CSR_OFFSET':
return ['COMMAND_REGS_BASE', data]
return None
def handle_ame_unit_dep_keys(key_id, type_name, data):
if key_id == 0x02 and type_name == 'LEAF':
descriptor_type = data[0]
specifier_id = (data[1] << 16) | unpack('>H', data[2:4])[0]
if descriptor_type != 0x00 or specifier_id != 0x00:
raise ValueError('Invalid data in vendor-dep descriptor leaf.')
width = data[4] >> 4
character_set = ((data[4] & 0x0f) << 8) | data[5]
language = unpack('>H', data[6:8])[0]
if character_set != 0x00 or language != 0x00:
raise ValueError('Invalid data in descriptor leaf.')
content = data[8:].decode('US-ASCII') + '\0'
return ['MODEL_NAME', content[:content.find('\0')]]
return None
pp = PrettyPrinter(indent=2, compact=False)
unit = Hinawa.FwUnit()
......@@ -109,5 +140,8 @@ else:
parser.add_spec_dep_handle(0x00022e, 0x800003, handle_teac_keys)
parser.add_spec_dep_handle(0x00022e, 0x800004, handle_teac_keys)
parser.add_vendor_dep_handle(0x0050f2, handle_microsoft_keys)
parser.add_spec_dep_handle(0x00a02d, 0x000100, handle_iidc_v1_04_keys)
parser.add_spec_dep_handle(0x00a02d, 0x000100, handle_ame_unit_dep_keys)
parser.add_vendor_dep_handle(0x0002f0, handle_ame_root_keys)
info = parser.parse_rom(data)
pp.pprint(info)
......@@ -2,6 +2,10 @@
# SPDX-License-Identifier: GPL-3.0-or-later
# Copyright (C) 2018 Takashi Sakamoto
import signal
from gi.repository import GLib
from hinawa_utils.misc.cui_kit import CuiKit
from hinawa_utils.dg00x.dg00x_unit import Dg00xUnit
......@@ -20,8 +24,8 @@ def handle_clock_source(unit, args):
return True
print('Arguments for clock-source command:')
print(' clock-source OPERATION [SOURCE]')
print(' OPERATION: {0}'.format(', '.join(ops)))
print(' SOURCE: {0}'.format(', '.join(unit.supported_clock_sources)))
print(' OPERATION: {0}'.format('|'.join(ops)))
print(' SOURCE: {0}'.format('|'.join(unit.SUPPORTED_CLOCK_SOURCES)))
return False
def handle_sampling_rate(unit, args):
......@@ -39,9 +43,9 @@ def handle_sampling_rate(unit, args):
return True
print('Arguments for sampling-rate command:')
print(' sampling-rate OPERATION [RATE]')
print(' OPERATION: {0}'.format(', '.join(ops)))
rates = [str(r) for r in unit.supported_sampling_rates]
print(' RATE: {0}'.format(', '.join(rates)))
print(' OPERATION: {0}'.format('|'.join(ops)))
rates = [str(r) for r in unit.SUPPORTED_SAMPLING_RATES]
print(' RATE: {0}'.format('|'.join(rates)))
return False
def handle_mixer_mode(unit, args):
......@@ -56,7 +60,7 @@ def handle_mixer_mode(unit, args):
return True
print('Arguments for mixer-mode command:')
print(' sampling-rate OPERATION [MODE]')
print(' OPERATION: {0}'.format(', '.join(ops)))
print(' OPERATION: {0}'.format('|'.join(ops)))
print(' MODE: 0, 1')
return False
......@@ -75,14 +79,11 @@ def handle_opt_iface(unit, args):
return True
print('Arguments for optical-interface command:')
print(' optical-interface OPERATION [MODE]')
print(' OPERATION: {0}'.format(', '.join(ops)))
print(' MODE: {0}'.format(', '.join(
unit.supported_optical_interfaces)))
print(' OPERATION: {0}'.format('|'.join(ops)))
print(' MODE: {0}'.format('|'.join(unit.SUPPORTED_OPTICAL_INTERFACES)))
return False
def handle_listen_message(self, args):
from gi.repository import GLib
import signal
loop = GLib.MainLoop()
def handle_unix_signal():
loop.quit()
......
......@@ -94,6 +94,7 @@ def handle_clock_source(unit, args):
print(' clock-source OPERATION [SOURCE]')
print(' OP: [{0}]'.format('|'.join(ops)))
print(' SOURCE: [{0}]'.format('|'.join(sources)))
return False
def handle_nickname(unit, args):
ops = ('set', 'get')
......@@ -108,6 +109,7 @@ def handle_nickname(unit, args):
print('Arguments for nickname command:')
print(' nickname OPERATION [SOURCE]')
print(' OPERATION: {0}'.format(', '.join(ops)))
return False
cmds = {
'current-status': handle_current_status,
......
This diff is collapsed.
This diff is collapsed.
......@@ -38,7 +38,7 @@ def handle_output_volume(unit, args):
data)
else:
data = AvcAudio.get_feature_volume_state(unit.fcp, 0, 'current', 1,
0))
0)
print(AvcAudio.parse_data_to_db(data))
return True
print('Arguments for output-volume command:')
......
......@@ -11,14 +11,14 @@ from hinawa_utils.misc.cui_kit import CuiKit
from hinawa_utils.bebob.maudio_unit import MaudioUnit
def _handle_target_volume(unit, args, cmd, targets_func, set_func, get_func):
CHS = (0, 1)
OPS = ('set', 'get')
chs = (0, 1)
ops = ('set', 'get')
targets = targets_func()
if len(args) >= 1 and args[0] in targets:
target = args[0]
if len(args) >= 2 and int(args[1]) in CHS:
if len(args) >= 2 and int(args[1]) in chs:
ch = int(args[1])
if len(args) >= 3 and args[2] in OPS:
if len(args) >= 3 and args[2] in ops:
op = args[2]
if op == 'set' and len(args) >= 4:
db = float(args[3])
......@@ -30,8 +30,8 @@ def _handle_target_volume(unit, args, cmd, targets_func, set_func, get_func):
print('Arguments for {0} command:'.format(cmd))
print(' {0} TARGET CH OP [dB]'.format(cmd))
print(' TARGET: [{0}]'.format('|'.join(targets)))
print(' CH: [{0}]'.format('|'.join(map(str, CHS))))
print(' OP: [{0}]'.format('|'.join(OPS)))
print(' CH: [{0}]'.format('|'.join(chs)))
print(' OP: [{0}]'.format('|'.join(ops)))
print(' dB: [-128.00..128.00] if OP=set')
return False
......@@ -60,14 +60,14 @@ def handle_headphone_volume(unit, args):
unit.protocol.get_headphone_volume)
def handle_input_balance(unit, args):
CHS = (0, 1)
OPS = ('set', 'get')
chs = (0, 1)
ops = ('set', 'get')
targets = unit.protocol.get_input_balance_labels()
if len(args) >= 1 and args[0] in targets:
target = args[0]
if len(args) >= 2 and int(args[1]) in CHS:
if len(args) >= 2 and int(args[1]) in chs:
ch = int(args[1])
if len(args) >= 3 and args[2] in OPS:
if len(args) >= 3 and args[2] in ops:
op = args[2]
if len(args) >= 4 and op == 'set':
balance = float(args[3])
......@@ -79,17 +79,17 @@ def handle_input_balance(unit, args):
print('Arguments for input-balance command')
print(' input-balance TARGET CH OP [BALANCE]')
print(' TARGET: [{0}]'.format('|'.join(targets)))
print(' CH: [{0}]'.format('|'.join(map(str, CHS))))
print(' OP: [{0}]'.format('|'.join(OPS)))
print(' CH: [{0}]'.format('|'.join(chs)))
print(' OP: [{0}]'.format('|'.join(ops)))
print(' BALANCE:[-128.0..128.0] (left-right) if OP=set')
return False
def handle_aux_balance(unit, args):
CHS = (0, 1)
OPS = ('set', 'get')
if len(args) >= 1 and int(args[0]) in CHS:
chs = (0, 1)
ops = ('set', 'get')
if len(args) >= 1 and int(args[0]) in chs:
ch = int(args[0])
if len(args) >= 2 and args[1] in OPS:
if len(args) >= 2 and args[1] in ops:
op = args[1]
if len(args) >= 3 and op == 'set':
balance = float(args[2])
......@@ -100,17 +100,17 @@ def handle_aux_balance(unit, args):
return True
print('Arguments for aux-balance command:')
print(' aux-balance CH OP [BALANCE]')
print(' CH: [{0}]'.format('|'.join(map(str, CHS))))
print(' OP: [{0}]'.format('|'.join(OPS)))
print(' CH: [{0}]'.format('|'.join(chs)))
print(' OP: [{0}]'.format('|'.join(ops)))
print(' BALACE: [-128.0..128.0] (left-right) if OP=set]')
return False
def handle_aux_volume(unit, args):
CHS = (0, 1)
OPS = ('set', 'get')
if len(args) > 0 and int(args[0]) in CHS:
chs = (0, 1)
ops = ('set', 'get')
if len(args) > 0 and int(args[0]) in chs:
ch = int(args[0])
if len(args) > 1 and args[1] in OPS:
if len(args) > 1 and args[1] in ops:
op = args[1]
if len(args) > 2 and op == 'set':
db = float(args[2])
......@@ -121,20 +121,20 @@ def handle_aux_volume(unit, args):
return True
print('Arguments for aux-volume command:')
print(' aux-volume CH OP [dB]')
print(' CH: [{0}]'.format('|'.join(map(str, CHS))))
print(' OP: [{0}]'.format('|'.join(OPS)))
print(' CH: [{0}]'.format('|'.join(chs)))
print(' OP: [{0}]'.format('|'.join(ops)))
print(' dB: [-128.0..128.0] if OP=set')
return False
def handle_mixer_routing(unit, args):
OPS = ('set', 'get')
ops = ('set', 'get')
targets = unit.protocol.get_mixer_labels()
sources = unit.protocol.get_mixer_source_labels()
if len(args) >= 1 and args[0] in targets:
target = args[0]
if len(args) >= 2 and args[1] in sources:
source = args[1]
if len(args) >= 3 and args[2] in OPS:
if len(args) >= 3 and args[2] in ops:
op = args[2]
if len(args) >= 4 and op == 'set':
enable = bool(int(args[3]))
......@@ -147,17 +147,17 @@ def handle_mixer_routing(unit, args):
print(' mixer-routing TARGET SOURCE [ENABLE]')
print(' TARGET: [{0}]'.format('|'.join(targets)))
print(' SOURCE: [{0}]'.format('|'.join(sources)))
print(' OP: [{0}]'.format('|'.join(OPS)))
print(' OP: [{0}]'.format('|'.join(ops)))
print(' ENABLE: [0|1]')
return False
def _handle_target_source(unit, args, cmd, targets_func, sources_func,
set_func, get_func):
OPS = ('set', 'get')
ops = ('set', 'get')
targets = targets_func()
if len(args) >= 1 and args[0] in targets:
target = args[0]
if len(args) >= 2 and args[1] in OPS:
if len(args) >= 2 and args[1] in ops:
op = args[1]
sources = sources_func(target)
if len(args) >= 3 and op == 'set' and args[2] in sources:
......@@ -170,7 +170,7 @@ def _handle_target_source(unit, args, cmd, targets_func, sources_func,
print('Arguments for {0} command:'.format(cmd))
print(' {0} TARGET OP [SRC]'.format(cmd))
print(' TARGET: [{0}]'.format('|'.join(targets)))
print(' OP: [{0}]'.format('|'.join(OPS)))
print(' OP: [{0}]'.format('|'.join(ops)))
for target in targets:
sources = sources_func(target)
print(' SRC: [{0}] if TARGET={1} and OP=set'.format(
......@@ -192,9 +192,9 @@ def handle_output_source(unit, args):
unit.protocol.get_output_source)
def handle_clock_source(unit, args):
OPS = ('set', 'get')
ops = ('set', 'get')
sources = unit.protocol.get_clock_source_labels()
if len(args) > 0 and args[0] in OPS:
if len(args) > 0 and args[0] in ops:
op = args[0]
if len(args) > 1 and op == 'set' and args[1] in sources:
source = args[1]
......@@ -205,7 +205,7 @@ def handle_clock_source(unit, args):
return True
print('Arguments for clock-source command:')
print(' clock-source OP [SRC]')
print(' OP: {0}'.format('|'.join(OPS)))
print(' OP: {0}'.format('|'.join(ops)))
print(' SRC: {0} if OP=set'.format('|'.join(sources)))
print(' Packet streaming should be stopped.')
return False
......@@ -228,9 +228,9 @@ def handle_listen_metering(unit, args):
return True
def handle_sampling_rate(unit, args):
OPS = ('set', 'get')
ops = ('set', 'get')
rates = unit.protocol.get_sampling_rate_labels()
if len(args) >= 1 and args[0] in OPS:
if len(args) >= 1 and args[0] in ops:
op = args[0]
if len(args) >= 2 and op == 'set':
rate = int(args[1])
......@@ -241,7 +241,7 @@ def handle_sampling_rate(unit, args):
return True
print('Arguments for sampling-rate command:')
print(' sampling-rate OP [RATE]')
print(' OP: {0}'.format('|'.join(OPS)))
print(' OP: {0}'.format('|'.join(ops)))
print(' RATE: {0}'.format('|'.join(map(str, rates))))
return False
......
......@@ -2,9 +2,13 @@
# SPDX-License-Identifier: GPL-3.0-or-later
# Copyright (C) 2018 Takashi Sakamoto
import signal
from hinawa_utils.misc.cui_kit import CuiKit
from hinawa_utils.motu.motu_unit import MotuUnit
from gi.repository import GLib
def handle_opt_iface_mode(uniit, args):
ops = ('set', 'get')
if len(args) > 2 and args[0] in ops:
......@@ -19,13 +23,13 @@ def handle_opt_iface_mode(uniit, args):
return True
print('Arguments for optical input interface mode:')
print(' opt-iface-mode OPERATION DIRECTION INDEX [MODE]')
print(' OPERATION: {0}'.format(', '.join(ops)))
print(' OPERATION: [{0}]'.format('|'.join(ops)))
directions = [str(d) for d in unit.get_supported_opt_iface_directions()]
print(' DIRECTION: {0}'.format(', '.join(directions)))
print(' DIRECTION: [{0}]'.format('|'.join(directions)))
indexes = [str(i) for i in unit.get_opt_iface_indexes()]
print(' INDEX: {0}'.format(', '.join(indexes)))
print(' INDEX: [{0}]'.format('|'.join(indexes)))
modes = [str(m) for m in unit.get_opt_iface_modes()]
print(' MODE: {0}'.format(', '.join(modes)))
print(' MODE: [{0}]'.format('|'.join(modes)))
return False
def handle_sampling_rate(unit, args):
......@@ -40,9 +44,9 @@ def handle_sampling_rate(unit, args):
return True
print('Arguments for sampling-rate command:')
print(' sampling-rate OPERATION [RATE]')
print(' OPERATION: {0}'.format(', '.join(ops)))
print(' OPERATION: [{0}]'.format('|'.join(ops)))