tool to create regular expression for you Wednesday, December 30, 2009



http://www.txt2re.com/

It's a online tool, you follow the three steps to create a regular expression easily

Python 如何在sys.path下包含自定义的路径 Wednesday, December 16, 2009





1〉定义环境变量PYTHONPATH,如果有多个路径则需要分号分隔,比如 PYTHONPATH=D:\_python;n:\_python1
2〉如果在d:\_python下还有子文件夹pyext,包含test.py。在d:\_python创建一个__init__.py写入import pyext,在pyext中也创建__init__.py(空文件)。 运行时使用import pyext.test就可以使用test.py

很有帮助的函数,可以显示api的信息 Thursday, December 10, 2009



"""Cheap and simple API helper

This program is part of "Dive Into Python", a free Python book for
experienced programmers. Visit http://diveintopython.org/ for the
latest version.
"""

__author__ = "Mark Pilgrim (mark@diveintopython.org)"
__version__ = "$Revision: 1.3 $"
__date__ = "$Date: 2004/05/05 21:57:19 $"
__copyright__ = "Copyright (c) 2001 Mark Pilgrim"
__license__ = "Python"

# While this is a good example script to teach about introspection,
# in real life it has been superceded by PyDoc, which is part of the
# standard library in Python 2.1 and later.
#
# Your IDE may already import the "help" function from pydoc
# automatically on startup; if not, do this:
#
# >>> from pydoc import help
#
# The help function in this module takes the object itself to get
# help on, but PyDoc can also take a string, like this:
#
# >>> help("string") # gets help on the string module
# >>> help("apihelper.help") # gets help on the function below
# >>> help() # enters an interactive help mode
#
# PyDoc can also act as an HTTP server to dynamically produce
# HTML-formatted documentation of any module in your path.
# That's wicked cool. Read more about PyDoc here:
# http://www.onlamp.com/pub/a/python/2001/04/18/pydoc.html

def info(object, spacing=10, collapse=1):
"""Print methods and doc strings.

Takes module, class, list, dictionary, or string."""
methodList = [e for e in dir(object) if callable(getattr(object, e))]
processFunc = collapse and (lambda s: " ".join(s.split())) or (lambda s: s)
print "\n".join(["[%s] %s" %
(method.ljust(spacing),
processFunc(str(getattr(object, method).__doc__)))
for method in methodList])

if __name__ == "__main__":
print help.__doc__

S60上使用python Wednesday, December 9, 2009



我在window xp上用S60 5th Edition SDK。
1> 首先需要下在两个软件

PythonForS60_1.9.7_Setup.exe
Python_1.9.7_3rdFP2_SDK_with_OpenC.zip

2> 在pc上安装PythonForS60_1.9.7_Setup.exe

这个软件中包含如下的sis包
pips.sisx
PythonScriptShell_1.9.7_3_0.sis
PythonScriptShell_1.9.7_3_2.sis
PythonScriptShell_1.9.7_high_capas.sis
PythonScriptShell_1.9.7_unsigned_devcert.sis
Python_1.9.7.sis
scribble_v0_2_0.sis
ssl_nokia_1_5_7.SIS
stdioserver_nokia_1_5_1_SS.sis

3> 我手机上安装了其中的两个:

Python_1.9.7.sis
PythonScriptShell_1.9.7_3_2.sis
这样你就可以在手机上运行python脚本了。sis包安装后有一些demo的脚本,正好可以体验一下。

4> 在pc上配置模拟器环境

解压Python_1.9.7_3rdFP2_SDK_with_OpenC.zip,然后把其中的文件导入到epoc32。我只拷贝了原来epoc32中没有的文件,已经有的文件没有覆盖。
可以自己写个脚本解决。如果需要的话可以联系我。

script to make python syntax hightlight in ultraedit Tuesday, December 8, 2009



