Friday, February 27, 2009

HTTP Header Field: BlackBerry Browser VS Opera Mini

BlackBerry:

GET / HTTP/1.0
Host: (host ip:port)
User-Agent: BlackBerry8830/4.5.0.77 Profile/MIDP-2.0 Configuration/CLDC-1.1 VendorID/126
Accept: application/vnd.rim.html,text/html,application/xhtml+xml,application/vnd.wap.xhtml+xml,text/vnd.sun.j2me.app-descriptor,image/vnd.rim.png,image/jpeg,application/x-vnd.rim.pme.b,image/gif;anim=1,application/vnd.wap.wmlc;q=0.9,application/vnd.wap.wmlscriptc;q=0.7,text/vnd.wap.wml;q=0.7,*/*;q=0.5
Accept-Language: en-US,en;q=0.5
Accept-Charset: ISO-8859-1,UTF-8,US-ASCII,UTF-16BE,windows-1252,UTF-16LE,windows-1250
Connection: keep-alive
profile: http://www.blackberry.net/go/mobile/profiles/uaprof/8830/4.5.0.rdf
Via: BISB_3.4.0.45, 1.1 pmds67.bisb1.blackberry:3128 (squid/2.5.STABLE12)
Cache-Control: max-age=259200
x-wap-profile: "http://www.blackberry.net/go/mobile/profiles/uaprof/8830/4.5.0.rdf"
X-Forwarded-For: unknown


Opera Mini:

GET / HTTP/1.1
Host: (host ip:port)
User-Agent: Opera/9.60 (J2ME/MIDP; Opera Mini/4.2.13337/670; U; en) Presto/2.2.0
Accept: text/html, application/xml;q=0.9, application/xhtml+xml, image/png, image/jpeg, image/gif, image/x-xbitmap, */*;q=0.1
Accept-Language: en,en;q=0.9
Accept-Charset: iso-8859-1, utf-8, utf-16, *;q=0.1
Accept-Encoding: deflate, gzip, x-gzip, identity, *;q=0
Connection: Keep-Alive
X-OperaMini-Features: advanced, file_system, folding
X-OperaMini-Phone-UA: BlackBerry
X-OperaMini-Phone: RIM #
x-forwarded-for: (some ip)

Tuesday, February 17, 2009

Java Serial Port Communication(javacomm) in 4 steps

These steps apply to Windows environment only:
1.) download javacomm20-win32.zip
2.) extract comm.jar to ..\jre\lib\ext
3.) extract javax.comm.properties to ..\jre\lib folder
4.) extract win32comm.dll to c:\windows


import java.util.Enumeration;
import javax.comm.CommPortIdentifier;

public class JavaCommTest {
public static void main(String[] ap) {
Enumeration pList = CommPortIdentifier.getPortIdentifiers();

while (pList.hasMoreElements()) {
CommPortIdentifier cpi = (CommPortIdentifier) pList.nextElement();
System.out.print("Port " + cpi.getName() + " ");
if (cpi.getPortType() == CommPortIdentifier.PORT_SERIAL) {
System.out.println("is a Serial Port: " + cpi);
} else if (cpi.getPortType() == CommPortIdentifier.PORT_PARALLEL) {
System.out.println("is a Parallel Port: " + cpi);
} else {
System.out.println("is an Unknown Port: " + cpi);
}
}
}
}



Here are the outputs of the above snippet if missing:

win32comm.dll - Error loading win32com: java.lang.UnsatisfiedLinkError: no win32com in java.library.path

javax.comm.properties - pList would return false at hasMoreElements()