Thursday, September 11, 2008

Opera Mobile 9.5 With Flash lite 3.1

Opera mobile 9.5 has yet released. But many OEM versions can be extracted through ROMs.
Flash lite 3.1 will never be retailed. But it is also in some ROMs.
What about combination!
Kuhl! It works. Now Opera Mobile have the capability to Flash 8&9 contents!
I can now display youtube inside the little screen.

http://forum.xda-developers.com/showthread.php?t=425268
http://forum.xda-developers.com/showthread.php?t=423860

Monday, September 8, 2008

关于计算机围棋的一些事实

1.Yose in the opening
2.Sente - myth or legend?
3.The advantages of gote
4.Sides are for suckers
5.Helping your opponent
6.Life - How to avoid it
7.Increasing a dead group
8.Play threats before starting a ko
9.Invasions after dame
10.Don't secure, pass!

Wednesday, September 3, 2008

回学校了

Leave and return.

Thursday, August 21, 2008

Socket in python

server:
#!/usr/bin/env python
import socket
if __name__ == '__main__':
sock = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
sock.bind(('localhost', 8001))
sock.listen(5)
while True:
connection,address = sock.accept()
try:
connection.settimeout(5)
buf = connection.recv(1024)
if buf == '1':
connection.send('this is one')
else:
connection.send('this is not one')
except socket.timeout:
print 'time out'
connection.close()

client:
#!/usr/bin/env python
def send():
import socket
sock = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
sock.connect(('localhost', 8001))
import time
time.sleep(1)
time.sleep(1)
sock.send('1')
print sock.recv(1024)
sock.close()

if __name__ == '__main__':
while(True):
send()

Monday, August 18, 2008

这个谜语有意思。

清代的谜学家张起南在《橐园春灯话》有个谜语真是bt到极点了。

杜甫诗句“无边落木萧萧下“打一个字:

谜底是"日"

因为萧是齐、梁朝的国姓,故萧->陳, 陳无边->東,東落木->日。

BQ27200芯片的编程


BQ27200 is a commonly used chip in mobile phone like HP IPAQ 6828's battery. It is possible to make a program that interact with the chip in windows ce platform.

First, you will need PXA27X's DDK for windows CE 5.0 or bulverde board development files.

Then, you can start programming. The most important thing is to allocate virtual memory for addressing the chip.

void InitializeBulverde(){
vg_pGPIORegs = NULL;
vg_pI2CRegs = NULL;
vg_pClkRegs = NULL;
vg_pOSTRegs = NULL;

PUCHAR pVMem; // for virtual memory address
DWORD VMemSize; // Total size needed for virtual memory

// Total size needed for virtual memory :
// Page size is 4Kbytes
// Driver Globals is also 4Kbytes
VMemSize = (PAGE_SIZE*5);
////////////////////////////////////////
// Size needed for register space.
pVMem = (PUCHAR)VirtualAlloc(0, VMemSize, MEM_RESERVE, PAGE_NOACCESS);
if(!pVMem) {
MessageBox(NULL, TEXT("Virtual Allocate failed!"), TEXT("InitBatteryDriver"), MB_OK);
}

// Map register space to virtual memory.
// 1. GPIO register
if(!VirtualCopy(pVMem, (LPVOID)(BULVERDE_BASE_REG_PA_GPIO >> 8), PAGE_SIZE,
PAGE_READWRITE|PAGE_NOCACHE|PAGE_PHYSICAL)) {
NKDbgPrintfW(_T("InitBatteryDriver: Virtual Copy: GPIO space failed\r\n"), GetLastError());
MessageBox(NULL, TEXT("GPIO space failed"), TEXT("Virtual Copy"), MB_OK);
}
vg_pGPIORegs = (DWORD *)pVMem;
pVMem += PAGE_SIZE;

// 2. I2C register
if(!VirtualCopy(pVMem,(LPVOID)(BULVERDE_BASE_REG_PA_I2C >> 8), PAGE_SIZE,
PAGE_READWRITE | PAGE_PHYSICAL | PAGE_NOCACHE)) {
MessageBox(NULL, TEXT("I2C space failed"), TEXT("Virtual Copy"), MB_OK);
}
vg_pI2CRegs = (DWORD *)pVMem;
pVMem += PAGE_SIZE;

// 3. CLKMGR register
if(!VirtualCopy(pVMem,(LPVOID)(BULVERDE_BASE_REG_PA_CLKMGR >> 8), PAGE_SIZE,
PAGE_READWRITE | PAGE_PHYSICAL | PAGE_NOCACHE)) {
MessageBox(NULL, TEXT("CLKMGR space failed"), TEXT("Virtual Copy"), MB_OK);
}
vg_pClkRegs = (DWORD *)pVMem;
pVMem += PAGE_SIZE;

// 4. OST register
if(!VirtualCopy(pVMem,(LPVOID)(BULVERDE_BASE_REG_PA_OST >> 8), PAGE_SIZE,
PAGE_READWRITE | PAGE_PHYSICAL | PAGE_NOCACHE)) {
MessageBox(NULL, TEXT("OST space failed"), TEXT("Virtual Copy"), MB_OK);
}
vg_pOSTRegs = (DWORD *)pVMem;

XllpI2cInit((P_XLLP_I2C_T)vg_pI2CRegs, (P_XLLP_GPIO_T)vg_pGPIORegs, (P_XLLP_CLKMGR_T)vg_pClkRegs, (XLLP_UINT32_T) 0x1);

Then you can you can read the registry like this:

if (XllpI2CReadS((P_XLLP_I2C_T)vg_pI2CRegs, (XLLP_OST_T *)vg_pOSTRegs, BQ27200_SLAVE, (XLLP_UINT8_T *)&buff, 1, bSENDSTOP) == XLLP_TRUE) {
return L" Battdrvr: XllpI2CReadS() is failed \r\n";
}
and write like this:

if (XllpI2CWriteS((P_XLLP_I2C_T)vg_pI2CRegs, (XLLP_OST_T *)vg_pOSTRegs, BQ27200_SLAVE, (XLLP_UINT8_T *)&buff, 1, bSENDSTOP) == XLLP_TRUE) {
MessageBox(NULL, TEXT("XllpI2CWriteS() is failed"), TEXT("Battdrvr"), MB_OK);
}

Note, in driver programming, one should use NKDbgPrintfW to print out the debug information instead of fprintr(stderr ...). This is because, this is a real-time function and will be used only in WinCE programs that interact with the kernel. So it is better.

Ok. here I will publish the the battery calibration for BQ27200 called BQ27200Expert. It can display various information about the BQ27200 and also calibrate the battery.

Download the program from XDA!

http://forum.xda-developers.com/showpost.php?p=2527251&postcount=1525