/L10"Python" Line Comment = # Block Comment One = """ Block Comment Off = """ Escape Char = \ File Extensions = PY PYW
/Indent Strings = ":"
/Function String 1 = "%[ ,^t]++def[ ]+^([a-zA-Z0-9_]+*^):"
/Function String 2 = "%[ ,^t]++^(##[ a-zA-Z0-9_]+*^)##"
/Function String 3 = "%[ ,^t]++^(class[ ]+[a-zA-Z0-9_]+*^):"
/Delimiters = []{}()<>="''.,:+
/C1"Reserved Words"
and assert
break
class continue
def del
elif else except exec
finally for from
global
if import in is
lambda
map
not
None
or
pass print
raise range return
try
while
/C2"Built-in Functions"
abs apply
callable chr cmp coerce compile complex
delattr dir divmod
eval execfile
filter float
getattr globals
hasattr hash hex
id input int intern isinstance issubclass
joinfields
len list local long
max min match
oct open ord
pow
raw_input reduce reload repr round
search setattr setdefault slice str splitfields
unichr unicode
tuple type
vars
xrange
zip
__import__
/C3"__Methods__"
__abs__ __add__ __and__
__call__ __cmp__ __coerce__
__del__ __delattr__ __delitem__ __delslice__ __div__ __divmod__
__float__
__getattr__ __getitem__ __getslice__
__hash__ __hex__
__iadd__ __isub__ __imod__ __idiv__ __ipow__ __iand__ __ior__ __ixor__
__ilshift__ __irshift__
__invert__ __int__ __init__
__len__ __long__ __lshift__
__mod__ __mul__
__neg__ __nonzero__
__oct__ __or__
__pos__ __pow__
__radd__ __rdiv__ __rdivmod__ __rmod__ __rpow__ __rlshift__ __rrshift__
__rshift__ __rsub__ __rmul__ __repr__
__rand__ __rxor__ __ror__
__setattr__ __setitem__ __setslice__ __str__ __sub__
__xor__
/C4"__Attributes__"
__bases__
__class__
__dict__ __doc__
__methods__ __members__
__name__
__version__
/C5"Exceptions"
ArithmeticError AssertionError AttributeError
EOFError Exception
FloatingPointError
IOError ImportError IndentationError IndexError
KeyError KeyboardInterrupt
LookupError
MemoryError
NameError
OverflowError
RuntimeError
StandardError SyntaxError SystemError SystemExit
TabError TypeError
ValueError
ZeroDivisionError
/C6"Operators"
+=
-=
%=
/=
**=
&=
|=
^=
>>=
<<=
/C7"Common Libs"
AST atexit
BaseHTTPServer Bastion
cmd codecs commands compileall copy
CGIHTTPServer Complex
dbhash dircmp dis dospath dumbdbm
emacs
find fmt fnmatch ftplib
getopt glob gopherlib grep
htmllib httplib
ihooks imghdr imputil
linecache lockfile
macpath macurl2path mailbox mailcap
mimetools mimify mutex math
Mimewriter
newdir ni nntplib ntpath nturl2path
os ospath
pdb pickle pipes poly popen2 posixfile posixpath profile pstats pyclbr
pyexpat
Para
quopri
Queue
rand random regex regsub rfc822
sched sgmllib shelve site sndhdr string sys snmp
SimpleHTTPServer StringIO SocketServer
tb tempfile toaiff token tokenize traceback tty types tzparse
Tkinter
unicodedata urllib urlparse util uu
UserDict UserList
wave webbrowser whatsound whichdb whrandom
xdrlib xml xmlpackage
zmod
/C8"Others"
array
AzIM
Desc
fnmatch
Info
Run
struct self
StartKey StopKey

Use table in Mediawiki Thursday, October 29, 2009

As you know, it is very hard to use Table in MediaWiKi . The syntax to create table is sample but the process is bored.
fortunately I found a good way to do it.
1> use google doc to create and edit table.
2> download it as html or tap "edit"-->"view as html"
3> copy the code between "div" and "/div"
4> paste the code in MediaWiki.
Good luck.

OOM(Out of Memory Wednesday, October 21, 2009

S60 5th Edition provides a OOM mechanism to handle the out-of-memory case. You can check out the detailed info from the belowing link.

The clinet interface is ROomMonitorSession by which you can get more free RAM to match your application's memory requestion.

Notice: You can extend the OOM mechanism by using PLUGIN framework.

formal artical from S60


What's different between INDEX and KEY in database Tuesday, October 13, 2009

INDEX:
An index is a database feature used for locating data quickly within a table. Indexes are defined by selecting a set of commonly searched attribute(s) on a table and using the appropriate platform-specific mechanism to create an index.
for example, Personnel information may be store in a Human Resource department's employee table. Clerks find that they often search the table for employees by last name but get slow query responses. Defining an index on the table consisting of the last name attribute would speed up these queries.

KEY:
A database key is a attribute utilized to sort and/or identify data in some manner. Each table has a primary key which uniquely identifies records. Foriegn keys are utilized to cross-reference data between relational tables.



What means DDL, DML, TCL and DCL?

There're four catalogs in standard SQL language:

  1. DDL-----Data Defination Language
  2. DML-----Data Manipulation Language
  3. DCL------Data Control Language
  4. TCL------Transaction Language
The detaled information is as belowing 
1> The DDL includes
CREATE TABLE - creates new database table
ALTER TABLE - alters or changes the database table
DROP TABLE - deletes the database table
CREATE INDEX - creates an index or used as a search key
DROP INDEX - deletes an index 
2> The DML includes
SELECT - extracts data from the database
UPDATE - updates data in the database
DELETE - deletes data from the database
INSERT INTO - inserts new data into the database
3> The DCL includes
GRANT – gives access privileges to users for database
REVOKE – withdraws access privileges to users for database
4> The TCL includes
COMMIT – saves the work done
ROLLBACK - restore the database to original since the last COMMIT

Regarding how to use SQL, pls refer to this link. http://sql.1keydata.com/cn/  

使用Sqlitecc查看symbian sql 数据库

在symbian OS 9.5 上提供了sqlite api,用这些api 生成的数据库可以用sqlitecc打开。
sqlitecc是图形界面,可以在其中修改数据,很方便、直观

首先需要从sourceforge上下载sqlitecc,http://sqlitecc.sourceforge.net/
然后直接可以打开。打开后界面如下





listbox中使用svg图片

这些天尽管有源源不断的pr过来,但是还是有时间搞搞listbox。之所以搞这个是因为在NewLc上看到有不少人问类似的问题,而且我觉得在UI开发中Listbox经常用到。计划在一周内抽时间把S60上的所有标准listbox都深入研究一下。
今天在使用CAknSingleGraphicStyleListBox的时候,没有合适的icon用,正好手边有一些svg图片就试了一下,发现可以使用。这下好了svg图片可大可小,不用考虑尺寸问题。
如果用carbid c++ ide的话,可以直接用ide提供的功能编辑和创建mbm/mif文件。如下图所示启动编辑器















目前,我通过makefile文件生成mif文件。首先创建一个makefile文件icon.mk,然后在bld文件中加入
gnumakefile icon.mk

即可。 其实也可以在mmp文件中加入
prj_extensions
start extension s60/mifconc
option targetfile icon.mif
.....
option source ....
end
来替代那个makefile文件
SVG图片的使用方法不同于bmp。bmp通过bmpconv工具被整合为一个mbm(multi-bitmap)文件,这是symbian独有的文件格式。而svg通过mifconv工具整合为mif(MSX interchange format)文件,在Mif文件中也可以加入bmp。
由于mif的支持不是symbian提供的,所以用createiconl这样的方法只能加载mbm文件,不能加载mif文件,需要用aknsutils::creategulicon加载。加载后,使用方法跟通常一样。

歌曲蛮好,flash更有创意 Monday, October 12, 2009

http://soytuaire.labuat.com/

北京及其各个区的地图


通州


顺义


昌平



大兴


望京地图


我眼中的NMEA-0183协议

 

NMEA是National Marine Electronics Association(美国国家海事电子协会)的缩写。该协会是一家专门从事海洋电子设备方面研究的民间机构,它制定了关于GPS(全球定位系统)电子设备之间的通信接口和协议的NMEA标准。
NMEA-0183协议是目前GPS接收机上使用最广泛的协议,大多数常见的GPS接收机、GPS数据处理软件、导航软件都遵守或者至少兼容这个协议。
一、            电器特性
Baud Rate:4800bps
Data Bits:8(d7=0)
Parity:None
Stop Bits:One(or more)
二、            协议
1.     语法格式
NMEA 0183的信息格式一般如下所示:
$aaaaa,df1,df2,....[CR][LF]
所有的信息由$开始,以换行结束,紧跟着$后的五个字符解释了信息的基本类型,多个参数之间用逗号隔开。
2.     协议类型
NMEA 0183中有以下三种基本的协议类型:
a)         信息源
b)        查询
c)        属性
1)     信息源
标准格式为:
$ttsss,df1,df2,....[CR][LF]
在紧随$后的两个字符用来识别作为信息内容识别码的后3个字符,信息识别码定义了保留的数据区,在NMEA 0183标准下,每个类型的数据区的信息内容是符合标准的。
例如:    $HCHDM,238,M[CR][LF]
标明“HC”说明信息源作为一个磁性的罗盘,“HDM” 指明以下是磁性的船首向航向,238是船首向航向的值,M指明船首向航向的值是磁性的。
2)     查询
标准格式为:
$ttllQ,sss,[CR][LF]
头两个字符做为请求者的信息源的识别码,后两个字符作为被查询的设备的信息识别,最后一个字符说明这是一个查询信息。紧跟着的字段(sss)包含了三个字的被查询内容的记忆信息。
查询意味着接受端需要从信息源那里得到一个有规律的内容,例如,我们可以发一个信息给GPS接受器请求传送一个“DISTANCE-TO-WAYPOINT”的信息,得到响应后,GPS接受器会发送请求的内容,直到接到别的请求。
例如:  $CCGPQ,GGA[CR][LF]
说明“CC”这个设备(计算机)正从 “GP”这个设备(GPS)查询GGA的内容。GPS将每隔一秒传送这个内容,直到有别的查询请求。
3)     属性
 这对厂商来说是一种使用没有在标准下预定义的特殊内容的方法。它通常的格式为:
