ChinaPhone + MakeProgress = USB Bus Voltmeter

It’s been some time already, that I’ve been working on my  ‘Remote Debug Rig’. The whole setup involves a Chinese mobile phone, I use a gsm module, a couple of avrs and other stuff. The whole setup is yet to be described once finished, but one thing I can show off now.

Since I use a lot of usb devices in a powered 10-port hub, power is an issue. The hub is externally powered, but still the power drops significantly if I fire up just everything. Since a cool power supply is yet to be done ( I still need to eth a couple of boards for it), I needed live monitoring right now.  

Using AT+EADC=1 AT command to the Mediatek-based mobile I managed to get the ADC values from the cell phone, that tell the battery voltage and the charger/usb voltage.
Then a little magic and…

Here goes the pic:

I hooked that to the makeprogress plasmoid. That one had to be hacked a bit, since it displays the value in percents, but that was an easy task and I sent the feature request to Nikita. Hopefully he adds that to his plasmoid.

Voila: USB bus Voltage on my desktop. The script as well tells the mobile to enter the keyboard test mode, so that I can grab the keypresses and use it as a remote control. The same I demonstrated in my earlier post, but this one, but rewritten fully in bash. The very serial port I use is actually a bluetooth one, so the internal uart is free to work with the AVR that manages the rest of the power control circuitry and the remote control becomes kind of wireless.

I still need to make a better cradle for that thing though, ad attach it to avr, but this yet to come.

BTW: It looks like I can track the touch screen presses via the TST-PS setting of internal UART. Wonder how that can be of use…

The software. Completely in bash, completely useless to windoze junkies. Alter the BT MAC and SPP channel, add some more code, andhere you go. Quite dirty in parts, but works.

at_daemon.sh

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
#!/bin/bash
 
if [ -e /tmp/at_fifo ]; then
echo "Already ready."
cat /dev/rfcomm0 >> /tmp/at_fifo&
else
mkfifo /tmp/at_fifo
chmod 777 /tmp/at_fifo
echo "Configuring interface"
rfcomm bind rfcomm0 34:71:B9:53:66:01 10 
stty -F /dev/rfcomm0 115200 
echo "AT interface ready"
fi
 
#enable ADC & EKPD by default
 
./at_files/init.sh&
 
while true; do cat /tmp/at_fifo|while read line; do
#echo $line
CMD=`echo $line|cut -d" " -f1`
DATA=`echo $line|cut -d" " -f2| sed 's/.$//'`
case "$CMD" in
  "+EADC:")
  VBAT=`echo $DATA|cut -d"," -f1`
  VUSB=`echo $DATA|cut -d"," -f5`
  echo '{"minimum":0,"maximum":4.5,"value":'$VBAT'}' > /tmp/vbat
  echo '{"minimum":0,"maximum":6,"value":'$VUSB'}' > /tmp/vusb
  echo "VBAT=$VBAT; VUSB=$VUSB"
   ;;
  "+EKPDS:")
  KEYEVENT=`echo $DATA|cut -d"," -f1`
  KEYCODE=`echo $DATA|cut -d"," -f2`
  if [ $KEYEVENT -eq "1" ]; then
    echo $KEYCODE
    ./keymaps/e71.map $KEYCODE
    fi
  ;;
  "SEND")
  ATCMD=`echo $line|cut -d" " -f2`
  echo "$ATCMD" > /dev/rfcomm0
  echo "Sending CMD: $ATCMD"
  ;;
  "ERROR")
  echo "Bad stuff =("
  ;;
  "OK")
  echo "All fine"
  ;;
  *)
  echo $line
  ;;
 esac
done
done

init.sh
Use the AT() method found here for your custom stuff

1
2
3
4
5
6
7
8
9
10
11
#!/bin/bash
AT()
{
echo "SEND AT$1" > /tmp/at_fifo
}
sleep 5
#Since there's a bug/feature - a double command of the same thing just increases the poll frequency
AT "+EKPD=0"
AT "+EADC=0"
AT "+EKPD=1"
AT "+EADC=1"

e71.map
A small and limited example of key mapping script. Yet to be remade into a better looking map using a more neat solution.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
#!/bin/bash -x
echo $1
 
case "$1" in
14)
  xdotool key Up
;;
15)
  xdotool key Down
;;
16)
  xdotool key Left
;;
17)
  xdotool key Right
;;

Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.