03-05-2021, 10:35 AM
(This post was last modified: 03-05-2021, 11:27 AM by gregvds.
Edit Reason: code formatting
)
If I reorder entries by id in cfg_audiodev, should I update the hash again? - Answered: yes!!!
I don't like that the new HiFiBerry DAC2 HD entry is at the back of the list, I'd rather prefer to find it with the other HiFiBerry entries, hence I'm in a small python script to do that :-). But once it's done, should the hash be updated?
Thanks
Edit:
ssh into your moode,
sudo nano /tmp/switchid.py
copy paste the code here under :
ctrl + x, enter to save and exit nano.
execute it like this:
python switchid.py -c 75 -n 47 (-c the current id of my entry in cfg_audiodev (HiFiBerry DAC2 HD), -n the place I want to find it in the list of devices in audio config GUI).
You'll have to recreate hash as explained by Mystic here on top of the thread like this:
sudo sqlite3 /var/local/www/db/moode-sqlite3.db "SELECT * FROM cfg_audiodev WHERE drvoptions NOT IN ('slave', 'glb_mclk') AND chipoptions = ''" > /tmp/moode-devices-new.txt
php -r 'echo md5(file_get_contents("/tmp/moode-devices-new.txt"));'
copy-paste the output, this should be something like this c8f05964fff3b968a21d09d0f57c1174
sudo sqlite3 /var/local/www/db/moode-sqlite3.db "DROP TRIGGER ro_columns"
sudo sqlite3 /var/local/www/db/moode-sqlite3.db "UPDATE cfg_hash SET value='YOUR_HASH_VALUE_HERE' WHERE id=8"
sudo sqlite3 /var/local/www/db/moode-sqlite3.db "CREATE TRIGGER ro_columns BEFORE UPDATE OF param, value, [action] ON cfg_hash FOR EACH ROW BEGIN SELECT RAISE(ABORT, 'read only'); END"
and then
sudo reboot
It worked for me on MoOde 7.0.1.
Pay attention that the python script assumes there is no entries with ID = currentId + 1000 value!!!
All the best,
Greg
I don't like that the new HiFiBerry DAC2 HD entry is at the back of the list, I'd rather prefer to find it with the other HiFiBerry entries, hence I'm in a small python script to do that :-). But once it's done, should the hash be updated?
Thanks
Edit:
ssh into your moode,
sudo nano /tmp/switchid.py
copy paste the code here under :
Code:
#!/usr/bin/python3
# This script helps to reorganize the entries in the cfg_audiodev to place a new
# entry at a given place in MoOde.
# this script assume there are no current ID + 1000 value in the table! You
# should check first this is true!
import sys, getopt, os
def main(argv):
currentId = ''
newId = ''
try:
opts, args = getopt.getopt(argv,"c:n:",["cid=","nid="])
except getopt.GetoptError:
print ('test.py -c <currentId> -n <newId>')
sys.exit(2)
for opt, arg in opts:
if opt == '-h':
print ('test.py -c <currentId> -n <newId>')
sys.exit()
elif opt in ("-c", "--cid"):
currentId = arg
elif opt in ("-n", "--nid"):
newId = arg
if currentId == '' or newId == '':
print ('test.py -c <currentId> -n <newId>')
sys.exit(2)
print ('Current ID is ', currentId)
print ('New ID is ', newId)
tempId = int(currentId) + 1000
command = os.popen('sudo sqlite3 /var/local/www/db/moode-sqlite3.db " UPDATE cfg_audiodev SET id = %s WHERE id = %s;"' % (tempId, currentId)).read()
print(command)
for id in range(int(currentId)-1, int(newId)-1, -1):
command = os.popen('sudo sqlite3 /var/local/www/db/moode-sqlite3.db " UPDATE cfg_audiodev SET id = %s WHERE id = %s;"' % (id+1, id)).read()
print(command)
command = os.popen('sudo sqlite3 /var/local/www/db/moode-sqlite3.db " UPDATE cfg_audiodev SET id = %s WHERE id = %s;"' % (newId, tempId)).read()
print(command)
if __name__ == "__main__":
main(sys.argv[1:])
ctrl + x, enter to save and exit nano.
execute it like this:
python switchid.py -c 75 -n 47 (-c the current id of my entry in cfg_audiodev (HiFiBerry DAC2 HD), -n the place I want to find it in the list of devices in audio config GUI).
You'll have to recreate hash as explained by Mystic here on top of the thread like this:
sudo sqlite3 /var/local/www/db/moode-sqlite3.db "SELECT * FROM cfg_audiodev WHERE drvoptions NOT IN ('slave', 'glb_mclk') AND chipoptions = ''" > /tmp/moode-devices-new.txt
php -r 'echo md5(file_get_contents("/tmp/moode-devices-new.txt"));'
copy-paste the output, this should be something like this c8f05964fff3b968a21d09d0f57c1174
sudo sqlite3 /var/local/www/db/moode-sqlite3.db "DROP TRIGGER ro_columns"
sudo sqlite3 /var/local/www/db/moode-sqlite3.db "UPDATE cfg_hash SET value='YOUR_HASH_VALUE_HERE' WHERE id=8"
sudo sqlite3 /var/local/www/db/moode-sqlite3.db "CREATE TRIGGER ro_columns BEFORE UPDATE OF param, value, [action] ON cfg_hash FOR EACH ROW BEGIN SELECT RAISE(ABORT, 'read only'); END"
and then
sudo reboot
It worked for me on MoOde 7.0.1.
Pay attention that the python script assumes there is no entries with ID = currentId + 1000 value!!!
All the best,
Greg