$PmmmA,df1,df2,...,[CR][LF]
P说明是属性内容,mmm定义为厂商信息代码,A(A-Z)标明信息类型。
 
NMEA-0183协议定义的语句非常多,但是常用的或者说兼容性最广的语句只有$GPGGA、$GPGSA、$GPGSV、$GPRMC、$GPVTG、$GPGLL等。
3.     协议语法
1)      Global Positioning System Fix Data(GGA)GPS定位信息
$GPGGA,<1>,<2>,<3>,<4>,<5>,<6>,<7>,<8>,<9>,M,<10>,M,<11>,<12>*hh<CR><LF>
<1> UTC时间,hhmmss(时分秒)格式
<2> 纬度ddmm.mmmm(度分)格式(前面的0也将被传输)
<3> 纬度半球N(北半球)或S(南半球)
<4> 经度dddmm.mmmm(度分)格式(前面的0也将被传输)
<5> 经度半球E(东经)或W(西经)
<6> GPS状态:0=未定位,1=非差分定位,2=差分定位,6=正在估算
<7> 正在使用解算位置的卫星数量(00~12)(前面的0也将被传输)
<8> HDOP水平精度因子(0.5~99.9)
<9> 海拔高度(-9999.9~99999.9)
<10> 地球椭球面相对大地水准面的高度
<11> 差分时间(从最近一次接收到差分信号开始的秒数,如果不是差分定位将为空
<12> 差分站ID号0000~1023(前面的0也将被传输,如果不是差分定位将为空)
2)     GPS DOP and Active Satellites(GSA)当前卫星信息
$GPGSA,<1>,<2>,<3>,<3>,<3>,<3>,<3>,<3>,<3>,<3>,<3>,<3>,<3>,<3>,<4>,<5>,<6>*hh<CR><LF>
<1> 模式,M=手动,A=自动
<2> 定位类型,1=没有定位,2=2D定位,3=3D定位
<3> PRN码(伪随机噪声码),正在用于解算位置的卫星号(01~32,前面的0也将被传输)。
<4> PDOP位置精度因子(0.5~99.9)
<5> HDOP水平精度因子(0.5~99.9)
<6> VDOP垂直精度因子(0.5~99.9)
3)      GPS Satellites in View(GSV)可见卫星信息
$GPGSV,<1>,<2>,<3>,<4>,<5>,<6>,<7>,…<4>,<5>,<6>,<7>*hh<CR><LF>
<1> GSV语句的总数
<2> 本句GSV的编号
<3> 可见卫星的总数(00~12,前面的0也将被传输)
<4> PRN码(伪随机噪声码)(01~32,前面的0也将被传输)
<5> 卫星仰角(00~90度,前面的0也将被传输)
<6> 卫星方位角(000~359度,前面的0也将被传输)
<7> 信噪比(00~99dB,没有跟踪到卫星时为空,前面的0也将被传输)
注:<4>,<5>,<6>,<7>信息将按照每颗卫星进行循环显示,每条GSV语句最多可以显示4颗卫星的信息。其他卫星信息将在下一序列的NMEA0183语句中输出。
4)     Recommended Minimum Specific GPS/TRANSIT Data(RMC)推荐定位信息
$GPRMC,<1>,<2>,<3>,<4>,<5>,<6>,<7>,<8>,<9>,<10>,<11>,<12>*hh<CR><LF>
<1> UTC时间,hhmmss(时分秒)格式
<2> 定位状态,A=有效定位,V=无效定位
<3> 纬度ddmm.mmmm(度分)格式(前面的0也将被传输)
<4> 纬度半球N(北半球)或S(南半球)
<5> 经度dddmm.mmmm(度分)格式(前面的0也将被传输)
<6> 经度半球E(东经)或W(西经)
<7> 地面速率(000.0~999.9节,前面的0也将被传输)
<8> 地面航向(000.0~359.9度,以真北为参考基准,前面的0也将被传输)
<9> UTC日期,ddmmyy(日月年)格式
<10> 磁偏角(000.0~180.0度,前面的0也将被传输)
<11> 磁偏角方向,E(东)或W(西)
<12> 模式指示(仅NMEA0183 3.00版本输出,A=自主定位,D=差分,E=估算,N=数据无效)
5)     Track Made Good and Ground Speed(VTG)地面速度信息
$GPVTG,<1>,T,<2>,M,<3>,N,<4>,K,<5>*hh<CR><LF>
<1> 以真北为参考基准的地面航向(000~359度,前面的0也将被传输)
<2> 以磁北为参考基准的地面航向(000~359度,前面的0也将被传输)
<3> 地面速率(000.0~999.9节,前面的0也将被传输)
<4> 地面速率(0000.0~1851.8公里/小时,前面的0也将被传输)
<5> 模式指示(仅NMEA0183 3.00版本输出,A=自主定位,D=差分,E=估算,N=数据无效)
6)     Geographic Position(GLL)定位地理信息
$GPGLL,<1>,<2>,<3>,<4>,<5>,<6>,<7>*hh<CR><LF>
<1> 纬度ddmm.mmmm(度分)格式(前面的0也将被传输)
<2> 纬度半球N(北半球)或S(南半球)
<3> 经度dddmm.mmmm(度分)格式(前面的0也将被传输)
<4> 经度半球E(东经)或W(西经)
<5> UTC时间,hhmmss(时分秒)格式
<6> 定位状态,A=有效定位,V=无效定位
<7> 模式指示(仅NMEA0183 3.00版本输出,A=自主定位,D=差分,E=估算,N=数据无效)

 

WLAN研究起步

  • wlan的物理特性
  WLAN利用电磁波在空气中发送和接受数据,而无需线缆介质。WLAN的数据传输速率现在已经能够达到11Mbps,传输距离可远至20km以上。
  • wlan的好处

  安装便捷:一般在网络建设当中,施工周期最长、对周边环境影响最大的就是网络布线的施工了。在施工过程时,往往需要破墙掘地、穿线架管。而WLAN最大的优势就是免去或减少了这部分繁杂的网络布线的工作量,一般只要在安放一个或多个接入点(Access Point)设备就可建立覆盖整个建筑或地区的局域网络。

  使用灵活:在有线网络中,网络设备的安放位置受网络信息点位置的限制。而一旦WLAN建成后,在无线网的信号覆盖区域内任何一个位置都可以接入网络,进行通讯。

  经济节约:由于有线网络中缺少灵活性,这就要求网络的规划者尽可能地考虑未来的发展的需要,这就往往导致需要预设大量利用率较低的信息点。而一旦网络的发展超出了设计规划时的预期,又要花费较多费用进行网络改造。而WLAN可以避免或减少以上情况的发生。

  易于扩展:WLAN又多种配置方式,能够根据实际需要灵活选择。这样,WLAN能够胜任只有几个用户的小型局域网到上千用户的大型网络,并且能够提供像"漫游(Roaming)"等有线网络无法提供的特性。

  由于WLAN具有多方面的优点,其发展十分迅速。在最近几年里,WLAN已经在医院、商店、工厂和学校等不适合网络布线的场合得到了广泛的应用。
  • wlan的危害
  电磁波辐射
   还有人说会给公司和社团保密带来不利因素,因为wlan可以随时随地连接。
  • wlan的前景  
  据权威调研机构Cahners In-Stat Group预计,全球无线局域网市场将在2000年至2004年保持快速增长趋势,每年平均增长率高达25%。无线局域网市场的网卡、接入点设备及其他相关设备的总销售额也将在2000年轻松突破10亿美元大关,在2004年达到21.97亿美元。
 

[FW] Philips RC-5 Protocol

The RC-5 code from Philips is possibly the most used protocol by hobbyists, probably because of the wide availability of cheap remote controls.
The protocol is well defined for different device types ensuring compatibility with your whole entertainment system. Lately Philips started using a new protocol called RC-6 which has more features.
Features:

  • 5 bit address and 6 bit command length (7 command bits for RC5X)
  • Bi-phase coding (aka Manchester coding)
  • Carrier frequency of 36kHz
  • Constant bit time of 1.778ms (64 cycles of 36 kHz)
  • Manufacturer Philips
