Wednesday, December 28, 2011

FW: File size limit exceeded error under Linux and solution

[1] From Cyberciti.biz

File size limit exceeded error under Linux and solution

$ulimit -a

core file size (blocks, -c) 0
data seg size (kbytes, -d) unlimited
file size (blocks, -f) unlimited
max locked memory (kbytes, -l) 64
max memory size (kbytes, -m) unlimited
open files (-n) 1024
pipe size (512 bytes, -p) 8
stack size (kbytes, -s) 8192
cpu time (seconds, -t) unlimited
max user processes (-u) 227
virtual memory (kbytes, -v) unlimited

Monday, September 26, 2011

String processing in C++ using string library

[1] String library in C++ library.
[2] Get decimalhttp://www.blogger.com/img/blank.gif value from string.
[3] iStringStream Class in C++ library.
[4] iStringStream operator.
[5] Print hex value in C++
[6] IP address validation using GNU C++ library.
[7]String to number and vice versa in C++/C Lib.



IP ADDRESS VALIDATION [6]
-------------------------
inet_ntop(), inet_pton().



//------------------------------------------------------

// IPv4 demo of inet_ntop() and inet_pton()

struct sockaddr_in sa;
char str[INET_ADDRSTRLEN];

// store this IP address in sa:
inet_pton(AF_INET, "192.0.2.33", &(sa.sin_addr));

// now get it back and print it
inet_ntop(AF_INET, &(sa.sin_addr), str, INET_ADDRSTRLEN);

printf("%s\n", str); // prints "192.0.2.33"


//-----------------------------

// IPv6 demo of inet_ntop() and inet_pton()
// (basically the same except with a bunch of 6s thrown around)

struct sockaddr_in6 sa;
char str[INET6_ADDRSTRLEN];

// store this IP address in sa:
inet_pton(AF_INET6, "2001:db8:8714:3a90::12", &(sa.sin6_addr));

// now get it back and print it
inet_ntop(AF_INET6, &(sa.sin6_addr), str, INET6_ADDRSTRLEN);

printf("%s\n", str); // prints "2001:db8:8714:3a90::12"


//--------------------------------------------------------

// Helper function you can use:

//Convert a struct sockaddr address to a string, IPv4 and IPv6:

char *get_ip_str(const struct sockaddr *sa, char *s, size_t maxlen)
{
switch(sa->sa_family) {
case AF_INET:
inet_ntop(AF_INET, &(((struct sockaddr_in *)sa)->sin_addr),
s, maxlen);
break;

case AF_INET6:
inet_ntop(AF_INET6, &(((struct sockaddr_in6 *)sa)->sin6_addr),
s, maxlen);
break;

default:
strncpy(s, "Unknown AF", maxlen);
return NULL;
}

return s;
}




STRING PROCESSING IN C 'atoi','atof','sscanf' [2]
--------------------------
The old C way (deprecated):



const char* str_int = "777";
const char* str_float = "333.3";
int i = atoi(str_int);
float f = atof(str_float);


A better way:

const char* str_int = "777";
const char* str_float = "333.3";
int i;
float f;

if(EOF == sscanf(str_int, "%d", &i))
{
//error
}

if(EOF == sscanf(str_float, "%f", &f))
{
//error
}





STRING PROCESSING IN C++ USING 'istringstream' CLASS[2][3]
--------------------------


#include
#include
#include

template
bool from_string(T& t,
const std::string& s,
std::ios_base& (*f)(std::ios_base&))
{
std::istringstream iss(s);
return !(iss >> f >> t).fail();
}

int main()
{
int i;
float f;

// the third parameter of from_string() should be
// one of std::hex, std::dec or std::oct
if(from_string(i, std::string("ff"), std::hex))
{
std::cout << i << std::endl;
}
else
{
std::cout << "from_string failed" << std::endl;
}

if(from_string(f, std::string("123.456"), std::dec))
{
std::cout << f << std::endl;
}
else
{
std::cout << "from_string failed" << std::endl;
}
return 0;
}

/* output:
255
123.456
*/




STRING PROCESSING IN C++ BUILDER
-----------------------------------


//Text.SubString(1,2).c_str()
sprintf(lcTemp, "%s", Pan1Edit2PacMac->Text.SubString(1,2).c_str());

//Text.ToInt()
lsPacHwRev.HwRevChkSum=Pan1Edit4NewHwRev->Text.ToInt()+0xFF;

//AnsiString::IntToHex(addr,2)
Memo1ScreenPrint->Lines->Add("Mac Address Retrieved from PAC: "+
AnsiString(SPACPacketPtr->Source));
Memo1ScreenPrint->Lines->Add(AnsiString::IntToHex(ptrlsPacMacAddr->macAddr1,2)+
"-"+AnsiString::IntToHex(ptrlsPacMacAddr->macAddr2,2)+
"-"+AnsiString::IntToHex(ptrlsPacMacAddr->macAddr3,2)+
"-"+AnsiString::IntToHex(ptrlsPacMacAddr->macAddr4,2)+
"-"+AnsiString::IntToHex(ptrlsPacMacAddr->macAddr5,2)+
"-"+AnsiString::IntToHex(ptrlsPacMacAddr->macAddr6,2));
Memo1ScreenPrint->Lines->Add(" at: "+AnsiString(asctime(tblock)));

//AnsiString(text).AnsiPos("KeyWords")
lcTemp=AnsiString(lsStringBuffer).AnsiPos("OK");
if (lcTemp==0)
lcTemp=AnsiString(lsStringBuffer).AnsiPos("0");





//validate and decode ip address string
#include sys/types.h
#include sys/socket.h
#include arpa/inet.h



//To validate and decode ip address
std::string str3="";
size_t pos,posLast;
struct sockaddr_in sa;
char str[INET_ADDRSTRLEN];
int liRet;


//Check whether it's valid IP address
liRet=inet_pton(AF_INET,pszVal,&(sa.sin_addr));
if(liRet<0){
std::cout<<"Error: Only IpV4 address is supported"<}else if(liRet==0){
std::cout<<"Illegal IpV4 address string"<}else{
inet_ntop(AF_INET,&(sa.sin_addr),str,INET_ADDRSTRLEN);
std::cout<}


posLast=0;
pos=0;
//for(int j=0;j<4;j++){
// pos = std::string(pszVal).find(".",pos); // position of "." in str
// str3 = std::string(pszVal).substr (posLast,pos-posLast); // get from f"live" to the end
// from_string(lRealValue, str3, std::dec);
// std::cout<<"part "<// posLast=pos+1;
// pos++;
}





Thursday, September 22, 2011

Highlight your source code in blog

[1] http://alexgorbatchev.com/SyntaxHighlighter/hosting.html
[2] http://alexgorbatchev.com/SyntaxHighlighter/download/
[3] How to add brush:cpp into your blog



 

Wednesday, September 21, 2011

Read and parse ini file in C++


[1] A couple of tools to read and parse ini file.
[2]Stackoverflow Q&A for programmers.
[3] WiKi page on introduction of 'ini' file.
[4] SimpleIni library that support Window,WinCE, Linux


ini file is commonly used for configuration storage. So it can replace binary data you stored in EEPROM for configuration purpose once you system is supporting file system.



RUNNING SIMPLEINI ON LINUX TARGET BOARD
------------------------------------------

[q.yang@localhost Sample_023_SimpleIni_FileReader]$ cat Makefile
PROGRAM=testsi
DEBUG = -g
CFLAGS = -Wall -c $(DEBUG)
INCL = -I $(LTIB_LINUX_KERNEL_PATH)/include

CC=g++
CFLAGS=-Wall
CPPFLAGS=-Wall

OBJS=testsi.o test1.o snippets.o ConvertUTF.o

