Amplifier Switch Plugin

Discuss, contribute and orient Volumio development!

Ads helps Volumio remain Free and Open Source. Please consider donating to help us continue to serve you.

Amplifier Switch Plugin

Postby Fightclub » Fri Mar 02 2018 16:32

spyking wrote:@Fightclub

I just ran into this error while trying to uninstall the plugin - Any ideas?
Code: Select all
Mar 01 18:14:21 volumio volumio[23345]: info: Starting Uninstall of plugin miscellanea - ampswitch
Mar 01 18:14:21 volumio volumio[23345]: info: Uninstalling plugin ampswitch
Mar 01 18:14:21 volumio volumio[23345]: info: PLUGIN STOP: ampswitch
Mar 01 18:14:21 volumio volumio[23345]: info: [ASDebug] Port: 14
Mar 01 18:14:21 volumio volumio[23345]: info: [ASDebug] Inverted: false
Mar 01 18:14:21 volumio volumio[23345]: info: [ASDebug] Delay: 720
Mar 01 18:14:21 volumio volumio[23345]: fs.js:610
Mar 01 18:14:21 volumio volumio[23345]: return binding.close(fd);
Mar 01 18:14:21 volumio volumio[23345]: ^
Mar 01 18:14:21 volumio volumio[23345]: Error: EBADF: bad file descriptor, close
Mar 01 18:14:21 volumio volumio[23345]: at Error (native)
Mar 01 18:14:21 volumio volumio[23345]: at Object.fs.closeSync (fs.js:610:18)
Mar 01 18:14:21 volumio volumio[23345]: at Object.<anonymous> (/volumio/node_modules/graceful-fs/graceful-fs.js:51:27)
Mar 01 18:14:21 volumio volumio[23345]: at Object.<anonymous> (/data/plugins/miscellanea/ampswitch/node_modules/graceful-fs/graceful-fs.js:51:27)
Mar 01 18:14:21 volumio volumio[23345]: at Object.closeSync (/data/plugins/music_service/volspotconnect2/node_modules/graceful-fs/graceful-fs.js:51:27)
Mar 01 18:14:21 volumio volumio[23345]: at Gpio.unexport (/data/plugins/miscellanea/ampswitch/node_modules/onoff/onoff.js:354:6)
Mar 01 18:14:21 volumio volumio[23345]: at AmpSwitchController.freeGPIO (/data/plugins/miscellanea/ampswitch/index.js:230:19)
Mar 01 18:14:21 volumio volumio[23345]: at AmpSwitchController.onStop (/data/plugins/miscellanea/ampswitch/index.js:84:10)
Mar 01 18:14:21 volumio volumio[23345]: at PluginManager.stopPlugin (/volumio/app/pluginmanager.js:292:27)
Mar 01 18:14:21 volumio volumio[23345]: at PluginManager.unInstallPlugin (/volumio/app/pluginmanager.js:1149:8)
Mar 01 18:14:21 volumio volumio[23345]: at CoreCommandRouter.unInstallPlugin (/volumio/app/index.js:1343:21)
Mar 01 18:14:21 volumio volumio[23345]: at Socket.<anonymous> (/volumio/app/plugins/user_interface/websocket/index.js:1094:55)
Mar 01 18:14:21 volumio volumio[23345]: at emitTwo (events.js:106:13)
Mar 01 18:14:21 volumio volumio[23345]: at Socket.emit (events.js:191:7)
Mar 01 18:14:21 volumio volumio[23345]: at /volumio/node_modules/socket.io/lib/socket.js:503:12
Mar 01 18:14:21 volumio volumio[23345]: at _combinedTickCallback (internal/process/next_tick.js:73:7)
Mar 01 18:14:21 volumio volumio[23345]: at process._tickCallback (internal/process/next_tick.js:104:9)
Mar 01 18:14:21 volumio volumio-remote-updater[574]: [2018-03-01 18:14:21] [error] handle_read_frame error: websocketpp.transport:7 (End of File)
Mar 01 18:14:21 volumio volumio-remote-updater[574]: [2018-03-01 18:14:21] [disconnect] Disconnect close local:[1006,End of File] remote:[1006]
Mar 01 18:14:21 volumio systemd[1]: volumio.service: main process exited, code=exited, status=1/FAILURE
Mar 01 18:14:21 volumio systemd[1]: Unit volumio.service entered failed state.


@spyking: At the time of writing the initial version of the plugin I ran into this problem once or twice, but, at least to me, it was not reproducible. From what I get from the log it runs into a problem when stopping the plugin and returning its privileges on the GPIO. I'm unsure whether this happens when
a) Plugin is installed and before activation deinstalled again, i.e. it has not been started and thus never claimed the default GPIO
b) a GPIO is being claimed/released that is still allocated by something else
c) some hiccup occurs in the underlying node modules, e.g. onoff

I always wanted to make it a bit more robust using some error handling like
Code: Select all
try ... catch ....
, but I have not run into this problem again and no one else reported it until now, so motivation was rather low ;)
Maybe you can try to fiddle around with it a bit to verify that one or none of the above points is actually the case, I'm currently pretty busy and just sporadically find the time to look in here.
User avatar
Fightclub
Serious Listener
Serious Listener
 
Posts: 80
Joined: Tue Feb 09 2016 18:28
Location: Germany

Ads helps Volumio remain Free and Open Source. Please consider donating to help us continue to serve you.


Amplifier Switch Plugin

Postby apunktl » Sun Apr 01 2018 07:17

Dear all,

has anyone used ampswitch on the pine64?
i'm not too much into coding, if you could me direct me in the right direction i would be really happy :)

cheers

journalctl says the following:

Code: Select all
Mar 31 16:41:37 pandit volumio[3899]: Discovery: Started advertising... pandit - undefined
Mar 31 16:41:37 pandit volumio[3899]: info: CoreCommandRouter::executeOnPlugin: system , registerCallback
Mar 31 16:41:37 pandit volumio[3899]: info: Loading plugin "albumart"...
** Mar 31 16:41:37 pandit volumio[3899]: info: Plugin example_plugin is not enabled
Mar 31 16:41:37 pandit volumio[3899]: info: Loading plugin "updater_comm"...
Mar 31 16:41:37 pandit volumio[3899]: info: Plugin mpdemulation is not enabled
Mar 31 16:41:37 pandit volumio[3899]: info: Loading plugin "rest_api"...
Mar 31 16:41:37 pandit volumio[3899]: info: Loading plugin "websocket"...
Mar 31 16:41:37 pandit volumio[3899]: info: Loading plugin "volspotconnect2"...
Mar 31 16:41:38 pandit volumio[3899]: info: ___________ START PLUGINS ___________
** Mar 31 16:41:38 pandit volumio[3899]: info: PLUGIN START: ampswitch
Mar 31 16:41:38 pandit volumio[3899]: fs.js:641
Mar 31 16:41:38 pandit volumio[3899]: return binding.open(pathModule._makeLong(path), stringToFlags(flags), mode);
Mar 31 16:41:38 pandit volumio[3899]: ^
Mar 31 16:41:38 pandit volumio[3899]: Error: EACCES: permission denied, open '/sys/class/gpio/export'
Mar 31 16:41:38 pandit volumio[3899]: at Error (native)
Mar 31 16:41:38 pandit volumio[3899]: at Object.fs.openSync (fs.js:641:18)
Mar 31 16:41:38 pandit volumio[3899]: at Object.fs.writeFileSync (fs.js:1347:33)
Mar 31 16:41:38 pandit volumio[3899]: at new Gpio (/data/plugins/miscellanea/ampswitch/node_modules/onoff/onoff.js:84:8)
Mar 31 16:41:38 pandit volumio[3899]: at AmpSwitchController.ampGPIOInit (/data/plugins/miscellanea/ampswitch/index.js:155:21)
Mar 31 16:41:38 pandit volumio[3899]: at AmpSwitchController.onStart (/data/plugins/miscellanea/ampswitch/index.js:60:10)
Mar 31 16:41:38 pandit volumio[3899]: at PluginManager.startPlugin (/volumio/app/pluginmanager.js:256:27)
Mar 31 16:41:38 pandit volumio[3899]: at HashMap.<anonymous> (/volumio/app/pluginmanager.js:332:29)
Mar 31 16:41:38 pandit volumio[3899]: at HashMap.forEach (/volumio/node_modules/hashmap/hashmap.js:157:10)
Mar 31 16:41:38 pandit volumio[3899]: at HashMap.proto.(anonymous function) [as forEach] (/volumio/node_modules/hashmap/hashmap.js:169:7)
Mar 31 16:41:38 pandit systemd[1]: volumio.service: main process exited, code=exited, status=1/FAILURE
Mar 31 16:41:38 pandit systemd[1]: Unit volumio.service entered failed state.

Random avatar
apunktl
Fresh off the boat
Fresh off the boat
 
Posts: 2
Joined: Sat Mar 31 2018 16:50


Amplifier Switch Plugin

Postby ashthespy » Mon Apr 02 2018 17:41

apunktl wrote:Dear all,

has anyone used ampswitch on the pine64?
i'm not too much into coding, if you could me direct me in the right direction i would be really happy :)

cheers

journalctl says the following:

Code: Select all
<<snip>>
** Mar 31 16:41:38 pandit volumio[3899]: info: PLUGIN START: ampswitch
Mar 31 16:41:38 pandit volumio[3899]: fs.js:641
Mar 31 16:41:38 pandit volumio[3899]: return binding.open(pathModule._makeLong(path), stringToFlags(flags), mode);
Mar 31 16:41:38 pandit volumio[3899]: ^
Mar 31 16:41:38 pandit volumio[3899]: Error: EACCES: permission denied, open '/sys/class/gpio/export'
Mar 31 16:41:38 pandit volumio[3899]: at Error (native)
<<snip>>