Modulation:

 The protocol uses bi-phase modulation (or so-called Manchester coding) of a 36kHz IR carrier frequency. All bits are of equal length of 1.778ms in this protocol, with half of the bit time filled with a burst of the 36kHz carrier and the other half being idle. A logical zero is represented by a burst in the first half of the bit time. A logical one is represented by a burst in the second half of the bit time. The pulse/pause ratio of the 36kHz carrier frequency is 1/3 or 1/4 which reduces power consumption.
Protocol:
The drawing below shows a typical pulse train of an RC-5 message. This example transmits command $35 to address $05.

The first two pulses are the start pulses, and are both logical "1". Please note that half a bit time is elapsed before the receiver will notice the real start of the message.
Extended RC-5 uses only one start bit. Bit S2 is transformed to command bit 6, providing for a total of 7 command bits. The value of S2 must be inverted to get the 7th command bit though!
The 3rd bit is a toggle bit. This bit is inverted every time a key is released and pressed again. This way the receiver can distinguish between a key that remains down, or is pressed repeatedly.
The next 5 bits represent the IR device address, which is sent with MSB first. The address is followed by a 6 bit command, again sent with MSB first.
A message consists of a total of 14 bits, which adds up to a total duration of 25 ms. Sometimes a message may appear to be shorter because the first half of the start bit S1 remains idle. And if the last bit of the message is a logic "0" the last half bit of the message is idle too.
As long as a key remains down the message will be repeated every 114ms. The toggle bit will retain the same logical level during all of these repeated messages. It is up to the receiver software to interpret this auto repeat feature.
PS: I had rather a big error on this page for quite some time. For some mysterious reason the LSB and MSB of the address and command were reversed. I can recall correcting this error before, but somehow an old version of the description must have sneaked its way up to the internet again.
Pre-defined Commands:
Philips has created a beautiful list of "standardized" commands. This ensures the compatibility between devices from the same brand.
A very nice feature, often to be missed with other brands, is the fact that most devices are available twice in the table allowing you to have 2 VCRs stacked on top of each other without having trouble addressing only one of them with your remote control.
I can only show a limited list of standard commands, for this list is about all I know right now.

RC-5
Address

Device
$00 - 0
TV1
$01 - 1
TV2
$02 - 2
Teletext
$03 - 3
Video
$04 - 4
LV1
$05 - 5
VCR1
$06 - 6
VCR2
$07 - 7
Experimental
$08 - 8
Sat1
$09 - 9
Camera
$0A - 10
Sat2
$0B - 11

$0C - 12
CDV
$0D - 13
Camcorder
$0E - 14

$0F - 15

$10 - 16
Pre-amp
$11 - 17
Tuner
$12 - 18
Recorder1
$13 - 19
Pre-amp
$14 - 20
CD Player
$15 - 21
Phono
$16 - 22
SatA
$17 - 23
Recorder2
$18 - 24

$19 - 25

$1A - 26
CDR
$1B - 27

$1C - 28

$1D - 29
Lighting
$1E - 30
Lighting
$1F - 31
Phone
 

RC-5
Command

TV Command
VCR Command
$00 - 0
0
0
$01 - 1
1
1
$02 - 2
2
2
$03 - 3
3
3
$04 - 4
4
4
$05 - 5
5
5
$06 - 6
6
6
$07 - 7
7
7
$08 - 8
8
8
$09 - 9
9
9
$0A - 10
-/--
-/--
$0C - 12
Standby
Standby
$0D - 13
Mute

$10 - 16
Volume +

$11 - 17
Volume -

$12 - 18
Brightness +

$13 - 19
Brightness -

$20 - 32
Program +
Program +
$21 - 33
Program -
Program -
$32 - 50

Fast Rewind
$34 - 52

Fast Forward
$35 - 53

Play
$36 - 54

Stop
$37 - 55

Recording

[FW] Philips RC-6 Protocol

RC-6 is, as may be expected, the successor of the RC-5 protocol. Like RC-5 the new RC-6 protocol was also defined by Philips. It is a very versatile and well defined protocol. Because of this versatility its original definition is many pages long. Here on my page I will only summarize the most important properties of this protocol.
Features:

  • Different modes of operation, depending on the intended use
  • Dedicated Philips modes and OEM modes
  • Variable command length, depending on the operation mode
  • Bi-phase coding (aka Manchester coding)
  • Carrier frequency of 36kHz
  • Manufacturer Philips
Modulation
RC-6 signals are modulated on a 36 kHz Infra Red carrier. The duty cycle of this carrier has to be between 25% and 50%.
Data is modulated using Manchester coding. This means that each bit (or symbol) will have both a mark and space in the output signal. If the symbol is a "1" the first half of the bit time is a mark and the second half is a space. If the symbol is a "0" the first half of the bit time is a space and the second half is a mark.
Please note that this is the opposite of the RC-5 protocol!
The main timing unit is 1t, which is 16 times the carrier period (1/36k * 16 = 444µs).
With RC-6 a total of 5 different symbols are defined:
  • The leader pulse, which has a mark time of 6t (2.666ms) and a space time of 2t (0.889ms). This leader pulse is normally used to set the gain of the IR receiver unit.
  • Normal bits, which have a mark time of 1t (0.444ms) and space time of 1t (0.444ms). A "0" and "1" are encoded by the position of the mark and space in the bit time. 
  • Trailer bits, which have a mark time of 2t (0.889ms) and a space time of 2t (0.889ms). Again a "0" and "1" are encoded by the position of the mark and space in the bit time.
