Thank you for your donation!


Cloudsmith graciously provides open-source package management and distribution for our project.


HifiBerry DAC2 HD support
#25
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 :

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
Reply


Messages In This Thread
HifiBerry DAC2 HD support - by mystic - 01-17-2021, 06:14 PM
RE: HifiBerry DAC2 HD support - by TeronG - 01-18-2021, 11:29 AM
RE: HifiBerry DAC2 HD support - by Marrahm - 01-21-2021, 12:47 AM
RE: HifiBerry DAC2 HD support - by mystic - 01-21-2021, 05:44 PM
RE: HifiBerry DAC2 HD support - by Marrahm - 01-21-2021, 08:42 PM
RE: HifiBerry DAC2 HD support - by DRONE7 - 01-21-2021, 05:22 AM
RE: HifiBerry DAC2 HD support - by Marrahm - 01-21-2021, 09:43 PM
RE: HifiBerry DAC2 HD support - by Soundnub - 03-04-2021, 01:55 PM
RE: HifiBerry DAC2 HD support - by gregvds - 02-23-2021, 12:11 PM
RE: HifiBerry DAC2 HD support - by gregvds - 02-25-2021, 01:14 PM
RE: HifiBerry DAC2 HD support - by Marrahm - 02-25-2021, 02:05 PM
RE: HifiBerry DAC2 HD support - by gregvds - 02-25-2021, 03:56 PM
RE: HifiBerry DAC2 HD support - by agaufres - 02-26-2021, 07:23 PM
RE: HifiBerry DAC2 HD support - by Marrahm - 02-26-2021, 07:38 PM
RE: HifiBerry DAC2 HD support - by Marrahm - 03-04-2021, 02:05 PM
RE: HifiBerry DAC2 HD support - by Soundnub - 03-04-2021, 02:43 PM
RE: HifiBerry DAC2 HD support - by Marrahm - 03-04-2021, 03:09 PM
RE: HifiBerry DAC2 HD support - by Soundnub - 03-04-2021, 07:51 PM
RE: HifiBerry DAC2 HD support - by Marrahm - 03-04-2021, 09:04 PM
RE: HifiBerry DAC2 HD support - by Soundnub - 03-12-2021, 12:49 PM
RE: HifiBerry DAC2 HD support - by agaufres - 03-04-2021, 05:31 PM
RE: HifiBerry DAC2 HD support - by agaufres - 03-04-2021, 07:40 PM
RE: HifiBerry DAC2 HD support - by Marrahm - 03-04-2021, 07:51 PM
RE: HifiBerry DAC2 HD support - by gregvds - 03-05-2021, 10:35 AM
RE: HifiBerry DAC2 HD support - by gregvds - 03-07-2021, 11:25 AM
RE: HifiBerry DAC2 HD support - by 3dcnc - 05-18-2021, 10:35 AM
RE: HifiBerry DAC2 HD support - by Tim Curtis - 05-18-2021, 10:39 AM
RE: HifiBerry DAC2 HD support - by Marrahm - 05-18-2021, 12:28 PM
RE: HifiBerry DAC2 HD support - by 3dcnc - 05-19-2021, 06:54 AM
RE: HifiBerry DAC2 HD support - by agaufres - 10-02-2021, 10:17 PM
RE: HifiBerry DAC2 HD support - by Tim Curtis - 10-02-2021, 10:54 PM

Forum Jump: