Command line - return data / feedback

Discuss everything to do with GIMX here
Post Reply
elRey
Posts: 7
Joined: Thu Apr 27, 2017 6:46 pm

Command line - return data / feedback

Post by elRey » Tue May 02, 2017 2:51 pm

Are there any commands that return data or anything from a PS3 that we can use to confirm the PS3 received and processed the command?

User avatar
Matlo
Posts: 4517
Joined: Wed Jul 06, 2011 7:01 am
Location: France
Contact:

Re: Command line - return data / feedback

Post by Matlo » Fri May 05, 2017 7:08 am

This is not possible. What would be the use case?
GIMX creator Donate Shop

elRey
Posts: 7
Joined: Thu Apr 27, 2017 6:46 pm

Re: Command line - return data / feedback

Post by elRey » Sat May 13, 2017 6:36 pm

Home automation to turn in/off ps3. If I've been watching a movie for a couple of hours, the bluetooth connection has to be re-established. I would be nice to confirm the ps3 is indeed receiving commands before going thru the sequence if cmds to power off or start a game/app. If the sequence starts before the connection has been fully established, the end result will be off, not powered off of wrong game/app started.

If I could initial connection and then send one cmd repeated and listen for a response (maybe dualshock) to confirm PS3 is in fact processing cmds.

The controller have to receive some signals for controller number lights/ low battery lights, dualshock feedback.

Thanks,
Reey

User avatar
Matlo
Posts: 4517
Joined: Wed Jul 06, 2011 7:01 am
Location: France
Contact:

Re: Command line - return data / feedback

Post by Matlo » Sat May 13, 2017 7:28 pm

Please detail the commands you are running. There may be a better way to proceed.
GIMX creator Donate Shop

elRey
Posts: 7
Joined: Thu Apr 27, 2017 6:46 pm

Re: Command line - return data / feedback

Post by elRey » Sun May 14, 2017 1:11 am

Code: Select all

#!/bin/bash

default_delayT=0.007
delayT=${default_delayT}
afterPause=0.15
dstAddr="127.0.0.1:51000"
ps3IP="192.168.1.199"
ps3Addr="08:A9:5A:xx:xx:xx"
ctlrAddr="64:D4:BD:xx:xx:xx"
reconn=false
ps3Ping=true