The leader and trailer symbols are only used in the header field of the messages, which will be explained in more detail below.
RC-6 Mode 0
I can only describe operation mode 0 because I have never actually seen other modes in use than the one my Philips TV understands. The way I understand it the other modes can vary extremely from mode 0.
Mode 0 is a dedicated Philips Consumer Electronics mode. It allows control of up to 256 independent devices, with a total of 256 commands per device.


 The command is a concatenation of different information. I will cover these different components from left to right.
Header field
The Header field consists of 3 different components.
  • First the leader symbol LS is transmitted. Its purpose is to adjust the gain of the IR receiving unit.
  • This leader symbol is followed by a start bit SB which always has the value "1". Its purpose is to calibrate the receiver's timing.
  • The mode bits mb2 ... mb0 determine the mode, which is 0 in this case, thus all three bits will be "0".
  • Finally the header is terminated by the trailer bit TR. Please note that the bit time of this symbol is twice as long as normal bits! This bit also serves as the traditional toggle bit, which will be inverted whenever a key is released. This allows the receiver to distinguish between a new key or a repeated key.
Control Field
This field holds 8 bits which are used as address byte. This means that a total of 256 different devices can be controlled using mode 0 of RC-6.
The msb is transmitted first.
Information Field
The information field holds 8 bits which are used as command byte. This means that each device can have up to 256 different commands.
The msb is transmitted first.
Signal Free Time
The Signal Free time is a period in which no data may be transmitted (by any device). It is important for the receiver to detect the signal free time at the end of a message to avoid incorrect reception.
The signal free time is set to 6t, which is 2.666ms.

[FW] Philips RC-MM Protocol

RC-MM was defined by Philips to be a multi-media IR protocol to be used in wireless keyboards, mice and game pads. For these purposes the commands had to be short and have low power requirements.
Whether the protocol is actually used for these purposes today is unknown to me. What I do know is that some Nokia digital satellite receivers use the protocol (9800 series).
Features

  • 12 bits or 24 bits per message
  • Pulse position coding, sending 2 bits per IR pulse
  • Carrier frequency of 36kHz
  • Message time ranges from 3.5 to 6.5 ms, depending on data content
  • Repetition time 28 ms (36 messages per second)
  • Manufacturer Philips
Transmission timing:
RC-MM Timing


In this diagram you see the most important transmission times. The message time is the total time of a message, counting form the beginning of the first pulse until the end of the last pulse of the message. This time can be 3.5 to 6.5 ms, depending on the data content and protocol used.
The signal free time is the time in which no signal may be sent to avoid confusion with foreign protocols on the receiver's side. Philips recommends 1 ms for normal use, or 3.36 ms when used together with RC-5 and RC-6 signals. Since you can never tell whether a user has other remote controls in use together with an RC-MM controlled device I would recommend always to use a signal free time of 3.36 ms.
The frame time is the sum of the message time and the signal free time, which can add up to just about 10 ms per message.
Finally the repetition time is the recommended repetition time of 27.778 ms, which allows 36 messages per second. This is only a recommendation and is mainly introduced to allow other devices to send their commands during the dead times.
No provision is made for data collisions between two or more remote controls! This means that there is no guarantee that the messages get across.
Modulation:


With this protocol a 36 kHz carrier frequency is used to transmit the pulses. This helps to increase the noise immunity at the receiver side and at the same time it reduces power dissipated by the transmitter LED. The duty cycle of the pulses is 1:3 or 1:4.
Each message is preceded by a header pulse with the duration of 416.7 µs (15 pulses of the carrier), followed by a space of 277.8 µs (10 periods of the carrier). This header is followed by 12 or 24 bits of data.
By changing the distance between the pulses two bits of data are encoded per pulse. Below you find a table with the encoding times.
Data
Mark
Space
0 0
166.7 µs (6 cycles)
277.8 µs (10 cycles)
0 1
166.7 µs (6 cycles)
444.4 µs (16 cycles)
1 0
166.7 µs (6 cycles)
611.1 µs (22 cycles)
1 1
166.7 µs (6 cycles)
777.8 µs (28 cycles)

 
Protocol
RCMM comes in 3 different flavours, called modes. Each mode is intended for a particular purpose and differs mainly in the number of bits which can be used by the application. All data is sent with MSB first.

 
The 12 bit mode is the basic mode, and allows for 2 address bits and 8 data bits per device family. There are 3 different device families defined: keyboard, mouse and game pad.
Mode bits
Device Type
0 0
Extended mode
0 1
Mouse mode
1 0
Keyboard mode
1 1
Game pad mode
The 2 address bits provide for a way to use more than 1 device simultaneously. The data bits are the actual payload data.


The 24 bit mode, also know as extended mode, allows more data to be transmitted per message. For instance for multi-lingual keyboards or a high resolution mouse.
Mode bits
Device Type
0 0 0 0
OEM mode
0 0 0 1
Extended Mouse mode
0 0 1 0
Extended Keyboard mode
0 0 1 1
Extended Game pad mode


In the OEM mode the first 6 bits are always 0 0 0 0 1 1. The next 6 bits are the customer ID (OEM manufacturer). My observation showed that Nokia used the code 1 0 0 0 0 0  for their 9800 series digital satellite receivers.
Finally the last 12 bits are the actual pay load data.

[FW] NEC Protocol