Hi, it would look like the volumio user doesn't have access to the GPIO group (which might be needed ala Raspberry pi), you might have to manually add it,
Code: Select all
 
groupadd gpio
usermod -a -G gpio volumio
 

You should then see something like
Code: Select all
gpio:x:999:volumio
from
Code: Select all
cat /etc/group

But countercheck with someone with a pine64 if this is indeed needed.


EDIT: A quick search throws up https://forum.pine64.org/showthread.php?tid=2233
User avatar
ashthespy
Objectivist
Objectivist
 
Posts: 280
Joined: Fri Jul 22 2016 08:16


Amplifier Switch Plugin

Postby ashthespy » Sat Apr 14 2018 20:06

@apunktl I ran into similar issues with my Orange PI with the plugin, and found a better way to solve it - Proper udev rules.

Code: Select all
su -
groupadd -f --system gpio
usermod -aG gpio volumio
touch /etc/udev/rules.d/99-gpio.rules
echo "SUBSYSTEM==\"gpio\", ACTION==\"add\", RUN=\"/bin/sh -c '
        chown -R root:gpio /sys/class/gpio && chmod -R 770 /sys/class/gpio;\
        chown -R root:gpio /sys$DEVPATH && chmod -R 770 /sys$DEVPATH\
'\"" > /etc/udev/rules.d/99-gpio.rules


I still don't completely get how udev sets the $DEVPATH variable, but it works! :-)
User avatar
ashthespy
Objectivist
Objectivist
 
Posts: 280
Joined: Fri Jul 22 2016 08:16


Amplifier Switch Plugin

Postby ashthespy » Wed Jun 20 2018 21:44

PSA -- This plugin will cause issues with the new update (2.411).
OnOff needs a version of epoll that is compiled for node v8.

Find attached a version for it if you don't fancy compiling it yourself :-)
Attachments
ampswitch.zip
(1.04 MiB) Downloaded 76 times
User avatar
ashthespy
Objectivist
Objectivist
 
Posts: 280
Joined: Fri Jul 22 2016 08:16


Amplifier Switch Plugin

Postby michelangelo » Wed Jun 20 2018 23:18

Please let's stop distributing plugins zip!!!

Our goal is to make Volumio easy to use, and resistant to failures. This requires effort and cooperation.
I am releasing this new plugin.

An easy way for you would be

clone the whole plugins
cd to your plugin directory
volumio plugin publish

this will send me a PR, after you've checked it works ;)
User avatar
michelangelo
Founder
 
Posts: 4179
Joined: Sun Dec 15 2013 23:18


Amplifier Switch Plugin

Postby ashthespy » Wed Jun 20 2018 23:26

michelangelo wrote:Please let's stop distributing plugins zip!!!

Our goal is to make Volumio easy to use, and resistant to failures. This requires effort and cooperation.
I am releasing this new plugin.

An easy way for you would be

clone the whole plugins
cd to your plugin directory
volumio plugin publish

this will send me a PR, after you've checked it works ;)


@michelangelo but that will make a version that is not compatible for people who haven't upgraded yet.
also - my last PR's were merged - but no package made it to the gh-pages branch! But I see that this the job of `volumio plugin publish`
User avatar
ashthespy
Objectivist
Objectivist
 
Posts: 280
Joined: Fri Jul 22 2016 08:16


Amplifier Switch Plugin

Postby michelangelo » Thu Jun 21 2018 00:36

Now I published it ;)
Let me know if we're all set
User avatar
michelangelo
Founder
 
Posts: 4179
Joined: Sun Dec 15 2013 23:18


Amplifier Switch Plugin

Postby martin.b07 » Mon Jun 25 2018 11:13

Hi
As mention earlier in this thread, how about the implementation of user defined scripts when starting and stopping the playback?

Regards
Martin
Random avatar
martin.b07
Fresh off the boat
Fresh off the boat
 
Posts: 4
Joined: Fri Dec 01 2017 08:45


Amplifier Switch Plugin

Postby sarma_men » Fri Aug 24 2018 11:11

Awesome job man. This plugin I almost what I need 

I have two sources, one is TV and the second one pi. Both of them are connected to the same amp.
My problem now is when I stop the music in volumio, my amp turns off and I can watch TV but without sound.

I have played with your plugin and I understand how the plugin works. I would change it to turn on/off the amp with a single switch.
My question is “can somebody give me an example of changing UI”.
I would like to put a button and with that button I would like to open a new page.
In that new page on the top I would put On/Off switch to control the amp.
Here is an example where I would like to put the button for opening the new page.

If that is to complicated, can somebody suggest me something else to try out?

Thank you,
Sarma_men
Attachments
volumio2.png
volumio2.png (93.21 KiB) Viewed 282 times
User avatar
sarma_men
Fresh off the boat
Fresh off the boat
 
Posts: 8
Joined: Sat Aug 18 2018 16:48

PreviousNext

Return to Development talks

Who is online

Users browsing this forum: No registered users and 0 guests