Posts: 1,538
Threads: 106
Joined: Mar 2018
Reputation:
73
Code: $ sudo cat /sys/kernel/debug/usb/devices
T: Bus=01 Lev=00 Prnt=00 Port=00 Cnt=00 Dev#= 1 Spd=480 MxCh= 1
B: Alloc= 0/800 us ( 0%), #Int=-25, #Iso= 0
D: Ver= 2.00 Cls=09(hub ) Sub=00 Prot=01 MxPS=64 #Cfgs= 1
P: Vendor=1d6b ProdID=0002 Rev= 4.19
S: Manufacturer=Linux 4.19.83-v8+ dwc_otg_hcd
S: Product=DWC OTG Controller
S: SerialNumber=3f980000.usb
C:* #Ifs= 1 Cfg#= 1 Atr=e0 MxPwr= 0mA
I:* If#= 0 Alt= 0 #EPs= 1 Cls=09(hub ) Sub=00 Prot=00 Driver=hub
E: Ad=81(I) Atr=03(Int.) MxPS= 4 Ivl=256ms
T: Bus=01 Lev=01 Prnt=01 Port=00 Cnt=01 Dev#= 2 Spd=480 MxCh= 5
D: Ver= 2.00 Cls=09(hub ) Sub=00 Prot=02 MxPS=64 #Cfgs= 1
P: Vendor=0424 ProdID=9514 Rev= 2.00
C:* #Ifs= 1 Cfg#= 1 Atr=e0 MxPwr= 2mA
I: If#= 0 Alt= 0 #EPs= 1 Cls=09(hub ) Sub=00 Prot=01 Driver=hub
E: Ad=81(I) Atr=03(Int.) MxPS= 1 Ivl=256ms
I:* If#= 0 Alt= 1 #EPs= 1 Cls=09(hub ) Sub=00 Prot=02 Driver=hub
E: Ad=81(I) Atr=03(Int.) MxPS= 1 Ivl=256ms
T: Bus=01 Lev=02 Prnt=02 Port=00 Cnt=01 Dev#= 3 Spd=480 MxCh= 0
D: Ver= 2.00 Cls=ff(vend.) Sub=00 Prot=01 MxPS=64 #Cfgs= 1
P: Vendor=0424 ProdID=ec00 Rev= 2.00
C:* #Ifs= 1 Cfg#= 1 Atr=e0 MxPwr= 2mA
I:* If#= 0 Alt= 0 #EPs= 3 Cls=ff(vend.) Sub=00 Prot=ff Driver=smsc95xx
E: Ad=81(I) Atr=02(Bulk) MxPS= 512 Ivl=0ms
E: Ad=02(O) Atr=02(Bulk) MxPS= 512 Ivl=0ms
E: Ad=83(I) Atr=03(Int.) MxPS= 16 Ivl=1ms
T: Bus=01 Lev=02 Prnt=02 Port=01 Cnt=02 Dev#= 4 Spd=1.5 MxCh= 0
D: Ver= 1.10 Cls=00(>ifc ) Sub=00 Prot=00 MxPS= 8 #Cfgs= 1
P: Vendor=20a0 ProdID=0001 Rev= 1.00
S: Manufacturer=flirc.tv
S: Product=flirc
C:* #Ifs= 2 Cfg#= 1 Atr=a0 MxPwr=100mA
I:* If#= 0 Alt= 0 #EPs= 1 Cls=03(HID ) Sub=00 Prot=01 Driver=usbhid
E: Ad=81(I) Atr=03(Int.) MxPS= 8 Ivl=50ms
I:* If#= 1 Alt= 0 #EPs= 1 Cls=ff(vend.) Sub=ff Prot=ff Driver=(none)
E: Ad=83(I) Atr=03(Int.) MxPS= 8 Ivl=50ms
----------
bob
Posts: 1,538
Threads: 106
Joined: Mar 2018
Reputation:
73
12-16-2019, 03:59 AM
(This post was last modified: 12-16-2019, 07:21 AM by DRONE7.)
Hmmm this get interesting....
I have tried with 4 remotes....The Flirc GUI reports all button presses (A-Z and 1-0) as successfully mapped.... and I have adjusted the script for each trial.
However, #1 remote will activate Play Pause and Shutdown and ignores all other buttons
#2 remote will activate Shutdown and ignores all other buttons
#3 remote will activate Play and ignores all other buttons
#4 remote will activate nothing.
There is obviously something odd with the V1 Flirc and perhaps it only works with a limited number of remotes or I/R codes....
Not sure what to try next.....
Any suggestions (including "what the heck ! massive breakage may occour trying this " short of total destruction of Pi.....no, including possibility of total destruction of Pi... why not...?!
I once slaved for a small backyard electronics manufacturer.... At the end of the first week all my assembled devices were tested by the owner...(discrete component days) and any simple errors were thrown back at head height for fixing.
When the simple fixes...poor soldering, reversed components, etc were eliminated he then measured and tested and repaired the difficult ones... finally there were 2 left (motion detector and radar speed detector IIRC)
He spent some time testing, hrummphing and the odd rude sailor word before declaring that he would have to use the big test rig to debug those two...
He disappeared to the far back of the building with them, my co-workers looked at me and said "Wait for it.."
What sounded like two almighty explosions and the boss returned with the now unrecognisable boards, a broad smile, and a sledgehammer.
----------
bob
Posts: 6,024
Threads: 176
Joined: Apr 2018
Reputation:
235
@ DRONE7
I'm puzzled by your findings. Give me a day to revisit my notes and think up a plan of attack.
---on reminiscences---
I can't match your sledgehammer story but it does put me in mind of an early experience.
At 15 I was a crackerjack amateur-radio builder/operator. This was back in the day when every town had at least one radio/TV shop with a vacuum tube tester in the corner. I was in testing some used tubes when the owner asked if I knew what I was doing. I cockily said yes. He offered to let me help him in the back room "to gain experience", e.g., to work for free. He had a number of TVs in various stages of undress and a tech probing one. Then he pointed to two sets sitting in the corner, both turned on and apparently working. He called them his "dogs", letting them cook in hopes of finally displaying intermittent problems which his tech couldn't quickly find.
His challenge to me? Start poking. Either I might find the problem without costing him anything or I might break something in which case his tech would have something specific to fix. I didn't break anything and fixed a few TVs while I learned how to use test equipment I couldn't afford. I went on to be my (small) college radio station's chief engineer and the sole Hammond organ repairman in the county until I graduated. Simpler times!
Regards,
Kent
Posts: 1,538
Threads: 106
Joined: Mar 2018
Reputation:
73
12-16-2019, 09:59 PM
(This post was last modified: 12-17-2019, 07:33 AM by DRONE7.)
Hold up Kent...I think I've found the issue....It is the Flirc device itself....appears to need more current than usb ports on my Dell can give....odd and may be a faulty/damaged Flirc...(not new item)
I did some reading and saw that in the Flirc configuration app one can check the previously mapped buttons by connecting the Flirc ,opening the keyboard option and when a remote button is pressed a virtual key is lit green.
So whilst the setup phase reported full and correct recording when I came to test only some of the buttons were truly recorded.
Then did the usual swap usb ports and try again....this resulted in more keys, but not most keys, being recorded and retained.
Aha !!....found a powered usb hub and so far recording is working fine.....
Will report back later when I have time to test on the Pi.
Now that I think of it....I.ve had some problems burning images with Etcher to sdcards and thought it was the card-reader...swapped readers and all was fine...but I'm now suspecting a usb power problem ....the old Dell may be failing...
Fixed ! as above....seems as though it is the Dell....with the powered hub all the button configs are recorded and saved..
Moving the Flirc device to the Pi (without a powered hub) and all buttons perform as programmed...
Very happy here !
----------
bob
Posts: 1,538
Threads: 106
Joined: Mar 2018
Reputation:
73
12-18-2019, 12:01 AM
(This post was last modified: 12-18-2019, 04:21 AM by DRONE7.)
All working now... just need to make it start at boot.....
Did you manage to use systemd/udev to start the script when the Flirc is present at boot or hotplugged ??
I added to /etc/rc.local and that works :-)
----------
bob
Posts: 6,024
Threads: 176
Joined: Apr 2018
Reputation:
235
@ DRONE7
Short answer, no. Longer answer, not yet. Now that someone else has actually tried this code, I need to read through my notes (a motley collection of text files I drop in my working directory as I experiment) to see where I left off.
Regards,
Kent
Posts: 78
Threads: 5
Joined: Apr 2018
Reputation:
1
(12-18-2019, 02:39 PM)TheOldPresbyope Wrote: @DRONE7
Short answer, no. Longer answer, not yet. Now that someone else has actually tried this code, I need to read through my notes (a motley collection of text files I drop in my working directory as I experiment) to see where I left off.
Regards,
Kent
Hi Kent,
I have been following your Flirc post with interest and spurred on by Bob's recent progress I have acquired a V1 Flirc.
I have programmed a few keys to match your mapping and using your script name. I assume the first line of your script:
>> pi@moode54b2:~ $ more Flirc-moode.py
should be modified to read:
>> pi@("My Pi Address"):~ $ more Flirc-moode.py
Either way I am getting syntax errors from and including line 1 on.
Is the script sensitive to spaces or something that a straight cut and paste could cause?
I would appreciate any help and if Bob is reading this and has made any adjustments to the script maybe they could be posted.
I am on a learning curve with Linux and Python so apologies for the newbie questions.
Regards,
Richard.
Posts: 1,538
Threads: 106
Joined: Mar 2018
Reputation:
73
12-21-2019, 10:04 AM
(This post was last modified: 12-21-2019, 10:11 AM by DRONE7.)
ok, I interpreted Kents post as...(and it worked ) in a ssh session run...
Code: sudo nano Flirc-moode.py
then copy and paste Kent's script....
Code: #!/usr/bin/python3
import os, asyncio,evdev,subprocess,time
# Hackery by TheOldPresbyope
# - control some moOde playback functions from a Flirc USB
# the following endpoint tracks media keys:
#flirc=evdev.InputDevice('/dev/input/by-id/usb-flirc.tv_flirc-event-if01')
# the following endpoint tracks "valid command" keys
flirc=evdev.InputDevice('/dev/input/by-id/usb-flirc.tv_flirc-if01-event-kbd')
# make sure Raspbian doesn't consume the keyboard input before we do
flirc.grab()
# paired with my Roku remote to have the following outputs
# *** had to rework to use only "valid command" keys so could watch
# *** just one endpoint
#
# Roku button Flirc output moOde function
# "left arrow button" -> "KEY_A" => favorites
# "home button" -> "KEY_B" => default playlist
# "up angle button" -> "KEY_C" => volume up
# "left-angle bracket button" -> "KEY_D" => previous
# "OK button" -> "KEY_E" => mute/unmute
# "right angle bracket button" -> "KEY_F" => next
# "down angle button" -> "KEY_G" => volume down
# "redo button" -> "KEY_H" => nothing yet
# "asterisk button" -> "KEY_I" => nothing yet
# "double-left diamond button" -> "KEY_J" => nothing yet
### careful: flirc_util 3.22.4 says "k" is not a valid letter!!!
# "play/pause button" -> "KEY_L" => play/pause
# "double-right diamond button" -> "KEY_M" => nothing yet
for event in flirc.read_loop():
if event.type == evdev.ecodes.EV_KEY:
attrib = evdev.categorize(event)
if attrib.keystate == 1:
if attrib.keycode == 'KEY_F':
subprocess.run(['mpc','next'])
elif attrib.keycode == 'KEY_D':
subprocess.run(['mpc','prev'])
elif attrib.keycode == 'KEY_C':
subprocess.run(['/var/www/vol.sh','-up','10'])
elif attrib.keycode == 'KEY_G':
subprocess.run(['/var/www/vol.sh','-dn','10'])
elif attrib.keycode == 'KEY_L':
subprocess.run(['mpc','toggle'])
elif attrib.keycode == 'KEY_A':
subprocess.run(['mpc','clear'])
time.sleep(0.1)
subprocess.run(['mpc','load','Favorites'])
elif attrib.keycode == 'KEY_B':
subprocess.run(['mpc','clear'])
time.sleep(0.1)
subprocess.run(['mpc','load','Default Playlist'])
elif attrib.keycode == 'KEY_E':
subprocess.run(['/var/www/vol.sh','-mute'])
and change to suit the V1 Flirc as per this post
http://moodeaudio.org/forum/showthread.p...3#pid15213
edit to suit your remote and key codes and save....
If you need help here then let me know...
I am away from my Pi and about to retire for the night but tomorrow will post the full working config and script I am using.
Cheers,
Bob
----------
bob
Posts: 78
Threads: 5
Joined: Apr 2018
Reputation:
1
(12-21-2019, 10:04 AM)DRONE7 Wrote: ok, I interpreted Kents post as...(and it worked ) in a ssh session run...
Code: sudo nano Flirc-moode.py
then copy and paste Kent's script....
Code: #!/usr/bin/python3
import os, asyncio,evdev,subprocess,time
# Hackery by TheOldPresbyope
# - control some moOde playback functions from a Flirc USB
# the following endpoint tracks media keys:
#flirc=evdev.InputDevice('/dev/input/by-id/usb-flirc.tv_flirc-event-if01')
# the following endpoint tracks "valid command" keys
flirc=evdev.InputDevice('/dev/input/by-id/usb-flirc.tv_flirc-if01-event-kbd')
# make sure Raspbian doesn't consume the keyboard input before we do
flirc.grab()
# paired with my Roku remote to have the following outputs
# *** had to rework to use only "valid command" keys so could watch
# *** just one endpoint
#
# Roku button Flirc output moOde function
# "left arrow button" -> "KEY_A" => favorites
# "home button" -> "KEY_B" => default playlist
# "up angle button" -> "KEY_C" => volume up
# "left-angle bracket button" -> "KEY_D" => previous
# "OK button" -> "KEY_E" => mute/unmute
# "right angle bracket button" -> "KEY_F" => next
# "down angle button" -> "KEY_G" => volume down
# "redo button" -> "KEY_H" => nothing yet
# "asterisk button" -> "KEY_I" => nothing yet
# "double-left diamond button" -> "KEY_J" => nothing yet
### careful: flirc_util 3.22.4 says "k" is not a valid letter!!!
# "play/pause button" -> "KEY_L" => play/pause
# "double-right diamond button" -> "KEY_M" => nothing yet
for event in flirc.read_loop():
if event.type == evdev.ecodes.EV_KEY:
attrib = evdev.categorize(event)
if attrib.keystate == 1:
if attrib.keycode == 'KEY_F':
subprocess.run(['mpc','next'])
elif attrib.keycode == 'KEY_D':
subprocess.run(['mpc','prev'])
elif attrib.keycode == 'KEY_C':
subprocess.run(['/var/www/vol.sh','-up','10'])
elif attrib.keycode == 'KEY_G':
subprocess.run(['/var/www/vol.sh','-dn','10'])
elif attrib.keycode == 'KEY_L':
subprocess.run(['mpc','toggle'])
elif attrib.keycode == 'KEY_A':
subprocess.run(['mpc','clear'])
time.sleep(0.1)
subprocess.run(['mpc','load','Favorites'])
elif attrib.keycode == 'KEY_B':
subprocess.run(['mpc','clear'])
time.sleep(0.1)
subprocess.run(['mpc','load','Default Playlist'])
elif attrib.keycode == 'KEY_E':
subprocess.run(['/var/www/vol.sh','-mute'])
and change to suit the V1 Flirc as per this post
http://moodeaudio.org/forum/showthread.p...3#pid15213
edit to suit your remote and key codes and save....
If you need help here then let me know...
I am away from my Pi and about to retire for the night but tomorrow will post the full working config and script I am using.
Cheers,
Bob
Many thanks for your help Bob.
Regards,
Richard.
Posts: 6,024
Threads: 176
Joined: Apr 2018
Reputation:
235
@ rh2018
Hi, Richard.
Yes, I suppose I should have changed my specific hostname to the generic hostname moode but my original post was a work in progress and, like I warned, it assumed moderate Linux literacy. Glad to hear you got things straightened out with Bob's able assistance.
I must say I'm puzzled that V.1 FLIRCs seem to be in such abundance, but after this week's crush of holiday visitors and activities I expect to fix up the script to accommodate both V.1 and V.2 automagically. As well, there's the undone business about making the code a proper service.
All the best in this holiday season.
Regards,
Kent
|