To my knowledge the protocol I describe here was developed by NEC. I've seen very similar protocol descriptions on the internet, and there the protocol is called Japanese Format.
I do admit that I don't know exactly who developed it. What I do know is that it is used in my late VCR produced by Sanyo and was marketed under the name of Fisher. NEC manufactured the remote control IC.
This description was taken from the VCR's service manual. Those were the days, when service manuals were fulled with useful information!
Features

  • 8 bit address and 8 bit command length
  • Address and command are transmitted twice for reliability
  • Pulse distance modulation
  • Carrier frequency of 38kHz
  • Bit time of 1.12ms or 2.25ms
Modulation:
The NEC protocol uses pulse distance encoding of the bits. Each pulse is a 560µs long 38kHz carrier burst (about 21 cycles). A logical "1" takes 2.25ms to transmit, while a logical "0" is only 1.12ms. The recommended carrier duty-cycle is 1/4 or 1/3.
Protocol:


The picture above shows a typical pulse train of the NEC protocol. With this protocol the LSB is transmitted first. In this case Address $59 and Command $16 is transmitted. A message is started by a 9ms AGC burst, which was used to set the gain of the earlier IR receivers. This AGC burst is then followed by a 4.5ms space, which is then followed by the Address and Command. Address and Command are transmitted twice. The second time all bits are inverted and can be used for verification of the received message. The total transmission time is constant because every bit is repeated with its inverted length. If you're not interested in this reliability you can ignore the inverted values, or you can expand the Address and Command to 16 bits each!



A command is transmitted only once, even when the key on the remote control remains pressed. Every 110ms a repeat code is transmitted for as long as the key remains down. This repeat code is simply a 9ms AGC pulse followed by a 2.25ms space and a 560µs burst.



Example Commands
The table below lists the messages sent by the remote control of my late Fisher 530 VCR (it served us well during its 20 years long life).
NEC Message
Key Function
$68-$00
Play
$68-$01
Rec
$68-$02
Audio Dub
$68-$03
Frame Adv
$68-$04
Slow
$68-$05
Quick
$68-$06
Cue
$68-$07
Review
$68-$08
FF
$68-$09
Rew
$68-$0A
Stop
$68-$0B
Pause/Still
$68-$0C
Up key
$68-$1E
Down key

什么是aspect ratio

 今天本来打算写写关于屏幕高宽比的话题,但是我一个朋友发了个连接,觉得图文并茂,写得不错。不仅很好地说明了aspect ratio而且还可以帮助大家更好地欣赏电影。
http://www.mov8.com/dvd/freetalk_show.asp?id=5761

SAX与DOM之间的区别

 

SAX (Simple API for XML) DOM (Document Object Model) 是当前两个主要的XML API,几乎所有商用的xml 解析器都同时实现了这两个接口。因此如果你的程序使用了SAX或者DOM APIs,那么你的程序对xml解析器是透明。
1. DOM以一个分层的对象模型来映射xml文档。而SAX将文档中的元素转化为对象来处理。
2. DOM将文档载入到内存中处理,而SAX则相反,它可以检测一个即将到来的 XML流,由此并不需要所有的XML代码同时载入到内存中。
 
SAX 处理是如何工作的
     SAX 
在读取 XML 流的同时处理它们,这很像以前的自动收报机纸带(ticker tape)。请考虑下面的 XML 代码片断:
<?xml version="1.0"?>
<samples>
   <server>UNIX</server>
   <monitor>color</monitor>
</samples>
     
分析这个代码片断的 SAX 处理器一般情况下将产生以下事件: 
Start document
Start element (samples)
Characters (white space)
Start element (server)
Characters (UNIX)
End element (server)
Characters (white space)
Start element (monitor)
Characters (color)
End element (monitor)
Characters (white space)
End element (samples)
SAX API 
允许开发人员捕捉这些事件并对它们作出反应。
     SAX 
处理涉及以下步骤:
     1.
创建一个事件处理程序。 
     2.
创建 SAX 解析器。 
     3.
向解析器分配事件处理程序。 
     4.
解析文档,同时向事件处理程序发送每个事件。 
     
基于事件的处理的优点和缺点
     
这种处理的优点非常类似于流媒体的优点。分析能够立即开始,而不是等待所有的数据被处理。而且,由于应用程序只是在读取数据时检查数据,因此不需要将数据存储在内存中。这对于大型文档来说是个巨大的优点。事实上,应用程序甚至不必解析整个文档;它可以在某个条件得到满足时停止解析。一般来说,SAX 还比它的替代者 DOM 快许多。
另一方面,由于应用程序没有以任何方式存储数据,使用 SAX 来更改数据或在数据流中往后移是不可能的。
     DOM 
和基于树的处理
     DOM 
是处理 XML 数据的传统方法。使用 DOM 时,数据以树状结构的形式被加载到内存中。
     
例如,在“SAX 处理是如何工作的”中用作例子的相同文档在 DOM 中将表示为节点,DOM 使用父子关系。
     
基于树的处理的优点和缺点
     DOM 
以及广义的基于树的处理具有几个优点。首先,由于树在内存中是持久的,因此可以修改它以便应用程序能对数据和结构作出更改。它还可以在任何时候在树中上下导航,而不是像 SAX 那样是一次性的处理。DOM 使用起来也要简单得多。
另一方面,在内存中构造这样的树涉及大量的开销。大型文件完全占用系统内存容量的情况并不鲜见。此外,创建一棵 DOM 树可能是一个缓慢的过程。
     
如何在 SAX  DOM 之间选择
     
