1 |
#!/usr/bin/python |
---|
2 |
|
---|
3 |
''' |
---|
4 |
This test is for checking a function to switch digital interface on devices |
---|
5 |
based on Echo Fireworks. Only two devices support this function, AudioFire8A |
---|
6 |
(as of July 2009) and AudioFirePre8. |
---|
7 |
|
---|
8 |
If no argument given, this script output current status. |
---|
9 |
If one argument given, this script try to set it. |
---|
10 |
|
---|
11 |
The value of argument is: |
---|
12 |
0: S/PDIF over coaxial digital interface |
---|
13 |
2: S/PDIF over optical digital interface |
---|
14 |
3: ADAT over optical digital interface |
---|
15 |
|
---|
16 |
The value '1' seems to be 'ADAT over coaxial digital interface'. But according |
---|
17 |
to users manual, these devices don't support this. I think there is no |
---|
18 |
specification to satisfy 'ADAT over coaxial digital interface'. |
---|
19 |
''' |
---|
20 |
|
---|
21 |
import sys |
---|
22 |
import dbus |
---|
23 |
|
---|
24 |
# Echo AudioFirePre8 |
---|
25 |
GUID = "0014860a5b6bdb9b" |
---|
26 |
# GUID = "001486085b68e02a" # Echo AudioFire8A |
---|
27 |
# GUID = "001486045B65D6E8" # Echo AudioFire8 |
---|
28 |
|
---|
29 |
servername = "org.ffado.Control" |
---|
30 |
path = "/org/ffado/Control/DeviceManager/%s/" % GUID |
---|
31 |
bus = dbus.SessionBus() |
---|
32 |
|
---|
33 |
# connect to ffado-dbus-server to ask hardware information |
---|
34 |
try: |
---|
35 |
hwinfo = dbus.Interface(bus.get_object(servername, |
---|
36 |
path + 'HwInfo/OpticalInterface'), |
---|
37 |
dbus_interface='org.ffado.Control.Element.Discrete') |
---|
38 |
except: |
---|
39 |
print "'ffado-dbus-server' should be started in advance." |
---|
40 |
sys.exit() |
---|
41 |
|
---|
42 |
# ask the device has optical digital interface |
---|
43 |
try: |
---|
44 |
if (not hwinfo.getValue()): |
---|
45 |
raise Exception() |
---|
46 |
except: |
---|
47 |
print "Your device just supports coaxial digital interface." |
---|
48 |
sys.exit() |
---|
49 |
|
---|
50 |
interface = dbus.Interface(bus.get_object(servername, |
---|
51 |
path + "DigitalInterface"), |
---|
52 |
dbus_interface='org.ffado.Control.Element.Discrete') |
---|
53 |
|
---|
54 |
argvs = sys.argv |
---|
55 |
argc = len(argvs) |
---|
56 |
|
---|
57 |
if (argc > 2): |
---|
58 |
print "too many arguments" |
---|
59 |
sys.exit() |
---|
60 |
elif (argc > 1): |
---|
61 |
param = int(argvs[1]) |
---|
62 |
if ((param == 1) or (param > 3)): |
---|
63 |
print "wrong argument. it should be:" |
---|
64 |
print "\t0(S/PDIF coaxial), 2(S/PDIF optical), or 3(ADAT optical)" |
---|
65 |
else: |
---|
66 |
print interface.setValue(param) |
---|
67 |
|
---|
68 |
else: |
---|
69 |
print interface.getValue() |
---|
70 |
|
---|