if [ $# -gt 1 ]; then
    delayT=$2
fi

pingPS3() {
   ping -c 1 -W 1 ${ps3IP}>/dev/null
   if [ $? -eq 0 ]; then
      ps3Ping=true
   else
      ps3Ping=false
   fi
}

stat() {
   jobs
   ps ax|grep "[g]imx -t Sixaxis -s ${dstAddr}"
   pingPS3
   echo "ps3Ping: $ps3Ping"
}

sendCMD() {
   #startGIMX
   gimx -e "$1(255)" -d ${dstAddr} > /dev/null
   sleep ${delayT}
   gimx -e "$1(0)" -d ${dstAddr} > /dev/null
   sleep ${afterPause}
}

setBDAddr() {
   bdaddr -i hci0|grep ${ctlrAddr} >/dev/null || bdaddr -r -i hci0 ${ctlrAddr} >/dev/null
}

startGIMX() {
   reconn=false
   gStat=`ps ax -o pid,stat,command|grep "[g]imx -t Sixaxis -s ${dstAddr}" | awk {'print$2'}`
   #echo ${gStat}
   if [ "${gStat}" != "S" ]; then
      reconn=true
      pingPS3
      if [ "${gStat}" != "" ]; then
         stopGIMX
         sleep 4
      fi
      echo "no GIMX instance running. starting."
      setBDAddr
      gimx -t Sixaxis -s ${dstAddr} -b ${ps3Addr} >/dev/null &
      #sleep 17
      if [ "${1}" != "on" ] && [ "$ps3Ping" == "false" ]; then
         echo "PS3 was powered down. Waiting until fully powered on."
         sleep 34
      elif [ "${1}" != "gimx_start" ]; then
         sleep 0.1
      fi
   fi
}

stopGIMX() {
   gpid=`pgrep -f "gimx -t Sixaxis -s ${dstAddr}"`
   if [ "$gpid" != '' ]; then
      echo "gimx pid $gpid found. killing."
      kill -9 $gpid
   fi
}

catTV() {
   for i in {1..9}
   do
      sendCMD "right"
   done
   for i in {1..4}
   do
      sendCMD "left"
   done
   for i in {1..9}
   do
      sendCMD "up"
   done
}
if [ "${1}" == "stat" ]; then
   stat
   return
fi


if [ "${1}" != "on" ] && [ "${1}" != "off" ] && [ "${1}" != "gimx_start" ] && [ "${1}" != "gimx_stop" ]; then
   startGIMX
fi

if [ "${1}" == "gimx_start" ]; then
   startGIMX
elif [ "${1}" == "gimx_stop" ]; then
   stopGIMX
elif [ "${1}" == "on" ]; then
   #startGIMX "on"
   startGIMX
elif [ "${1}" == "off" ]; then
   pingPS3
   if ! $ps3Ping
   then
      echo "PS3 already powered down. nothing to do."
      return
   fi
   startGIMX
   if $reconn
   then
      echo "had to reconnect to PS3. waiting on new gimx instance."
      sleep 8
   fi

   for i in {1..5}
   do
      sendCMD circle
   done
   delayT=3.5
   sendCMD "PS"
   delayT=${default_delayT}
   for i in {1..5}
   do
      sendCMD "down"
   done
   sleep 0.5
   sendCMD "up"
   sendCMD "cross"
   sendCMD "left"
   sleep 0.5
   sendCMD "cross"
   sleep 2
   stopGIMX
   sleep 5
elif [ "${1}" == "exit" ]; then
   delayT=1.2
   sendCMD "PS"
   delayT=${default_delayT}
   for i in {1..5}
   do
      sendCMD "up"
   done
   sendCMD "cross"
   sleep 0.5
   sendCMD "left"
   sleep 0.5
   sendCMD "cross"
elif [ "${1}" == "netflix" ]; then
   catTV
   sendCMD "down"
   sendCMD "cross"
   sleep 33
   sendCMD "cross"
elif [ "${1}" == "youtube" ]; then
   catTV
   for i in {1..4}
   do
        sendCMD "down"
   done
   sendCMD "cross"
elif [ "${1}" == "hulu" ]; then
   catTV
   for i in {1..3}
   do
        sendCMD "down"
   done
   sendCMD "cross"
else
   sendCMD $1
fi


User avatar
Matlo
Posts: 4517
Joined: Wed Jul 06, 2011 7:01 am
Location: France
Contact:

Re: Command line - return data / feedback

Post by Matlo » Mon May 15, 2017 9:49 am

You can redirect the GIMX server output to a file.
Before sending commands to the gimx server, check that the PS3 is reachable, check that the GIMX server it is still running, and check that the connection was established looking into the GIMX server output file.
GIMX creator Donate Shop

elRey
Posts: 7
Joined: Thu Apr 27, 2017 6:46 pm

Re: Command line - return data / feedback

Post by elRey » Tue May 16, 2017 2:09 am

Watching output from both server instance and command call, there was no way to tell when the ps3 could start processing cmds. Output from server was immediate and did not change when ps3 actually started to respond. Output from commands found server running and returned positive even though ps3 was not responding immediately after server start.

In other words, there was no indication in outputs that connection was fully up and ps3 was processing cmds. How can we see data coming back from ps3? like force feedback, dualshock, battery, controller number ?

Controllers even have this when you first turn them on their leds blink until the are fully connected and can send button presses. There has to be a return message from ps3.

output of server and cmds with start of server, then 5 cmds (really 10 cmds) immediately following:

Code: Select all

pi@storagepi:~/gimx $ cat gimx_out
controller #1: option -t with value `Sixaxis'
controller #1: option -s with value `127.0.0.1:51000'
controller #1: option -b with value `08:A9:5A:xx:xx:xx'
now reading arguments for controller #2
using default refresh period: 10.00ms

controller #1: option -e with value `down(255)'
controller #1: option -d with value `127.0.0.1:51000'
now reading arguments for controller #2
Remote GIMX detected, controller type is: Sixaxis.
using default refresh period: 10.00ms
controller #1: option -e with value `down(0)'
controller #1: option -d with value `127.0.0.1:51000'
now reading arguments for controller #2
Remote GIMX detected, controller type is: Sixaxis.
using default refresh period: 10.00ms

controller #1: option -e with value `down(255)'
controller #1: option -d with value `127.0.0.1:51000'
now reading arguments for controller #2
Remote GIMX detected, controller type is: Sixaxis.
using default refresh period: 10.00ms
controller #1: option -e with value `down(0)'
controller #1: option -d with value `127.0.0.1:51000'
now reading arguments for controller #2
Remote GIMX detected, controller type is: Sixaxis.
using default refresh period: 10.00ms

controller #1: option -e with value `down(255)'
controller #1: option -d with value `127.0.0.1:51000'
now reading arguments for controller #2
Remote GIMX detected, controller type is: Sixaxis.
using default refresh period: 10.00ms
controller #1: option -e with value `down(0)'
controller #1: option -d with value `127.0.0.1:51000'
now reading arguments for controller #2
Remote GIMX detected, controller type is: Sixaxis.
using default refresh period: 10.00ms

controller #1: option -e with value `down(255)'
controller #1: option -d with value `127.0.0.1:51000'
now reading arguments for controller #2
Remote GIMX detected, controller type is: Sixaxis.
using default refresh period: 10.00ms
controller #1: option -e with value `down(0)'
controller #1: option -d with value `127.0.0.1:51000'
now reading arguments for controller #2
Remote GIMX detected, controller type is: Sixaxis.
using default refresh period: 10.00ms

controller #1: option -e with value `down(255)'
controller #1: option -d with value `127.0.0.1:51000'
now reading arguments for controller #2
Remote GIMX detected, controller type is: Sixaxis.
using default refresh period: 10.00ms
controller #1: option -e with value `down(0)'
controller #1: option -d with value `127.0.0.1:51000'
now reading arguments for controller #2
Remote GIMX detected, controller type is: Sixaxis.
using default refresh period: 10.00ms


Only the last cmd (2 cmds) was processed by the ps3. However, there is no indication in output or difference in output between the last cmd that worked and the previous 4 that didn't.


Thanks,
Rey

elRey
Posts: 7
Joined: Thu Apr 27, 2017 6:46 pm

Re: Command line - return data / feedback

Post by elRey » Tue May 16, 2017 3:25 am

Is there an exposed method/function to get sixaxis state->sys.led[0-4] or led_state_t?

elRey
Posts: 7
Joined: Thu Apr 27, 2017 6:46 pm

Re: Command line - return data / feedback

Post by elRey » Tue May 16, 2017 5:07 am

the --status option add some output that I can use.

current fix:

Code: Select all

gimx --status -t Sixaxis -s ${dstAddr} -b ${ps3Addr} >>${server_out} &

Code: Select all

         connUp=`tail -n 2 ${server_out}|head -n 1|awk '{print $1}'`
         while [ $connUp != "0" ]
         do
             gimx -e "circle(0)" -d ${dstAddr} >>${cmd_out}
             connUp=`tail -n 2 ${server_out}|head -n 1|awk '{print $1}'`
             sleep 0.2
             #connUp="0"
         done
output:

Code: Select all

pi@storagepi:~/gimx $ cat output
no GIMX instance running. starting.
controller #1: option -t with value `Sixaxis'
controller #1: option -s with value `127.0.0.1:51000'
controller #1: option -b with value `08:A9:5A:xx:xx:xx'
now reading arguments for controller #2
status flag is set
using default refresh period: 10.00ms
Warning: can't open macro directory /home/pi//.gimx//macros/
connecting with hci0 = 64:D4:BD:xx:xx:xx to 08:A9:5A:xx:xx:xx psm 0x0011
connecting with hci0 = 64:D4:BD:xx:xx:xx to 08:A9:5A:xx:xx:xx psm 0x0013
connected with hci0 = 64:D4:BD:xx:xx:xx to 08:A9:5A:xx:xx:xx
0 1494911333.562464
0 1494911338.552722
0 1494911338.742662
0 1494911339.001443, up (255)
0 1494911339.046428

Post Reply