选择 DOM 还是选择 SAX,这取决于下面几个因素:
1.
应用程序的目的:如果打算对数据作出更改并将它输出为 XML,那么在大多数情况下,DOM 是适当的选择。并不是说使用 SAX 就不能更改数据,但是该过程要复杂得多,因为您必须对数据的一份拷贝而不是对数据本身作出更改。 
2.
数据容量: 对于大型文件,SAX 是更好的选择。 
数据将如何使用:如果只有数据中的少量部分会被使用,那么使用 SAX 来将该部分数据提取到应用程序中可能更好。 另一方面,如果您知道自己以后会回头引用已处理过的大量信息,那么 SAX 也许不是恰当的选择。 
3.
对速度的需要: SAX 实现通常要比 DOM 实现更快。 
SAX 
 DOM 不是相互排斥的,记住这点很重要。您可以使用 DOM 来创建 SAX 事件流,也可以使用 SAX 来创建 DOM 树。事实上,用于创建 DOM 树的大多数解析器实际上都使用 SAX 来完成这个任务!

 

怎么调试perl程序(1)

Usage: C:\Perl\bin\perl.exe [switches] [--] [programfile] [arguments]

  -0[octal]       specify record separator (\0, if no argument)

  -a              autosplit mode with -n or -p (splits $_ into @F)

  -C              enable native wide character system interfaces

  -c              check syntax only (runs BEGIN and CHECK blocks)

  -d[:debugger]   run program under debugger

  -D[number/list] set debugging flags (argument is a bit mask or alphabets)

  -e 'command'    one line of program (several -e's allowed, omit programfile)

  -F/pattern/     split() pattern for -a switch (//'s are optional)

  -i[extension]   edit <> files in place (makes backup if extension supplied)

  -Idirectory     specify @INC/#include directory (several -I's allowed)

  -l[octal]       enable line ending processing, specifies line terminator

  -[mM][-]module  execute `use/no module...' before executing program

  -n              assume 'while (<>) { ... }' loop around program

  -p              assume loop like -n but print line also, like sed

  -P              run program through C preprocessor before compilation

  -s              enable rudimentary parsing for switches after programfile

  -S              look for programfile using PATH environment variable

  -T              enable tainting checks

  -u              dump core after parsing program

  -U              allow unsafe operations

  -v              print version, subversion (includes VERY IMPORTANT perl info)

  -V[:variable]   print configuration summary (or a single Config.pm variable)

  -w              enable many useful warnings (RECOMMENDED)

  -W              enable all warnings

  -X              disable all warnings

  -x[directory]   strip off text before #!perl line and perhaps cd to directory 

怎么调试perl程序(2)

什么是调试程序

P e r l调试程序是个P e r l解释程序的内置特性。它使你能够取出任何一个P e r l程序,然后逐个语句运行该程序。在运行过程中,你可以查看各个变量,修改这些变量,中断程序的运行,或者从头开始运行该程序,设置断点,输出你的函数调用堆栈,修改变量值等等。任何调试器不能识别的命令都会当作正在被调试的包里面的 Perl 代码直接执行(用 eval)。(调试器使用 DB 包存储自己的状态信息,以避免破坏你的程序的状态。)这个功能非常好用,以至于有时候人们经常使用调试器来交互地测试 Perl 的构造。这时候,它不在乎你让 Perl 调试什么程序。
从你的程序角度来看,它与普通程序并无区别。输入仍然来自键盘,输出仍然送往屏幕。程序并不知道何时停止运行,何时它正在运行。实际上,你可以观察程序的运行情况,根本不必中断程序的运行。

怎么调试perl程序(3)

启动调试程序

若要启动P e r l调试程序,必须打开操作系统的命令提示符。如果你是D O SWi n d o w s用户,那么要打开M S - D O S的标准提示符C : \。如果是U N I X用户,这个提示符应该是你登录时显示的提示符(通常是%或$)。对于运行P e r lM a c i n t o s h用户来说,只需从S c r i p t菜单中选定D e b u g g e r。这时就会为你打开带有提示符的D e b u g g e r窗口。

若要在提示符处启动调试程序(本例中使用D O S提示符),请键入下面这行命令:

> perl -d XPath.pl stocks.xml

P e r l- d开关可使P e r l以调试方式启动运行。命令行上也指明了被调试的程序。然后显示关于版本信息的某些消息,如下所示:

Loading DB routines from perl5db.pl version 1.22

Editor support available.

 

Enter h or `h h' for help, or `perldoc perldebug' for more help.

 

main::(XPath.pl:5):     my $filename = shift;

  DB<1>

该调试程序首先显示版本号( 1 . 0 4 0 1,你的版本号可能不一样)和help (帮助)提示。接着显示该程序的第一行可执行代码。说明它们来自什么文件(XPath.pl),以及它们是在文件的哪一行或哪几行上找到的(第5行)。

最后,你看到调试文件的提示符D B < 1 >。这里面的数字显示你执行了多少命令。一个类似 csh 的历史机制可以让你通过数字访问前面的命令。比如 17 将重复命令数为 17 的命令。尖括号的数目表示调试器的深度。比如,如果你已经在一个断点了,然后又打印一个函数调用的结果,而且那个函数里面也有一个断点,那么你就会看到多于一对尖括号。调试程序提示符后面的光标正等待你输入命令。

这时,你的P e r l程序实际上暂停在第一个指令-my $filename的前面。每当调试程序向你显示程序中的一个语句时,它就是准备要执行的语句,而不是上一个运行的语句。

现在调试程序已经作好准备,等待你输入命令。