help:
@echo This makefile is just for the test program \(use \"make clean all test\"\)
@echo Just include the SimpleIni.h header file to use it.

all: $(PROGRAM)

$(PROGRAM): $(OBJS)
$(CC) -o $(PROGRAM) $(OBJS)

./%.o:./%.cpp
$(CC) -c $(CFLAGS) $< -o $@ $(INCL)

clean:
rm -f core *.o $(PROGRAM)

data:
sed 's/\r\n$$/\n/g' < test1-expected.ini > unix.out
mv unix.out test1-expected.ini

test: testsi
./testsi -u -m -l test1-input.ini > test1-blah.ini
diff test1-output.ini test1-expected.ini

install:
@echo No install required. Just include the SimpleIni.h header file to use it.

testsi.o test1.o snippets.o : SimpleIni.h


SAMPLE CODE TO USE SIMPLEINI
-----------------------------------
Load *.ini file pointed by 'pszFile'


const TCHAR * pszFile;
bool bIsUtf8, bUseMultiKey, bUseMultiLine;

TestGateWayCfg(pszFile, bIsUtf8, bUseMultiKey, bUseMultiLine);

static bool TestGateWayCfg(const TCHAR *a_pszFile,bool a_bIsUtf8,bool a_bUseMultiKey,bool a_bUseMultiLine)
{
//----CSimpleIni GateWayCfgIni(a_bIsUtf8, a_bUseMultiKey, a_bUseMultiLine)-------------------
//---------------GateWayCfgIni.LoadFile(a_pszFile)-------------------------------------------
// load the file
CSimpleIni GateWayCfgIni(a_bIsUtf8, a_bUseMultiKey, a_bUseMultiLine);
_tprintf(_T("Loading file: %s\n"), a_pszFile);
SI_Error rc = GateWayCfgIni.LoadFile(a_pszFile);
if (rc < 0) {
printf("Failed to open file.\n");
return false;
}

//Read and print out values read from all keys
//All keys,values,comments will be buffered in instanse of 'GateWayCfgIni'.
_tprintf(_T("\n\n\n\n-----------scan and display all key and values-----------------\n"));
QuentinScanIniFile(GateWayCfgIni);
}



'GateWayCfgIni' stores a clone copy of all comments,sections,keys and values of *.ini file.

Analyze and display sections, keys, values in *.ini file.


static void QuentinScanIniFile(CSimpleIni &ini)
{
const TCHAR *pszSection = 0;
const TCHAR *pItem = 0;
const TCHAR *pszVal = 0;

//------GetValue-======-------------------------------------------
// get the value of the key "LogLevel" in section "ManufactureCfg"
bool bHasMulti;
pszVal = ini.GetValue(_T("ManufactureCfg"), _T("LogLevel"), 0, &bHasMulti);
_tprintf(_T("\n-- Value of ManufactureCfg::LogLevel is '%s' (hasMulti = %d)\n"),
pszVal ? pszVal : _T("(null)"), bHasMulti);

//------GetSectionSize-----------------------------------------------
// get the size of the section [ManufactureCfg]
_tprintf(_T("\n-- Number of keys in section [ManufactureCfg] = %d\n"),
ini.GetSectionSize(_T("ManufactureCfg")));

//------GetAllKeys------------------------------------------------
// get the list of all key names for the section "ManufactureCfg"
_tprintf(_T("\n-- Dumping keys of section: [ManufactureCfg]\n"));
CSimpleIni::TNamesDepend keys;

ini.GetAllKeys(_T("ManufactureCfg"), keys);
// dump all of the key names
CSimpleIni::TNamesDepend::const_iterator iKey = keys.begin();
for ( ; iKey != keys.end(); ++iKey ) {
pItem = iKey->pItem;
_tprintf(_T("Key: %s\n"), pItem);
}

//------GetAllSections------------------------
// iterate through every section in the file
_tprintf(_T("\n-- Dumping all sections\n"));
CSimpleIni::TNamesDepend sections;

ini.GetAllSections(sections);
CSimpleIni::TNamesDepend::const_iterator iSection = sections.begin();
for ( ; iSection != sections.end(); ++iSection ) {
pszSection = iSection->pItem;

// print the section name
printf("\n");
if (*pszSection) {
_tprintf(_T("[%s]\n"), pszSection);
}

// if there are keys and values...
const CSimpleIni::TKeyVal * pSectionData = ini.GetSection(pszSection);
if (pSectionData) {
//-------------------------------------------------------
// iterate over all keys and dump the key name and value
CSimpleIni::TKeyVal::const_iterator iKeyVal = pSectionData->begin();
for ( ;iKeyVal != pSectionData->end(); ++iKeyVal) {
pItem = iKeyVal->first.pItem;
pszVal = iKeyVal->second;
_tprintf(_T("%s=%s\n"), pItem, pszVal);
}
}
}
}

Monday, September 19, 2011

Watchdog in Embedded Linux

[1] Embedded Freak

To use watchdog peripheral in Linux, you will need:
Watchdog driver: Most of board suppliers will provide you for free (ask their support if you need to). This article is using EA3131 Linux BSP’s provided watchdog driver.
Watchdog device file: Device file is a special kind of file to mark the device node in your root filesystem (so you can access the peripheral like accessing file..’everything is a file’ in UNIX system). Normally it is called ‘/dev/watchdog’

RESULT OF RUNNING DEMO FROM [1] ON LPC3240 BOARD
---------------------------------------------------
[root@LIQ-GateWay user]# ./WatchDogTest
Current watchdog interval is 19
Last boot is caused by : Power-On-Reset
Use:
< w > to kick through writing over device file
< i > to kick through IOCTL
< x > to exit the program
w
Kick watchdog through writing over device file
Unknown command
w
Kick watchdog through writing over device file
Unknown command
i
Kick watchdog through IOCTL
Unknown command
i
Kick watchdog through IOCTL
Unknown command

Friday, September 16, 2011

FW: Become a Good Programmer in Six Really Hard Steps

Become a Good Programmer in Six Really Hard Steps


Step One: Suck It Up. Get in it for the long haul, or take up bird watching.Sure, you can fiddle around and make nifty shell scripts and maybe a small game or four; if you're content with a limited skill set, by all means go for the fast-and-easy route. I'm not trying to diminish the legitimacy of that option at all - some people don't have the time (or even the desire) to become a master programmer. If you don't relish the idea of practicing this craft for ten years before you get good at it, then don't bother - but don't be fooled, you'll always be limited in what you can do and do well. If that is a reasonable trade-off for you, cool! You don't need to finish this article.

For the rest of us, though, there's something alluring about getting Really Good at programming. We want to be experts, ninjas, gurus - whatever noun of superlative mastery strikes your fancy. For us, ten years seems like a reasonable investment. Maybe a bit hefty, but hey, if it's worth doing, it's worth doing right... right?

So the first step to being a really good programmer is to bite the bullet. Accept that this is not just a ten year process, but a lifetime process. And as Norvig so rightly notes, do it because you want to. Nobody becomes exceptionally good at doing something they'd rather not be doing; the world record holders don't make it into the history books because they kind of accidentally ate the most hotdogs ever in one sitting, but didn't actually feel hungry that day.


Step Two: Write Lots of Code
It doesn't have to be good code. It won't be good code, for a long time. Just crank stuff out. Any time you encounter a small annoyance in your daily computer life, think about how you could write a program to help solve that problem. Any time you find something interesting that you want to experiment with, do it. Play with new concepts and tools and languages, as much as possible.

The learning process is never going to stop, so if you approach this with the attitude that you get the most mileage out of cramming as much learning as you can into a given day, you will go far. Get into the mentality that a day/week/month in which you have not learned something interesting is a failure. There's enough stuff out there that you surely can learn something cool every day; this gets harder after the fifteen year mark or so, but it's still totally possible. No one mortal can assimilate all of the knowledge there is in the world about programming, so if you ever feel like you've run out of stuff to learn, find a new project and write more code.

While you're doing this, pay attention. Look for patterns - things you do often that might be useful to automate, or things you write a lot in your code that you might be able to separate into shared libraries or other centralized locations. Look for languages that make certain tasks easy. Look for other languages that aren't so good at those same tasks, and figure out why one is more productive than the other.

But most of all: write code. Every day, even if it's just a regular expression to search through your email history or something. Do something programming-ish as often as you can. And remember, if this stops being fun, go do something else; there's no point in this if you aren't enjoying yourself.


Step Three: Read Even More Code
Once you have a small body of projects accumulated, start reading other people's code. At first, it will be difficult; they will do things you haven't seen before, or use styles you aren't used to, or even languages you haven't learned. If you find something cool, read its code if at all possible. Don't worry about deeply analyzing any given project, at least not at first; it can be a full-time job just to understand existing code bases like those of many large projects. Pick one or two things that you wish you could learn how to do, and find out how they were done.

Reading new code exposes you to ways of thinking that are new, and this helps stretch your brain. Stretching is vital to keeping up progress, and it will help ensure that as you go along you keep discovering new stuff to learn.

Be sure to talk to other programmers, too. Ask how and why they did certain things. Ask if they would do things differently in retrospect. Ask if they have any suggestions for your code. (But be polite; a lot of high-profile programmers are extremely busy and don't necessarily have the time or inclination to dredge through other people's work for free. Respect will carry you a long way; this is a tight-knit industry and reputation means a lot.)


Step Four: Learn Many Languages. Master a Couple.
You will not have a practical surplus of time, at least not enough to master many languages simultaneously, unless you are exceedingly lucky. Therefore, learn as many languages as you can at a shallow level - enough to learn what makes them tick, what makes them good at their specific jobs, and what their weaknesses are. Stretching is important here; don't just stick to imperative languages like C, or "object oriented" languages like Java, or whatnot; expand into functional languages and declarative languages as well.

Learn a Lisp dialect. This is why. It won't do anything for your day-to-day programming, because you aren't going to use it; but it will make you a better thinker, and it will give you a deep understanding of the beauty of simple recursive systems. Stick with it until the "aha!" moment occurs; until then, it will seem like a soup of weird syntax and bizarre conventions. After that, it will remain with you for the duration of your career as one of the most astoundingly elegant concepts ever devised by mankind.

Then, learn a purely functional language. I recommend Haskell for this, because it forces you to be pure in ways that other functional languages (including most Lisp dialects) do not. You will have to bend your mind a bit, but once the inevitable "aha!" moment occurs (sometime around the point where you understand the purpose of monads, in my experience) you will again move forward a level in your thinking and ability to design elegant systems.

Finally, learn a declarative language. SQL counts, although it's a bit weak-sauce to just learn SQL. Prolog is often recommended, but isn't necessarily hugely accessible. In the realm of the practical, XAML, XSLT, and XQuery are good tools to know, and will introduce you to the concepts behind declarative programming. (In a nutshell, you tell the computer what you want it to do, and it figures it out; this is in direct contrast to imperative programming, where you tell the computer how to do things and hope it does the right "what", and functional programming, in which you describe transformations of data and types.)

As a bonus, learning XML-based tools after you learn a Lisp dialect will make it painfully obvious how desperately hard XML is trying to reinvent s-expressions, and just how poor a job it does.

Thursday, August 25, 2011

61850 Learing and Practice

[1] Syscorp demo DLL
[2] Syscorp 61850 API on-line Manual
[3] Latest WinPcap download
[4] WinPcap/libpcap intro on WiKipedia
[5] Syscorp 61850 on youtube
[6] SISCO 61850 solution

NOTES FROM READING 61850 STANDARD
--------------------------------------------
1. IEC61850_QUALITY_XXXX in 61850-8-1 2004. section 8.2


Logical Device (LD)
Object representing a group of functions, each function is defined
as a logical node. A physical device consists of one or several
LDs.

Logical Node (LN)
An object defined by its data and methods. LN is the smallest
part of a function that exchanges data.

Data Object (DO)
A data object is an instance of one of the IEC 61850 Common
Data Classes, for example single point status, measured value
etc. Depending on the class, each data object has a set of
attributes for monitoring and controlling the object, for instance
value, quality and control.


Data Set (DS)
The data set is the content basis for reporting and logging. The
data set contain references to the data and data attribute values.

Report Control Block (RCB)
The report control block controls the reporting process for event
data as they occur. The reporting process continues as long as
the communication is available.



Attributes
Predefined object that contains items for controlling or retrieving
status information for the parent object. The parent object can
be the Server, a Subnetwork, or a Device object.

IEC 61850 Device (IEC 61850 IED)
Object representing a physical IEC 61850 protection and control
device. You should not have more than 30 devices per each
subnetwork.




Q&A
-------------------
1. How historical data from 61850 device are handled in 61850 stack?

2. When some LD/LN not installed how 61850 stack handle that? (new *.ICD file for each different installation?)

3. For DNP3 integration poll will find out all available points. How about 61850?





NOTES OF READING servermain.c, iec61850api.h
-------------------------------------------------
Customer need to maintain its own local data storage. 61850 stack just get
data dynamically from customer's local data stroage by loopback_read, and update customer's local data storage by loopback_write.

When there's new data updated in customer's local data storage, customer need use update() to get 61850 stack updated with new value. Then 61850 stack will do GOOSE,
buffered report, unbuffered report, sample value, log. See 61850 API user manual.


PRACTICE ENABLE LOG CONTROL
-----------------------------
When enabling log control, has to choose 'log name' and 'data set'.


PRACTICE ADD 'generic private id' WITH 5 fields
----------------------------------------------
Inside any DA, we can add 'generic private id' which will allow us to further define values of 5 fields. Those 5 fields will uniquely identify any DA ID. Thus, we use those 5 fields to interact with Syscorp 61850 stack.


PRACTICE GET DEMO RUN
-----------------------
If having -19 error reported when running ServerDemo61850.exe. Update of WinPcap to latest 4.1.2 version will solve the problem. [1]




TREE CHART OF DEMO SERVER 61850 ICD FILE
------------------------------------------









Monday, August 22, 2011

Java call C function

[1] One Pdf document 'Java call C via JNI'
[2] Sun link of using JNI
[3] Java call C on power PC
[4] Sun book of JNI
[5] JNI and JNA in Wiki
[6] JNA intro on wiki
[7] where to download jna.jar

The JNA library uses a small native library called foreign function interface library (libffi) to dynamically invoke native code. [6]



Java Native Interface[5]

The Java Native Interface has a high overhead associated with it, making it costly to cross the boundary between code running on the JVM and native code.[69][70] Java Native Access (JNA) provides Java programs easy access to native shared libraries (DLLs on Windows) without writing anything but Java code—no JNI or native code is required. This functionality is comparable to Windows' Platform/Invoke and Python's ctypes. Access is dynamic at runtime without code generation. But it comes with a cost and JNA is usually slower than JNI.[71]

Tuesday, August 9, 2011

Using Scp under windows.

[1] WinScp
[2] scp that come with putty, which is not working with DropBear SSH server.

Sunday, August 7, 2011

C Call Java function under Linux/Windows

[1] Ref from codeproject



[q.yang@localhost CTest]$ ll
total 16
-rwxr--r-- 1 q.yang developer 7298 2011-08-05 15:03 CTest.cpp
drwxr-xr-x 2 q.yang developer 4096 2011-08-08 11:31 debug
-rwxr--r-- 1 q.yang developer 838 2011-08-08 11:32 makefile
[q.yang@localhost CTest]$ echo $JAVA_HOME
/usr/java/default
[q.yang@localhost CTest]$ pwd
/home/q.yang/EclipseCDT/qywkspace/Sandbox/Sample_017_CCallJava_via_JNI/CTest
[q.yang@localhost CTest]$ cat makefile
DESTDIR = ./debug
PROGRAM = $(DESTDIR)/CCallJava
SRCDIR = ./
CC = g++
OBJS := $(addprefix $(DESTDIR)/,CTest.o)
DEBUG = -g
CFLAGS = -Wall -c $(DEBUG) -D GSN_HOST_NOT_SUPPORT_RD_CONFIG
INCL = -I ./include -I $(JAVA_HOME)/include -I $(JAVA_HOME)/include/linux
LIB_FLAGS = -ljvm
LD_FLAGS = -L $(JAVA_HOME)/jre/lib/i386/server/ -L $(JAVA_HOME)/jre/lib/i386/
#-----------------------------------------------
#Compile and Link Image
#------------------------------------------------
all: $(PROGRAM)
$(PROGRAM): $(OBJS)
$(CC) -o $(PROGRAM) $(OBJS) -pthread $(LD_FLAGS) $(LIB_FLAGS)
$(DESTDIR)/%.o:$(SRCDIR)/%.cpp
$(CC) -c $(CFLAGS) $< -o $@ $(INCL)
#-----------------------------------------------
#Clean obj and image files.
#------------------------------------------------
clean :
rm -f $(OBJS)
rm -f $(PROGRAM)



COMPILE ALL JAVA PROGRAM
------------------------------
[q.yang@localhost TestStruct]$ javac *.java


RUN C PROGRAM TO CALL JAVA FUNCTION
------------------------------------
[q.yang@localhost Sandbox]$ tree Sample_017_CCallJava_via_JNI/
Sample_017_CCallJava_via_JNI/
|-- CTest
| |-- CTest.cpp
| |-- debug
| | |-- CCallJava
| | `-- CTest.o
| `-- makefile
|-- JavaSrc
| `-- TestStruct
| |-- ControlDetail.class
| |-- ControlDetail.java
| |-- HelloWorld.class
| |-- HelloWorld.java
| |-- ReturnData.class
| |-- ReturnData.java
| |-- WorkOrder.class
| `-- WorkOrder.java
`-- readme.txt


[q.yang@localhost CTest]$ export LD_LIBRARY_PATH=$JAVA_HOME/jre/lib/i386/server/:$JAVA_HOME/jre/lib/i386/
[q.yang@localhost CTest]$ echo $LD_LIBRARY_PATH
/usr/java/default/jre/lib/i386/server/:/usr/java/default/jre/lib/i386/

[q.yang@localhost debug]$ ./CCallJava
Struct Created in C has values:
ID:11
Name:HR-HW
IP:10.32.164.133
Port:9099
Hello World!
This is the main function in HelloWorld class

TestCall:Called from the C Program


Going to Call DisplayStruct
Structure is:
-------------------------
Name:HR-HW
IP:10.32.164.133
Port9099


Going to call DisplayStructArray From C

WorkOrders are Given hereunder:
----------------------------
<---Work Order Number:1<---
Sum_Serial_ID: 2000
Access_Number: 2878430
Action_Type: 04
Effective_Date: 25-12-2007 12:20:30 PM
Fetch_Flag: 0
Reason: Executed Successfully
Access_Source: PMS
<---Work Order Number:2<---
Sum_Serial_ID: 1000
Access_Number: 2878000
Action_Type: T4
Effective_Date: 25-12-2007 11:20:30 PM
Fetch_Flag: 0
Reason:
Access_Source: RMS
Going to return an object from java


Values Returned from Object are:
returnValue=1
Log=Successfull function call
[q.yang@localhost debug]$

Install VLC Player for ubuntu 10.10

[1] Web source Link

Command line way

You need to check that a universe mirror is listed in your /etc/apt/sources.list file.

% sudo apt-get update
% sudo apt-get install vlc vlc-plugin-pulse mozilla-plugin-vlc

Friday, August 5, 2011

Install Java SE JDK6 under Fedora 9

[1] http://www.oracle.com/technetwork/java/javase/install-linux-rpm-137089.html
[2] http://fedoraunity.org/Members/zcat/using-sun-java-instead-of-openjdk

[q.yang@localhost Download]$ ./jdk-6u26-linux-i586-rpm.bin
[q.yang@localhost Download]$ ./jdk-6u26-linux-i586-rpm.bin
Unpacking...
Checksumming...
Extracting...
UnZipSFX 5.50 of 17 February 2002, by Info-ZIP (Zip-Bugs@lists.wku.edu).
inflating: jdk-6u26-linux-i586.rpm
inflating: sun-javadb-common-10.6.2-1.1.i386.rpm
inflating: sun-javadb-core-10.6.2-1.1.i386.rpm
inflating: sun-javadb-client-10.6.2-1.1.i386.rpm
inflating: sun-javadb-demo-10.6.2-1.1.i386.rpm
inflating: sun-javadb-docs-10.6.2-1.1.i386.rpm
inflating: sun-javadb-javadoc-10.6.2-1.1.i386.rpm
error: can't create transaction lock on /var/lib/rpm/__db.000
Installing JavaDB
error: can't create transaction lock on /var/lib/rpm/__db.000

Done.
[q.yang@localhost Download]$ su
Password:
[root@localhost Download]# ./jdk-6u26-linux-i586-rpm.bin
Unpacking...
Checksumming...
Extracting...
UnZipSFX 5.50 of 17 February 2002, by Info-ZIP (Zip-Bugs@lists.wku.edu).
replace jdk-6u26-linux-i586.rpm? [y]es, [n]o, [A]ll, [N]one, [r]ename: y
inflating: jdk-6u26-linux-i586.rpm
replace sun-javadb-common-10.6.2-1.1.i386.rpm? [y]es, [n]o, [A]ll, [N]one, [r]ename: y
inflating: sun-javadb-common-10.6.2-1.1.i386.rpm
replace sun-javadb-core-10.6.2-1.1.i386.rpm? [y]es, [n]o, [A]ll, [N]one, [r]ename: y
inflating: sun-javadb-core-10.6.2-1.1.i386.rpm
replace sun-javadb-client-10.6.2-1.1.i386.rpm? [y]es, [n]o, [A]ll, [N]one, [r]ename: y
inflating: sun-javadb-client-10.6.2-1.1.i386.rpm
replace sun-javadb-demo-10.6.2-1.1.i386.rpm? [y]es, [n]o, [A]ll, [N]one, [r]ename: y
inflating: sun-javadb-demo-10.6.2-1.1.i386.rpm
replace sun-javadb-docs-10.6.2-1.1.i386.rpm? [y]es, [n]o, [A]ll, [N]one, [r]ename: y
inflating: sun-javadb-docs-10.6.2-1.1.i386.rpm
replace sun-javadb-javadoc-10.6.2-1.1.i386.rpm? [y]es, [n]o, [A]ll, [N]one, [r]ename: A
inflating: sun-javadb-javadoc-10.6.2-1.1.i386.rpm
Preparing... ########################################### [100%]
1:jdk ########################################### [100%]
Unpacking JAR files...
rt.jar...
jsse.jar...
charsets.jar...
tools.jar...
localedata.jar...
plugin.jar...
javaws.jar...
deploy.jar...
Installing JavaDB
Preparing... ########################################### [100%]
1:sun-javadb-common ########################################### [ 17%]
2:sun-javadb-core ########################################### [ 33%]
3:sun-javadb-client ########################################### [ 50%]
4:sun-javadb-demo ########################################### [ 67%]
5:sun-javadb-docs ########################################### [ 83%]
6:sun-javadb-javadoc ########################################### [100%]

Java(TM) SE Development Kit 6 successfully installed.

Product Registration is FREE and includes many benefits:
* Notification of new versions, patches, and updates
* Special offers on Oracle products, services and training
* Access to early releases and documentation

Product and system data will be collected. If your configuration
supports a browser, the JDK Product Registration form will
be presented. If you do not register, none of this information
will be saved. You may also register your JDK later by
opening the register.html file (located in the JDK installation
directory) in a browser.

For more information on what data Registration collects and
how it is managed and used, see:
http://java.sun.com/javase/registration/JDKRegistrationPrivacy.html

Press Enter to continue.....


Done.
[root@localhost Download]# exit
exit
[q.yang@localhost Download]$ java -version
java version "1.6.0"
OpenJDK Runtime Environment (build 1.6.0-b09)
OpenJDK Client VM (build 1.6.0-b09, mixed mode)
[q.yang@localhost Download]$


CHANGE DEFAULT JDK TO SUN INSTEAD OF OPEN JDK [2]
----------------------------------------------
[q.yang@localhost ~]$ source /etc/profile.d/sunjava.sh
[q.yang@localhost ~]$ echo $PATH
/usr/java/default/bin:/usr/java/default/bin:/usr/kerberos/bin:/usr/lib/ccache:/usr/local/bin:/bin:/usr/bin:/home/q.yang/bin:/sbin:/usr/sbin:/opt/wx/2.8/bin:/opt/freescale/usr/local/gcc-4.1.2-glibc-2.5-nptl-3/arm-none-linux-gnueabi/bin:/opt/codeblocks20100721-svn/bin/:/home/q.yang/CodeSourcery/arm-2010q1/bin:/opt/codeblocks20100721-svn/bin:/home/q.yang/EclipseCDT/eclipse
[q.yang@localhost ~]$ java -version
java version "1.6.0_26"
Java(TM) SE Runtime Environment (build 1.6.0_26-b03)
Java HotSpot(TM) Client VM (build 20.1-b02, mixed mode, sharing)
[q.yang@localhost ~]$ cat /etc/profile.d/sunjava.sh
export JAVA_HOME=/usr/java/default
export PATH=$JAVA_HOME/bin:$PATH

Wednesday, August 3, 2011

Change MAC address under Linux

[1] http://www.linuxquestions.org/questions/linux-software-2/how-to-change-mac-address-304234/

[root@localhost ltib]# ifconfig eth0 down hw ether 00:0C:F1:87:56:F8

Friday, July 29, 2011

Set GateWay under Windows MS-DOS command line

C:\Documents and Settings\q.yang>route

Manipulates network routing tables.

ROUTE [-f] [-p] [command [destination]
[MASK netmask] [gateway] [METRIC metric] [IF interface]

-f Clears the routing tables of all gateway entries. If this is
used in conjunction with one of the commands, the tables are
cleared prior to running the command.
-p When used with the ADD command, makes a route persistent across
boots of the system. By default, routes are not preserved
when the system is restarted. Ignored for all other commands,
which always affect the appropriate persistent routes. This
option is not supported in Windows 95.
command One of these:
PRINT Prints a route
ADD Adds a route
DELETE Deletes a route
CHANGE Modifies an existing route
destination Specifies the host.
MASK Specifies that the next parameter is the 'netmask' value.
netmask Specifies a subnet mask value for this route entry.
If not specified, it defaults to 255.255.255.255.
gateway Specifies gateway.
interface the interface number for the specified route.
METRIC specifies the metric, ie. cost for the destination.

All symbolic names used for destination are looked up in the network database
file NETWORKS. The symbolic names for gateway are looked up in the host name
database file HOSTS.

If the command is PRINT or DELETE. Destination or gateway can be a wildcard,
(wildcard is specified as a star '*'), or the gateway argument may be omitted.

If Dest contains a * or ?, it is treated as a shell pattern, and only
matching destination routes are printed. The '*' matches any string,
and '?' matches any one char. Examples: 157.*.1, 157.*, 127.*, *224*.
Diagnostic Notes:
Invalid MASK generates an error, that is when (DEST & MASK) != DEST.
Example> route ADD 157.0.0.0 MASK 155.0.0.0 157.55.80.1 IF 1
The route addition failed: The specified mask parameter is invalid.
(Destination & Mask) != Destination.

Examples:

> route PRINT
> route ADD 157.0.0.0 MASK 255.0.0.0 157.55.80.1 METRIC 3 IF 2
destination^ ^mask ^gateway metric^ ^
Interface^
If IF is not given, it tries to find the best interface for a given
gateway.
> route PRINT
> route PRINT 157* .... Only prints those matching 157*
> route CHANGE 157.0.0.0 MASK 255.0.0.0 157.55.80.5 METRIC 2 IF 2

CHANGE is used to modify gateway and/or metric only.
> route PRINT
> route DELETE 157.0.0.0
> route PRINT

C:\Documents and Settings\q.yang>route ADD 192.168.0.0 MASK 255.255.255.0 10.10.
20.201 -p

C:\Documents and Settings\q.yang>ping 192.168.0.1

Pinging 192.168.0.1 with 32 bytes of data:

Reply from 192.168.0.1: bytes=32 time=10ms TTL=255
Reply from 192.168.0.1: bytes=32 time=1ms TTL=255
Reply from 192.168.0.1: bytes=32 time=1ms TTL=255
Reply from 192.168.0.1: bytes=32 time=1ms TTL=255

Ping statistics for 192.168.0.1:
Packets: Sent = 4, Received = 4, Lost = 0 (0% loss),
Approximate round trip times in milli-seconds:
Minimum = 1ms, Maximum = 10ms, Average = 3ms

C:\Documents and Settings\q.yang>ping 192.168.0.2

Pinging 192.168.0.2 with 32 bytes of data:

Reply from 192.168.0.2: bytes=32 time=48ms TTL=254
Reply from 192.168.0.2: bytes=32 time=50ms TTL=254
Reply from 192.168.0.2: bytes=32 time=50ms TTL=254
Reply from 192.168.0.2: bytes=32 time=50ms TTL=254

Ping statistics for 192.168.0.2:
Packets: Sent = 4, Received = 4, Lost = 0 (0% loss),
Approximate round trip times in milli-seconds:
Minimum = 48ms, Maximum = 50ms, Average = 49ms

C:\Documents and Settings\q.yang>route ADD 192.168.1.0 MASK 255.255.255.0 10.10.
20.201 -p

C:\Documents and Settings\q.yang>ping 192.168.0.3

Pinging 192.168.0.3 with 32 bytes of data:

Reply from 192.168.0.3: bytes=32 time=50ms TTL=254
Reply from 192.168.0.3: bytes=32 time=49ms TTL=254
Reply from 192.168.0.3: bytes=32 time=49ms TTL=254
Reply from 192.168.0.3: bytes=32 time=59ms TTL=254

Ping statistics for 192.168.0.3:
Packets: Sent = 4, Received = 4, Lost = 0 (0% loss),
Approximate round trip times in milli-seconds:
Minimum = 49ms, Maximum = 59ms, Average = 51ms

C:\Documents and Settings\q.yang>ping 192.168.1.1

Pinging 192.168.1.1 with 32 bytes of data:

Reply from 192.168.1.1: bytes=32 time=48ms TTL=254
Reply from 192.168.1.1: bytes=32 time=50ms TTL=254
Reply from 192.168.1.1: bytes=32 time=50ms TTL=254
Reply from 192.168.1.1: bytes=32 time=50ms TTL=254

Ping statistics for 192.168.1.1:
Packets: Sent = 4, Received = 4, Lost = 0 (0% loss),
Approximate round trip times in milli-seconds:
Minimum = 48ms, Maximum = 50ms, Average = 49ms

C:\Documents and Settings\q.yang>ping 192.168.1.2

Pinging 192.168.1.2 with 32 bytes of data:

Reply from 192.168.1.2: bytes=32 time=64ms TTL=98
Reply from 192.168.1.2: bytes=32 time=58ms TTL=98
Reply from 192.168.1.2: bytes=32 time=58ms TTL=98
Reply from 192.168.1.2: bytes=32 time=57ms TTL=98

Ping statistics for 192.168.1.2:
Packets: Sent = 4, Received = 4, Lost = 0 (0% loss),
Approximate round trip times in milli-seconds:
Minimum = 57ms, Maximum = 64ms, Average = 59ms

Tuesday, July 19, 2011

SAMBA Setting -- Ubuntu 10.10

[1] https://help.ubuntu.com/community/Samba/SambaServerGuide
[2] https://help.ubuntu.com/community/Samba


INSTALL SAMBA IF NOT INSTALLED (Live Ubuntu CD doesn't install in default)
---------------------------------------------------------------------------
In order to apply patch file, set up Samba server for file exchange between Windows
and Ubuntu box.

quentin@ubuntu:~/lpc3250/ltib-qs$ sudo apt-get install samba-common-bin (has to be done to get samba work)
quentin@ubuntu:~/lpc3250/ltib-qs$ sudo apt-get install system-config-samba



ADD SAMBA PASSWORD PROTECTION FOR ONE USER IN CMD LINE
----------------------------------------------------------
sudo smbpasswd -a username

RESTART SAMBA SERVER IN UBUNTU
------------------------------
sudo restart smbd


MANUALLY ADD SHARE BY EDITING SMB.CONF
(if no luck to set it by using system-config-samba GUI)
--------------------------------------------------------------
(system-config-samba might issue warning on smb.conf syntax error but it won't affect the sharing of folders) See [2], another way to run Samba as service


quentin@QuentinUbuntu:/media/WQYSada$ ll /etc/samba/
total 32
drwxr-xr-x 2 root root 4096 2011-07-21 20:53 ./
drwxr-xr-x 137 root root 12288 2011-10-15 12:47 ../
-rw-r--r-- 1 root root 8 2010-10-06 09:26 gdbcommands
-rw-r--r-- 1 root root 11553 2011-07-21 20:53 smb.conf
-rw-r--r-- 1 root root 0 2011-07-21 20:43 smbusers


quentin@ubuntu:~$ diff smb.conf smb-vm.conf
110c110
< passdb backend = tdbsam
---
> ; passdb backend = tdbsam
191c191

> username map = /etc/samba/smbusers
298c299

[printers]

< guest ok = no
---
> ; guest ok = no

---ADD THIS SECTION AT THE END OF SMB.CONF---

[UbuntuQt]
comment = Quentin's DwLd folder on Ubuntu
path = /home/quentin
writeable = yes
; browseable = yes
valid users = quentin

Sunday, July 17, 2011

Why is JSON so popular? Developers want out of the syntax business.

[1] http://blog.mongolab.com/2011/03/why-is-json-so-popular-developers-want-out-of-the-syntax-business/

Wednesday, July 6, 2011

CmdLine ----- Check Public IP address

[1] http://www.simplehelp.net/2009/04/07/how-to-find-your-public-ip-address-with-the-linux-command-line/

[root@GsnCommsModule /]# wget -q -O - http://checkip.dyndns.org
...Current IP Check Current IP Address: 1.152.83.93...

wget -q -O - checkip.dyndns.org|sed -e 's/.*Current IP Address: //' -e 's/<.*$//'

Tuesday, July 5, 2011

ntpclient NTP used in Embedded Linux

[1] http://doolittle.icarus.com/ntpclient/README



ntpclient home page: http://doolittle.icarus.com/ntpclient/

Joachim Nilsson created a fork of ntpclient that he maintains at
http://vmlinux.org/jocke/ntpclient.shtml. We don't have the same
maintainance and build system sensibilities; some people may prefer his.
In particular, he has converted his ntpclient to daemon and syslog.
The basic functionality of the two versions should be identical.

Usage: ntpclient [options]
options:
-c count stop after count time measurements (default 0 means go forever)
-d print diagnostics (feature can be disabled at compile time)
-g goodness causes ntpclient to stop after getting a result more accurate
than goodness (microseconds, default 0 means go forever)
-h hostname (mandatory) NTP server, against which to measure system time
-i interval check time every interval seconds (default 600)
-l attempt to lock local clock to server using adjtimex(2)
-p port local NTP client UDP port (default 0 means "any available")
-q min_delay minimum packet delay for transaction (default 800 microseconds)
-r replay analysis code based on stdin
-s simple clock set (implies -c 1)
-t trust network and server, no RFC-4330 recommended cross-checks

Wednesday, June 29, 2011

Flash File System ---- Linux

[1] http://en.wikipedia.org/wiki/LogFS
[2] http://en.wikipedia.org/wiki/JFFS2
[3] http://en.wikipedia.org/wiki/YAFFS
[4] http://en.wikipedia.org/wiki/Flash_file_system
[5] http://www.linux-mtd.infradead.org/faq/jffs2.html#L_bbhandle ----jffs2 trouble shotting


LOGFS IS THE FUTURE FOR BIGGER FLASH [1]
----------------------------------------
LogFS is a Linux log-structured and scalable flash filesystem, intended for use on large devices of flash memory. It is written by Jörn Engel and in part sponsored by the CE Linux Forum.

LogFS is included in the mainline Linux kernel and was introduced in version 2.6.34, released on May 16, 2010.


DISADVANTAGE OF JFFS2 [2]
-------------------------------
Disadvantages

All nodes must still be scanned at mount time. This is slow and is becoming an increasingly serious problem as flash devices scale upward into the Gigabyte range.
Writing many small blocks of data can even lead to negative compression rates, so it is essential for applications to use large write buffers.
There is no practical way to tell how much usable free space is left on a device since this depends both on how well additional data can be compressed, and the writing sequence.

Tuesday, June 28, 2011

Check package version under Ubuntu

[1] http://www.howtogeek.com/howto/ubuntu/see-what-version-of-a-package-is-installed-on-ubuntu/


quentin@ubuntu:/var/lib/tftpboot$ dpkg -s mtd-utils
Package: mtd-utils
Status: install ok installed
Priority: extra
Section: utils
Installed-Size: 1160
Maintainer: Ubuntu Developers
Architecture: i386
Version: 20100706-1
Replaces: mtd-tools
Provides: mtd-tools
Depends: libc6 (>= 2.8), liblzo2-2, libuuid1 (>= 2.16), zlib1g (>= 1:1.1.4)
Description: Memory Technology Device Utilities
Utilities for manipulating memory technology devices, such as flash
memory, Disk-On-Chip, or ROM. Includes mkfs.jffs2, a tool to create
JFFS2 (journaling flash file system) filesystems.
Original-Maintainer: Riku Voipio
Homepage: http://www.linux-mtd.infradead.org/

Monday, June 20, 2011

VNC Server set up in UBUNTU

[1] http://theseekersquill.wordpress.com/2010/03/16/vnc-server-ubuntu-windows/ ---Best Link
[2] http://nuclear-imaging.info/site_content/2010/04/19/vnc-server-setup-for-ubuntu-10-04-lucid-lynx/
[3] http://usingnix.wordpress.com/2010/12/15/setup-vnc-in-ubuntu-10-10/
[4] http://blog.sudobits.com/2011/03/13/vnc-server-for-ubuntu-10-10/
[5] http://ubuntuforums.org/showthread.php?t=1313898 ---- Get rid of warning for auto start
[6] http://www.debianhelp.co.uk/vnc.htm
[7] http://askubuntu.com/questions/390113/x11vnc-much-slower-than-xvnc-how-to-get-a-xubuntu-session-manually
[8] https://freevps.us/thread-14110.html
[9] https://help.ubuntu.com/community/VNC/Servers
[10] https://wiki.archlinux.org/index.php/TigerVNC  
[11] http://askubuntu.com/questions/603169/lubuntu-14-04-tightvnc-remote-mouse-cursor-is-x

[12] vnc/xrdp to xfce4  windows manager good posts
[13] Using ubuntu 14.04.3 default vino desktop sharing (current session)
[14] One bug fix in early 14.04 vino

qyang@lubuntu-laptop:~$ apt-cache search autocutsel
autocutsel - Keep the X clipboard and the cutbuffer in sync

Got tightvnc work on lubuntu after changing xstartup file
./vnc/xstartup file is configured as follows [11] :


#!/bin/sh

xrdb $HOME/.Xresources
xsetroot -solid grey -cursor_name left_ptr
autocutsel -fork
lxsession -s Lubuntu -e LXDE
 

x11vnc is slower. [7] [8] tightvncserver is suggested and faster. [8] vnc4server was discussed a lot.

x11vnc is different from xvnc(tightvnc, tigervnc). The latter support multiple sessions. Also, seems x11vnc is slower than xvnc.[7]
x11vnc offers better security focus ( can be secured with SSH or SSL.) but it's known to be slower. [8]


vino and x11vnc in Ubuntu [9]


VNC SET UP AND SSH SERVER SET UP
-----------------------------------

INSTALL OPENSSH SERVER AND VNC SERVER
----------------------------------------
quentin@QuentinUbuntu:~$ sudo apt-get install openssh-server openssh-client vnc4server xinetd vncviewer
[sudo] password for quentin:
Sorry, try again.
[sudo] password for quentin:
Reading package lists... Done
Building dependency tree
Reading state information... Done
Note, selecting 'xtightvncviewer' instead of 'vncviewer'
The following extra packages will be installed:
xbase-clients xtightvncviewer
Suggested packages:
libpam-ssh keychain openssh-blacklist openssh-blacklist-extra rssh
molly-guard vnc-java tightvncserver
The following NEW packages will be installed:
openssh-server vnc4server xbase-clients xinetd xtightvncviewer
The following packages will be upgraded:
openssh-client
1 upgraded, 5 newly installed, 0 to remove and 328 not upgraded.
Need to get 3,305kB of archives.
After this operation, 6,484kB of additional disk space will be used.
Do you want to continue [Y/n]? Y
....................
.............


SSH SERVER SET UP
--------------------------------------------
quentin@QuentinUbuntu:~$ ssh-keygen
Generating public/private rsa key pair.
Enter file in which to save the key (/home/quentin/.ssh/id_rsa):
Created directory '/home/quentin/.ssh'.
Enter passphrase (empty for no passphrase):
Enter same passphrase again:
Your identification has been saved in /home/quentin/.ssh/id_rsa.
Your public key has been saved in /home/quentin/.ssh/id_rsa.pub.
The key fingerprint is:
9f:71:93:c0:80:9f:aa:e5:a9:ec:e1:0c:d2:9a:a3:13 quentin@QuentinUbuntu
The key's randomart image is:
+--[ RSA 2048]----+
| .. |
| . o |
| . .o |
| o . . |
| .S . + |
|E. o . + . |
|..o .+ . o |
|o+ =..o |
|=o .*. |
+-----------------+

SET UP VNC SERVER PASSWORD
--------------------------------------
qyang@lubuntu-laptop:~$ vncpasswd
Using password file /home/qyang/.vnc/passwd
VNC directory /home/qyang/.vnc does not exist, creating.
Password:
Verify: 
Would you like to enter a view-only password (y/n)? y
Password:
Verify: 



START VNC SERVER
-----------------------------
quentin@QuentinUbuntu:~$ vnc4server

New 'QuentinUbuntu:1 (quentin)' desktop is QuentinUbuntu:1

Creating default startup script /home/quentin/.vnc/xstartup
Starting applications specified in /home/quentin/.vnc/xstartup
Log file is /home/quentin/.vnc/QuentinUbuntu:1.log


quentin@QuentinUbuntu:~$ ps aux |grep vnc
quentin 1898 0.1 0.3 10504 5284 pts/0 S 19:07 0:00 Xvnc4 :1 -desktop QuentinUbuntu:1 (quentin) -auth /var/run/gdm/auth-for-quentin-5eao3N/database -geometry 1024x768 -depth 16 -rfbwait 30000 -rfbauth /home/quentin/.vnc/passwd -rfbport 5901 -pn -fp /usr/X11R6/lib/X11/fonts/Type1/,/usr/X11R6/lib/X11/fonts/Speedo/,/usr/X11R6/lib/X11/fonts/misc/,/usr/X11R6/lib/X11/fonts/75dpi/,/usr/X11R6/lib/X11/fonts/100dpi/,/usr/share/fonts/X11/misc/,/usr/share/fonts/X11/Type1/,/usr/share/fonts/X11/75dpi/,/usr/share/fonts/X11/100dpi/ -co /etc/X11/rgb
quentin 1904 0.0 0.0 4596 1540 pts/0 S 19:07 0:00 vncconfig -iconic
quentin 1936 0.0 0.0 4008 748 pts/0 S+ 19:09 0:00 grep --color=auto vnc

KILL VNCSERVER
------------------------
quentin@QuentinUbuntu:~$ vncserver -kill :1
Killing Xvnc4 process ID 3561

LOCAL VNC ACCESS
-----------------------
quentin@QuentinUbuntu:~$vncviewer localhost:1

SSH SERVER LOG IN VIA PUTTY
-------------------------------
quentin@10.1.1.5's password:
Linux QuentinUbuntu 2.6.35-22-generic #33-Ubuntu SMP Sun Sep 19 20:34:50 UTC 2010 i686 GNU/Linux
Ubuntu 10.10

Welcome to Ubuntu!
* Documentation: https://help.ubuntu.com/

Your CPU appears to be lacking expected security protections.
Please check your BIOS settings, or for more information, run:
/usr/bin/check-bios-nx --verbose

336 packages can be updated.
157 updates are security updates.

New release 'natty' available.
Run 'do-release-upgrade' to upgrade to it.


The programs included with the Ubuntu system are free software;
the exact distribution terms for each program are described in the
individual files in /usr/share/doc/*/copyright.

Ubuntu comes with ABSOLUTELY NO WARRANTY, to the extent permitted by
applicable law.


EDIT VNC XSTARTUP FILE TO REMOVE GREY BACKGROUND
------------------------------------------------
quentin@QuentinUbuntu:~$ vi /home/quentin/.vnc/xstartup

#!/bin/sh

# Uncomment the following two lines for normal desktop:
unset SESSION_MANAGER
#exec /etc/X11/xinit/xinitrc
sh /etc/X11/xinit/xinitrc

#[ -x /etc/vnc/xstartup ] && exec /etc/vnc/xstartup
#[ -r $HOME/.Xresources ] && xrdb $HOME/.Xresources
#xsetroot -solid grey
#vncconfig -iconic &
#x-terminal-emulator -geometry 80x24+10+10 -ls -title "$VNCDESKTOP Desktop" &

#x-window-manager &

#gnome-session &
#twm &

START VNC SERVER AGAIN
----------------------------------
quentin@QuentinUbuntu:~$ vncserver
xauth: creating new authority file /home/quentin/.Xauthority

New 'QuentinUbuntu:1 (quentin)' desktop is QuentinUbuntu:1

Starting applications specified in /home/quentin/.vnc/xstartup
Log file is /home/quentin/.vnc/QuentinUbuntu:1.log


MAKE VNC SERVER AUTO RUN WHEN BOOT
------------------------------------
$sudo -i

root@QuentinUbuntu:~# vi /etc/init.d/vncserver

#!/bin/sh -e

### BEGIN INIT INFO
# Provides: vncserver
# Required-Start: networking
# Default-Start: S
# Default-Stop: 0 6
### END INIT INFO

PATH="$PATH:/usr/X11R6/bin/"

# The Username:Group that will run VNC
export USER="quentin"
#${RUNAS}

# The display that VNC will use
DISPLAY="1"
# Color depth (between 8 and 32)
DEPTH="16"
# The Desktop geometry to use.
#GEOMETRY="x"
#GEOMETRY="800x600"
GEOMETRY="1024x768"
#GEOMETRY="1280x1024"
# The name that the VNC Desktop will have.
NAME="QuentinUbuntu-vnc-server"
OPTIONS="-name ${NAME} -depth ${DEPTH} -geometry ${GEOMETRY} :${DISPLAY}"
. /lib/lsb/init-functions

case "$1" in
start)
su ${USER} -c "/usr/bin/vncserver ${OPTIONS}"
;;
stop)
su ${USER} -c "/usr/bin/vncserver -kill :${DISPLAY}"
;;
restart)
$0 stop
$0 start
;;
esac
exit 0

root@QuentinUbuntu:~# chmod +x /etc/init.d/vncserver

MAKE IT AUTO RUN WHEN BOOT
-----------------------------------
sudo update-rc.d vncserver defaults
update-rc.d: warning: /etc/init.d/vncserver missing LSB keyword 'required-stop'

update-rc.d: warning: vncserver start runlevel arguments (2 3 4 5) do not match LSB Default-Start values (S)
update-rc.d: warning: vncserver stop runlevel arguments (0 1 6) do not match LSB Default-Stop values (0 6)
Adding system startup for /etc/init.d/vncserver ...
/etc/rc0.d/K20vncserver -> ../init.d/vncserver
/etc/rc1.d/K20vncserver -> ../init.d/vncserver
/etc/rc6.d/K20vncserver -> ../init.d/vncserver
/etc/rc2.d/S20vncserver -> ../init.d/vncserver
/etc/rc3.d/S20vncserver -> ../init.d/vncserver
/etc/rc4.d/S20vncserver -> ../init.d/vncserver
/etc/rc5.d/S20vncserver -> ../init.d/vncserver
To get rid of warning

we change the /etc/init.d/vncserver

### BEGIN INIT INFO
# Provides: vncserver
# Required-Start: $remote_fs $syslog
# Required-Stop: $remote_fs $syslog
# Default-Start: 2 3 4 5
# Default-Stop: 0 1 6
# Short-Description: Start daemon at boot time
# Description: Enable service provided by daemon.
### END INIT INFO

quentin@QuentinUbuntu:~$ sudo update-rc.d -f vncserver remove
Removing any system startup links for /etc/init.d/vncserver ...
/etc/rc0.d/K20vncserver
/etc/rc1.d/K20vncserver
/etc/rc2.d/S20vncserver
/etc/rc3.d/S20vncserver
/etc/rc4.d/S20vncserver
/etc/rc5.d/S20vncserver
/etc/rc6.d/K20vncserver

NO MORE WARNINGS
--------------------------------
quentin@QuentinUbuntu:~$ sudo update-rc.d vncserver defaults
Adding system startup for /etc/init.d/vncserver ...
/etc/rc0.d/K20vncserver -> ../init.d/vncserver
/etc/rc1.d/K20vncserver -> ../init.d/vncserver
/etc/rc6.d/K20vncserver -> ../init.d/vncserver
/etc/rc2.d/S20vncserver -> ../init.d/vncserver
/etc/rc3.d/S20vncserver -> ../init.d/vncserver
/etc/rc4.d/S20vncserver -> ../init.d/vncserver
/etc/rc5.d/S20vncserver -> ../init.d/vncserver

Sunday, May 29, 2011

Network setting under Linux ---Embedded Linux Internet Access

[1] http://www.linuxhomenetworking.com/wiki/index.php/Quick_HOWTO_:_Ch03_:_Linux_Networking


[root@GsnCommsModule rc.d]# ifconfig -a
[root@GsnCommsModule rc.d]# cat rc.conf
all_services="mount-proc-sys mdev udev hostname devfsd depmod modules filesystems syslog network inetd portmap dropbear sshd boa smb dhcpd settime qtopia watchdog gtk2 pango"
all_services_r="pango gtk2 watchdog qtopia settime dhcpd smb boa sshd dropbear portmap inetd network syslog filesystems modules depmod devfsd hostname udev mdev mount-proc-sys"

cfg_services="mount-proc-sys mdev hostname depmod modules filesystems syslog network sshd settime "

cfg_services_r=" settime sshd network syslog filesystems modules depmod hostname mdev mount-proc-sys"

export HOSTNAME="GsnCommsModule [-m ] [options....]"
export NTP_SERVER="ntp.cs.strath.ac.uk"
export MODLIST=""
export RAMDIRS="/tmp /var"
export TMPFS="tmpfs"
export TMPFS_SIZE="512k"
export READONLY_FS=""
export INETD_ARGS=""
export BOA_ARGS=""
export SMBD_ARGS=""
export NMBD_ARGS=""
export DHCP_ARG=""
export DEPLOYMENT_STYLE="JFFS2"
export SYSCFG_DHCPC_CMD="udhcpc -b -i "
export DROPBEAR_ARGS=""
# net interface 1
export SYSCFG_IFACE1=y
export INTERFACE1="eth0"
export IPADDR1="10.10.20.89"
export NETMASK1="255.255.0.0"
export BROADCAST1="10.10.255.255"
export GATEWAY1="10.10.10.1"
export NAMESERVER1="10.10.10.1"

[root@GsnCommsModule rc.d]# source rc.local

--------------------------------------------
VIEW ROUTING TABLE

[root@GsnCommsModule rc.d]# netstat -nr
Kernel IP routing table
Destination Gateway Genmask Flags MSS Window irtt Iface
10.10.0.0 0.0.0.0 255.255.0.0 U 0 0 0 eth0
127.0.0.0 0.0.0.0 255.0.0.0 U 0 0 0 lo

------------------------------
ADD DEFAULT GATEWAY

[root@GsnCommsModule rc.d]# route add default gw 10.10.10.1 eth0

Routing table with 0.0.0.0 as destination is the default gateway.
[root@GsnCommsModule rc.d]# netstat -nr
Kernel IP routing table
Destination Gateway Genmask Flags MSS Window irtt Iface.1
10.10.0.0 10.10.10.1 255.255.255.255 UGH 0 0 0 eth0
10.10.0.0 0.0.0.0 255.255.0.0 U 0 0 0 eth0
127.0.0.0 0.0.0.0 255.0.0.0 U 0 0 0 lo
0.0.0.0 10.10.10.1 0.0.0.0 UG 0 0 0 eth0

------------------------
DELETE GATEWAY

[root@GsnCommsModule rc.d]# route del -net 10.10.0.0 netmask 255.255.255.255 gw 10.10.10.1 eth0
[root@GsnCommsModule rc.d]# netstat -nr
Kernel IP routing table
Destination Gateway Genmask Flags MSS Window irtt Iface
10.10.0.0 0.0.0.0 255.255.0.0 U 0 0 0 eth0
127.0.0.0 0.0.0.0 255.0.0.0 U 0 0 0 lo
0.0.0.0 10.10.10.1 0.0.0.0 UG 0 0 0 eth0






Wednesday, May 25, 2011

Ubuntu --- install tftp Server

[1] http://pjpramod.blogspot.com/2009/08/setting-up-tftp-server-on-ubuntu-904.html
[2] http://www.ubuntugeek.com/howto-setup-advanced-tftp-server-in-ubuntu.html


-----------------------[1]---------------------------------------
quentin@ubuntu:~/lpc3250/ltib-qs$ sudo apt-get install tftpd-hpa

Running Java on Embedded Linux

[1] Libffi Official Link
[2] http://www.linuxquestions.org/questions/linux-kernel-70/locale-support-in-linux-kernel-811248/
[3] http://java.sun.com/developer/technicalArticles/JavaTechandLinux/RedHat/ ---NPTL from RedHat
[4] http://en.wikipedia.org/wiki/NPTL#cite_note-0 ---NPTL
[5] http://en.wikipedia.org/wiki/LinuxThreads ---NPTL replace LinuxThreads
[6] http://dev.maxtrack.com.br/index.php/Td60_notes#Set_Locale --- locale issue
[7] http://sourceware.org/ml/libffi-discuss/2009/msg00004.html --- mail list for using libffi for power pc.
[8] http://www.linuxquestions.org/questions/linux-general-1/locale-cannot-set-lc_all-to-default-locale-no-such-file-or-directory-218622/ --- check locale
[9] http://www.busybox.net/ --- busy box home page
[10] http://groups.google.com/group/netusg20/tree/browse_frm/month/2010-01/2d17cfad90f32150?rnum=31&lnk=ol --- localedef crash (same as locale-gen crash)
[11] http://www.linuxquestions.org/questions/linux-newbie-8/detect-glibc-version-based-on-libpthread-so-627968/ --- check Glibc version
[12] http://ubuntuforums.org/showthread.php?t=829866 ---- java class library loading error.
[13] http://www.coderanch.com/t/110728/Linux-UNIX/find-vma-failed-warning ---VM Stack warning.
[14] http://www.velocityreviews.com/forums/t149023-cant-detect-initial-thread-stack-location.html --- JVM Stack warning.
[15] Embedded JRE Download from Oracle --- EJRE
[16] http://www.linux-mtd.infradead.org/faq/jffs2.html#L_bbhandle ---- jffs2 file system CRC error on node



RUN REST SERVER ON LINUX USING JAVA
------------------------------------
[root@10 HandMade]# java -jar Make.jar &
[1] 384
[root@10 HandMade]# Jan 3, 1970 1:52:04 AM org.restlet.engine.http.connector.HttpServerHelper start
INFO: Starting the internal HTTP server on port 8182

From Browser:
http://10.10.20.89:8182/powergridiq/datapac
[root@10 HandMade]# ps -A --sort -rss -o comm,pmem |head -n 11
COMMAND %MEM
java 57.7
sh 5.5
ps 3.0
init 0.9
head 0.8
kthreadd 0.0
ksoftirqd/0 0.0
events/0 0.0
khelper 0.0
async/mgr 0.0
[root@10 HandMade]# cat /proc/meminfo
MemTotal: 28952 kB
MemFree: 1424 kB
Buffers: 0 kB
Cached: 11684 kB
SwapCached: 0 kB
Active: 13344 kB
Inactive: 12100 kB
Active(anon): 6732 kB
Inactive(anon): 7028 kB
Active(file): 6612 kB
Inactive(file): 5072 kB
Unevictable: 0 kB
Mlocked: 0 kB
SwapTotal: 0 kB
SwapFree: 0 kB
Dirty: 0 kB
Writeback: 0 kB
AnonPages: 13792 kB
Mapped: 4444 kB
Shmem: 0 kB
Slab: 1100 kB
SReclaimable: 256 kB
SUnreclaim: 844 kB
KernelStack: 264 kB
PageTables: 116 kB
NFS_Unstable: 0 kB
Bounce: 0 kB
WritebackTmp: 0 kB
CommitLimit: 14476 kB
Committed_AS: 31352 kB
VmallocTotal: 745472 kB
VmallocUsed: 428 kB
VmallocChunk: 744912 kB





Access REST server from browser
http://10.10.20.89:8182/powergridiq/datapac



WORKAROUND FOR CLASS LIBRARY LOADING ERROR
----------------------------------------------
Here's a workaround. It's for making the package install and configure properly, not for actually running java in the chrooted environment.

1. Install sun-java6-bin. It fails to configure.
2. Find out where libjli.so is. Do "locate libjli.so". In my case it was here:

/opt/jdk1.7.0/jre/lib/i386/jli/libjli.so

3. Set the LD_LIBRARY_PATH variable so that the package can configure properly. Enter the following command (using your location of libjli.so):

LD_LIBRARY_PATH=/opt/jdk1.7.0/jre/lib/i386/jli dpkg --configure -a

Hopefully it's now installed and configured correctly.


TRY RUNNING JAVA PROGRAM AFTER LOCALE IS SET CORRECTLY
-----------------------------------------------------
[root@10 HandMade]# java -jar Make.jar
Java HotSpot(TM) Client VM warning: Can't detect initial thread stack location - find_vma failed
Jan 1, 1970 12:44:27 AM org.restlet.engine.http.connector.HttpServerHelper start
INFO: Starting the internal HTTP server on port 8182



Calling C function from Java. [1]
-----------------------------------


CHECK GLIBC VERSION [11]
-------------------
[root@GsnCommsModule lib]# cat /lib/libpthread.so.0 |grep GLIBC
GLIBC_2.4
GLIBC_PRIVATE
pthread_cond_timedwait@@GLIBC_2.4
__libc_dlopen_mode@@GLIBC_PRIVATE
tfind@@GLIBC_2.4
pthread_attr_getaffinity_np@@GLIBC_2.4
__fsetlocking@@GLIBC_2.4



SOLVE LOCALE ISSUE TO GET EMBEDDED JAVA RUN IN EMBEDDED LINUX [2]
-----------------------------------------------------------------
From [8]
[root@GsnCommsModule /]# locale
LANG=
LC_CTYPE="POSIX"
LC_NUMERIC="POSIX"
LC_TIME="POSIX"
LC_COLLATE="POSIX"
LC_MONETARY="POSIX"
LC_MESSAGES="POSIX"
LC_PAPER="POSIX"
LC_NAME="POSIX"
LC_ADDRESS="POSIX"
LC_TELEPHONE="POSIX"
LC_MEASUREMENT="POSIX"
LC_IDENTIFICATION="POSIX"
LC_ALL=
[root@GsnCommsModule /]# locale -a
C
POSIX
[root@GsnCommsModule /]#

AFTER USING CODESOURCERY arm-2010q1 COMPILER
----------------------------------------------
arm-2010q1 is using newer version GCC (GCC4.41)
So all locale and language suit are generated in LTIB
Extra folders are removed so that only support wanted languages and font coding.

[root@LIQ-GateWay /]# locale
LANG=en_US.UTF-8
LC_CTYPE="en_US.UTF-8"
LC_NUMERIC="en_US.UTF-8"
LC_TIME="en_US.UTF-8"
LC_COLLATE="en_US.UTF-8"
LC_MONETARY="en_US.UTF-8"
LC_MESSAGES="en_US.UTF-8"
LC_PAPER="en_US.UTF-8"
LC_NAME="en_US.UTF-8"
LC_ADDRESS="en_US.UTF-8"
LC_TELEPHONE="en_US.UTF-8"
LC_MEASUREMENT="en_US.UTF-8"
LC_IDENTIFICATION="en_US.UTF-8"
LC_ALL=en_US.UTF-8
[root@LIQ-GateWay /]# locale -a
C
en_GB
en_GB.utf8
en_US
en_US.utf8
POSIX

[root@LIQ-GateWay /]# locale -m
UTF-8

Tuesday, May 24, 2011

Ubuntu --- install LTIB

[1] http://imxcommunity.org/group/ubuntutipsandtricks/forum/topics/building-ltib-in-ubuntu-1004
[2] http://www.imxdev.org/wiki/index.php?title=ALL_Boards_ltib_config_ubuntu


quentin@ubuntu:~/lpc3250$ wget http://www.bitshrine.org/netinstall

--2011-05-23 21:47:51-- http://www.bitshrine.org/netinstall
Resolving www.bitshrine.org... 66.96.145.106
Connecting to www.bitshrine.org|66.96.145.106|:80... connected.
HTTP request sent, awaiting response... 200 OK
Length: 2327 (2.3K) [text/html]
Saving to: `netinstall'

100%[======================================>] 2,327 --.-K/s in 0s

2011-05-23 21:47:53 (6.94 MB/s) - `netinstall' saved [2327/2327]

quentin@ubuntu:~/lpc3250$ ll
total 12
drwxr-xr-x 2 quentin quentin 4096 2011-05-23 21:47 ./
drwxr-xr-x 24 quentin quentin 4096 2011-05-23 21:42 ../
-rw-r--r-- 1 quentin quentin 2327 2008-10-23 01:43 netinstall
quentin@ubuntu:~/lpc3250$ perl netinstall

You are about to install the LTIB (GNU/Linux Target Image Builder)

Do you want to continue ? Y|n
y
Where do you want to install LTIB ? (/home/quentin/lpc3250/ltib)
/home/quentin/lpc3250/ltib-qs
Installing LTIB to /home/quentin/lpc3250/ltib-qs
+ cvs -z3 -d:pserver:anonymous@cvs.savannah.nongnu.org:/sources/ltib co -d ltib-qs -P ltib
sh: cvs: not found
Died at netinstall line 69, line 2.
quentin@ubuntu:~/lpc3250$ cvs
The program 'cvs' can be found in the following packages:
* cvs
* cvsnt
Try: sudo apt-get install
quentin@ubuntu:~/lpc3250$ sudo apt-get install cvs
Reading package lists... Done
Building dependency tree
Reading state information... Done
The following NEW packages will be installed:
cvs
0 upgraded, 1 newly installed, 0 to remove and 326 not upgraded.
Need to get 1,685kB of archives.
After this operation, 3,703kB of additional disk space will be used.
Get:1 http://us.archive.ubuntu.com/ubuntu/ maverick/main cvs i386 1:1.12.13-12ubuntu1 [1,685kB]
Fetched 1,685kB in 10s (161kB/s)
Preconfiguring packages ...
Selecting previously deselected package cvs.
(Reading database ... 118286 files and directories currently installed.)
Unpacking cvs (from .../cvs_1%3a1.12.13-12ubuntu1_i386.deb) ...
Processing triggers for man-db ...
Processing triggers for install-info ...
Processing triggers for doc-base ...
Processing 31 changed 2 added doc-base file(s)...
Registering documents with scrollkeeper...
Setting up cvs (1:1.12.13-12ubuntu1) ...
Ignoring install-info called from maintainer script
The package cvs should be rebuilt with new debhelper to get trigger support
Ignoring install-info called from maintainer script
The package cvs should be rebuilt with new debhelper to get trigger support
quentin@ubuntu:~/lpc3250$ ll
total 12
drwxr-xr-x 2 quentin quentin 4096 2011-05-23 21:47 ./
drwxr-xr-x 24 quentin quentin 4096 2011-05-23 21:42 ../
-rw-r--r-- 1 quentin quentin 2327 2008-10-23 01:43 netinstall
quentin@ubuntu:~/lpc3250$ perl netinstall

You are about to install the LTIB (GNU/Linux Target Image Builder)

Do you want to continue ? Y|n
y
Where do you want to install LTIB ? (/home/quentin/lpc3250/ltib)
/home/quentin/lpc3250/ltib-qs/



===============================Ref [1] below ================================
quentin@ubuntu:~/lpc3250/ltib-qs$ sudo rm /bin/sh
[sudo] password for quentin:
quentin@ubuntu:~/lpc3250/ltib-qs$ sudo ln -s /bin/bash /bin/sh
quentin@ubuntu:~/lpc3250/ltib-qs$ sudo chmod 777 /opt
quentin@ubuntu:~/lpc3250/ltib-qs$ sudo apt-get install gcc build-essential

quentin@ubuntu:~/lpc3250/ltib-qs$ sudo apt-get install zlib1g-dev
quentin@ubuntu:~/lpc3250/ltib-qs$ sudo apt-get install libncurses-dev
quentin@ubuntu:~/lpc3250/ltib-qs$ sudo apt-get install m4
quentin@ubuntu:~/lpc3250/ltib-qs$ sudo apt-get install bison
quentin@ubuntu:~/lpc3250/ltib-qs$ sudo apt-get install rpm
quentin@ubuntu:~/lpc3250/ltib-qs$ sudo apt-get install ccache
quentin@ubuntu:~/lpc3250/ltib-qs$ sudo apt-get install flex

------------------------------------------------
In order to apply patch file, set up Samba server for file exchange between Windows
and Ubuntu box.

quentin@ubuntu:~/lpc3250/ltib-qs$ sudo apt-get install samba-common-bin (has to be done to get samba work)
quentin@ubuntu:~/lpc3250/ltib-qs$ sudo apt-get install system-config-samba

-------------------------------
quentin@ubuntu:~/lpc3250/ltib-qs$ cp -p /home/quentin/Downloads/2869_ltib.patch ./
quentin@ubuntu:~/lpc3250/ltib-qs$ patch -i 2869_ltib.patch
patching file ltib
Hunk #1 succeeded at 964 (offset 38 lines).

quentin@ubuntu:~/lpc3250/ltib-qs$ sudo /usr/sbin/visudo

# User privilege specification
root ALL=(ALL) ALL
quentin ALL = NOPASSWD: /usr/bin/rpm, /opt/ltib/usr/bin/rpm, /opt/freescale/lti$

---------------------------------------------------------
uentin@ubuntu:~/lpc3250/ltib-qs$ ./ltib -m config

Installing host support packages.

This only needs to be done once per host, but may take up to
an hour to complete ...

If an error occurs, a log file with the full output may be found in:
/home/quentin/lpc3250/ltib-qs/host_config.log

If you would like to see the log messages as the host packages are built and
installed:

* Open another terminal in the same directory
* Run the command: tail -f host_config.log
* When you're done with the tail, use CTRL+C to exit

------------------------------------------------
$ sudo rm -rf ~/.ccache

Wednesday, May 4, 2011

How does iPad WiFi model have locatiion service --- Skyhook Wireless

[1] http://bbs.weiphone.com/read-htm-tid-1020301-page-2.html

Skyhook Wireless

Website Skyhook Wireless
Skyhook Wireless (formerly known as Quarterscope) is a Boston-based company that has developed a technology for determining geographical location using Wi-Fi as the underlying reference system. Using the MAC addresses of nearby wireless access points and proprietary algorithms, WPS can determine the position of a mobile device within 20–30 meters. It provides service similar to GPS without GPS hardware and can also integrate with GPS-enabled devices to provide hybrid positioning. Skyhook Wireless claims that with sub-second time-to-first-fix, supposed 20–30 meter accuracy and near 100% availability indoors and in dense urban areas.
Skyhook's database is gathered through wardriving,[1] and includes more than 100 million wi-fi access points and covers 70 percent of population centers in the United States and Canada.[2]
Skyhook Wireless offers Loki[3], a free 'virtual GPS' toolbar that automatically integrates a user's location with web content such as Google Maps, Fandango, Weather.com, etc. It has been now replaced by a "Find Me" page on the website, as well as tools and SDK's used for adding location-based data to sites such as WeatherBug.com.
Skyhook announced a partnership to help users in geotagging their pictures.[4]
At the Macworld Conference & Expo in January 2008, Apple CEO Steve Jobs announced that both the iPhone and iPod Touch will use Skyhook's WPS as the primary location engine for Google Maps and other applications.[5] However, Apple revealed that starting with iPhone/iPad software 3.2 in April 2010, its devices no longer uses Skyhook, but relies on its own location technologies.[6]

Monday, May 2, 2011

Unzip window zip file under Linux

[1] http://www.cyberciti.biz/tips/how-can-i-zipping-and-unzipping-files-under-linux.html

Wednesday, April 27, 2011

Apply Linux Kernel Patch

[1] http://www.cyberciti.biz/faq/appy-patch-file-using-patch-command/
[2] http://www.regatta.cs.msu.su/doc/usr/share/man/info/ru_RU/a_doc_lib/cmds/aixcmds4/patch.htm

[q.yang@localhost linux-2.6.34]$ ll
total 1256
drwxr-xr-x 25 q.yang developer 4096 2010-05-17 07:17 arch
drwxr-xr-x 2 q.yang developer 4096 2010-05-17 07:17 block
-rw-r--r-- 1 q.yang developer 18693 2010-05-17 07:17 COPYING
-rw-r--r-- 1 q.yang developer 94031 2010-05-17 07:17 CREDITS
drwxr-xr-x 3 q.yang developer 4096 2010-05-17 07:17 crypto
drwxr-xr-x 85 q.yang developer 12288 2010-05-17 07:17 Documentation
drwxr-xr-x 89 q.yang developer 4096 2010-05-17 07:17 drivers
drwxr-xr-x 36 q.yang developer 4096 2010-05-17 07:17 firmware
drwxr-xr-x 72 q.yang developer 4096 2010-05-17 07:17 fs
drwxr-xr-x 20 q.yang developer 4096 2010-05-17 07:17 include
drwxr-xr-x 2 q.yang developer 4096 2010-05-17 07:17 init
drwxr-xr-x 2 q.yang developer 4096 2010-05-17 07:17 ipc
-rw-r--r-- 1 q.yang developer 2440 2010-05-17 07:17 Kbuild
-rw-r--r-- 1 q.yang developer 3526 2011-04-28 16:04 Kconfig.orig
-rw-r--r-- 1 q.yang developer 1040 2011-04-28 16:05 Kconfig.rej
drwxr-xr-x 7 q.yang developer 4096 2010-05-17 07:17 kernel
drwxr-xr-x 6 q.yang developer 4096 2010-05-17 07:17 lib
-rw-r--r-- 1 q.yang developer 735556 2011-04-09 03:50 linux-2.6.34_lpc32x0-v1.08.patch
-rw-r--r-- 1 q.yang developer 170406 2010-05-17 07:17 MAINTAINERS
-rw-r--r-- 1 q.yang developer 53183 2011-04-28 16:05 Makefile
-rw-r--r-- 1 q.yang developer 53183 2011-04-28 16:05 Makefile.orig
-rw-r--r-- 1 q.yang developer 308 2011-04-28 16:05 Makefile.rej
drwxr-xr-x 2 q.yang developer 4096 2010-05-17 07:17 mm
drwxr-xr-x 48 q.yang developer 4096 2010-05-17 07:17 net
-rw-r--r-- 1 q.yang developer 17459 2010-05-17 07:17 README
-rw-r--r-- 1 q.yang developer 3371 2010-05-17 07:17 REPORTING-BUGS
drwxr-xr-x 7 q.yang developer 4096 2010-05-17 07:17 samples
drwxr-xr-x 12 q.yang developer 4096 2010-05-17 07:17 scripts
drwxr-xr-x 7 q.yang developer 4096 2010-05-17 07:17 security
drwxr-xr-x 21 q.yang developer 4096 2010-05-17 07:17 sound
drwxr-xr-x 3 q.yang developer 4096 2010-05-17 07:17 tools
drwxr-xr-x 2 q.yang developer 4096 2010-05-17 07:17 usr
drwxr-xr-x 3 q.yang developer 4096 2010-05-17 07:17 virt
[q.yang@localhost linux-2.6.34]$ patch -p1 < ./linux-2.6.34_lpc32x0-v1.08.patch
patching file arch/arm/Kconfig
patching file arch/arm/Makefile
patching file arch/arm/configs/ea3250_defconfig
patching file arch/arm/configs/fdi3250_defconfig
patching file arch/arm/configs/phy3250_defconfig
patching file arch/arm/mach-lpc32xx/Kconfig
patching file arch/arm/mach-lpc32xx/Makefile
patching file arch/arm/mach-lpc32xx/Makefile.boot
patching file arch/arm/mach-lpc32xx/clock.c
patching file arch/arm/mach-lpc32xx/clock.h
patching file arch/arm/mach-lpc32xx/common.c
patching file arch/arm/mach-lpc32xx/common.h
patching file arch/arm/mach-lpc32xx/dma.c
patching file arch/arm/mach-lpc32xx/ea3250.c
patching file arch/arm/mach-lpc32xx/fdi3250.c
patching file arch/arm/mach-lpc32xx/gpiolib.c
patching file arch/arm/mach-lpc32xx/include/mach/board.h
patching file arch/arm/mach-lpc32xx/include/mach/clkdev.h
patching file arch/arm/mach-lpc32xx/include/mach/debug-macro.S
patching file arch/arm/mach-lpc32xx/include/mach/dma.h
patching file arch/arm/mach-lpc32xx/include/mach/dmac.h
patching file arch/arm/mach-lpc32xx/include/mach/entry-macro.S
patching file arch/arm/mach-lpc32xx/include/mach/gpio.h
patching file arch/arm/mach-lpc32xx/include/mach/hardware.h
patching file arch/arm/mach-lpc32xx/include/mach/i2c.h
patching file arch/arm/mach-lpc32xx/include/mach/i2s.h
patching file arch/arm/mach-lpc32xx/include/mach/io.h
patching file arch/arm/mach-lpc32xx/include/mach/irqs.h
patching file arch/arm/mach-lpc32xx/include/mach/memory.h
patching file arch/arm/mach-lpc32xx/include/mach/platform.h
patching file arch/arm/mach-lpc32xx/include/mach/sdcard.h
patching file arch/arm/mach-lpc32xx/include/mach/slcnand.h
patching file arch/arm/mach-lpc32xx/include/mach/system.h
patching file arch/arm/mach-lpc32xx/include/mach/timex.h
patching file arch/arm/mach-lpc32xx/include/mach/uncompress.h
patching file arch/arm/mach-lpc32xx/include/mach/usbd.h
patching file arch/arm/mach-lpc32xx/include/mach/vmalloc.h
patching file arch/arm/mach-lpc32xx/irq.c
patching file arch/arm/mach-lpc32xx/phy3250.c
patching file arch/arm/mach-lpc32xx/pm.c
patching file arch/arm/mach-lpc32xx/serial.c
patching file arch/arm/mach-lpc32xx/suspend.S
patching file arch/arm/mach-lpc32xx/timer.c
patching file arch/arm/vfp/vfpmodule.c
patching file drivers/i2c/busses/Kconfig
patching file drivers/i2c/busses/i2c-pnx.c
patching file drivers/input/keyboard/Kconfig
patching file drivers/input/keyboard/Makefile
patching file drivers/input/keyboard/lpc32xx_keys.c
patching file drivers/input/touchscreen/Kconfig
patching file drivers/input/touchscreen/Makefile
patching file drivers/input/touchscreen/ads7846.c
patching file drivers/input/touchscreen/lpc32xx_ts.c
patching file drivers/mmc/host/mmci.c
patching file drivers/mtd/nand/Kconfig
patching file drivers/mtd/nand/Makefile
patching file drivers/mtd/nand/lpc32xx_nand.c
patching file drivers/net/Kconfig
patching file drivers/net/Makefile
patching file drivers/net/lpc_eth.c
patching file drivers/net/lpc_eth.h
patching file drivers/rtc/Kconfig
patching file drivers/rtc/Makefile
patching file drivers/rtc/rtc-lpc32xx.c
patching file drivers/serial/8250.c
patching file drivers/serial/Kconfig
patching file drivers/serial/Makefile
patching file drivers/serial/lpc32xx_hs.c
patching file drivers/usb/gadget/Kconfig
patching file drivers/usb/gadget/Makefile
patching file drivers/usb/gadget/gadget_chips.h
patching file drivers/usb/gadget/lpc32xx_udc.c
patching file drivers/usb/gadget/lpc32xx_udc.h
patching file drivers/usb/host/ohci-hcd.c
patching file drivers/usb/host/ohci-pnx4008.c
patching file drivers/video/amba-clcd.c
patching file drivers/watchdog/Kconfig
patching file include/linux/amba/clcd.h
patching file include/linux/i2c-pnx.h
patching file sound/soc/Kconfig
patching file sound/soc/Makefile
patching file sound/soc/codecs/uda1380.c
patching file sound/soc/codecs/uda1380.h
patching file sound/soc/lpc3xxx/Kconfig
patching file sound/soc/lpc3xxx/Makefile
patching file sound/soc/lpc3xxx/lpc3xxx-i2s.c
patching file sound/soc/lpc3xxx/lpc3xxx-i2s.h
patching file sound/soc/lpc3xxx/lpc3xxx-pcm.c
patching file sound/soc/lpc3xxx/lpc3xxx-pcm.h
patching file sound/soc/lpc3xxx/lpc3xxx-uda1380.c
patching file sound/soc/soc-core.c
[q.yang@localhost linux-2.6.34]$

Tuesday, April 26, 2011

Installation of Git to get Lpc32xx latest code.

[1] http://git.lpclinux.com/?p=linux-2.6.34-lpc32xx.git;a=summary
[2] http://kernel.org/pub/software/scm/git/RPMS/i386/
[3] http://git-scm.com/

Get git RPM release 'git-1.6.5.1-1.fc9.i386.rpm','perl-Git-1.6.5.1-1.fc9.i386.rpm' from [2].

[root@localhost Download]# rpm -ivh git-1.6.5.1-1.fc9.i386.rpm perl-Git-1.6.5.1-1.fc9.i386.rpm
Preparing... ########################################### [100%]
1:git ########################################### [ 50%]
2:perl-Git ########################################### [100%]
[root@localhost Download]#

GET LATEST SOURCE CODE OF LPC32XX BSP VIA GIT
---------------------------------------------------
[q.yang@localhost GitLpc32xx]$ git clone git://git.lpclinux.com/linux-2.6.34-lpc32xx
Initialized empty Git repository in /home/q.yang/lpc3250/GitLpc32xx/linux-2.6.34-lpc32xx/.git/
remote: Counting objects: 34362, done.
remote: Compressing objects: 100% (30654/30654), done.
remote: Total 34362 (delta 3530), reused 33921 (delta 3209)
Receiving objects: 100% (34362/34362), 94.09 MiB | 271 KiB/s, done.
Resolving deltas: 100% (3530/3530), done.
Checking out files: 100% (32343/32343), done.

Monday, April 18, 2011

Bash_Prog using input argument from Command line

[q.yang@localhost Sandbox]$ cat SetDefault.sh
#!/bin/bash
# 19/APR/2011
# Author Quentin YANG
# Copy certain version app to default app.

# if no input argument, string is null or not '-z'
if [ -z "$1" ]
then
echo "please type CommsModule version you want make it default.e.g.'. SetDefault.sh 012'"
return
#exit
fi

VerRange=$1

NAME='GsnCommsTask'_$1

echo "You've chosen '$NAME' as default CommsModule App"

#cd $JIST_HOME

if [ -f "$NAME" ]
then
cp -p $NAME GsnCommsTask
echo "All files under this directory:"
ls -al
else
echo "Error: '$NAME' not found!"
fi

Thursday, March 3, 2011

picture editing tool

http://www.eetimes.com/electronics-blogs/other/4213692/SmartDraw---The-Visio-Killer-?cid=NL_ProgrammableLogic

Tuesday, March 1, 2011

String Processing Using Shell --- egrep + cut + awk

[1] Dreams soft




USING EGREP AND AWK SHELL
------------------------------






USING EGREP AND CUT SHELL
-------------------------------




CALLING STRING PROCESSING SHELL FROM C PROGRAM
-------------------------------------------------
int main()
{
#define MAXLINE 100

FILE *fpin;
char line[MAXLINE];
char line1[MAXLINE];
bool lbFound;

strcpy(line,"cat networkshow.txt|egrep '1: |2: |3: '|cut -d \":\" -f2");
printf(line);
printf("\n");

if ((fpin = popen(line,"r")) == NULL )
err_says("popen error");

lbFound=false;

while(fgets(line1,MAXLINE,fpin) != NULL){
if(strcmp(line1," ppp0\n")==0){
printf("Found ppp0\n");
lbFound=true;
break;
}
printf(line1);
}

if(lbFound==false)
printf("No ppp0 found.\n");

return 0;
}

Monday, February 28, 2011

Calling 'shell' from C/C++ code under Linux

See man page for those functions. Popen is better than system if want see return value of shell.

system()
popen()
pclose()

Network check

IFCONFIG
----------------------
$ifconfig
$ifconfig eth0 up
$ifconfig eth0 down

NETSTAT
-------------------
$netstat
Usage: netstat [-laentuwxr]

Display networking information

Options:
-l Display listening server sockets
-a Display all sockets (default: connected)
-e Display other/more information
-n Don't resolve names
-t Tcp sockets
-u Udp sockets
-w Raw sockets
-x Unix sockets
-r Display routing table




[root@GsnCommsModule user]# netstat -l
Active Internet connections (only servers)
Proto Recv-Q Send-Q Local Address Foreign Address State
tcp 0 0 (null):13000 (null):* LISTEN
tcp 0 0 (null):ssh (null):* LISTEN
Active UNIX domain sockets (only servers)
Proto RefCnt Flags Type State I-Node Path


BUSY BOX SHOW NETWORK INFTERFACE
---------------------------------
$ ip addr show
To show the kernel routing table use:
$ ip route show