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
;;

madwimax & ap mode

Well, it took me a while to figure out what was wrong and why the heck my atheros laptop wifi won’t go to AP mode.
Looks like the ath5k driver that is in stock ubuntu 10.04 cannot do any AP mode, so you’ll have to grab ath_pci one. However, the snapshots didn’t work at all and I had to compile the svn version.
It looks like regular modbrobe -r ath5k && modprobe ath_pci DOESN’T work: Youll get 0 scan results/devices won;t see the ap created. You have to either blacklist ath5k, OR
modprobe -r ath5k
suspend the laptop
resume the laptop
modprobe ath_pci

Windows fans can do a reboot.
Well, nevertheless, I got it working and finally share a small script that does all the mode-switching between client mode and ap mode.

#!/bin/bash
WW=$1
if [ $WW == "ap" ]; then
ifconfig ath0 down
wlanconfig ath0 destroy
killall knetworkmanager
/etc/init.d/network-manager stop
wlanconfig ath0 create wlandev wifi0 wlanmode ap
#wlanconfig ath0 destroy
#wlanconfig ath0 create wlandev wifi0 wlanmode ap
#wlanconfig ath1 create wlandev wifi0 wlanmode sta nosbeacon
hostapd -B /etc/hostapd/anomalia.conf&
sleep 1
ifconfig ath0 192.168.0.1
/etc/init.d/dhcp3-server start
exit 0
fi
if [ "$WW" == "sta" ]; then
killall hostapd
ifconfig ath0 down
wlanconfig ath0 destroy
wlanconfig ath0 create wlandev wifi0 wlanmode sta nosbeacon
sleep 1
/etc/init.d/network-manager start
su necromant -c knetworkmanager&
/etc/init.d/dhcp3-server stop
sleep 1
exit 0
fi

./ap.sh ap kills the network-manager & knetworkmanager
(Gnome users need to kill nm-applet)
./ap.sh sta brings back the sta mode.
Quite quick and dirty – but it does the job

Q&D air conditioner (2.5 hrs to make one!)

It’s damn hot in Russia now. no… Well, it’s HOT AS HELL HERE.
This weekend sitting in my country house with no air conditioner there, I got finally just a bit too sick of it. Besides the heat the smoke from those damned fires is always around. (see photos under the cut)
Freaking smoke!

Anyways, I got tired of my brain throttling 4 out 5 clock cycles due to overheat, I decided it’s time for some hacking =). So I loaded some water into the fridge and while it was slowly turning to ice…


The setup is simple. I got two buckets. The smaller one I used as the water tank. I later added ice to the water. the bigger – as the main chamber. The pump (some old junk I found lying around) pumps the water up, and inside the big bucket it is sprinkled into small particles. I cooler fan I ripped of an old PC power supply pushes the air through this watery chamber. The resulting air is cool, and the smell of smoke&ash is finally gone. It took this baby about 10 minutes to clean the air in my room so that my brain began to function normally. Besides it cooled the air from 34 (Celsius) to about 30, till I ran out of ice.
I guess, that if this heat goes on I will have to make something more powerful. It’s far better, than sitting in the basement all day… And more fun than buying a ready to use solution.
Here goes the video of the rig.

P.S. This is not the worst case of smoke you might see here. Back in the city it is a real ‘gasenvagen’ and even a real air conditioner doesn’t help.