For NonPeriod Activity, the updateHook just can work once after start. But how can I make it work when events come or command come?
Three ways to make updateHook work again for NonPeriod activity:
1, The simple way is add trigger in the updateHook function. But this way will waste the processor time. It likes a loop.
2, Using command method. If other task use this NonPeriod activity's command, then it will run again. The NonPeriod activity engine will first run command, and then run updateHook function.
3, Using event method. But event has two kinds. One is synchronous and the other one is asynchronous. Only the asynchronous one can be used to trigger updateHook. The reason is if the call back is in this NonPeriod activity, synchronous only make this call back run in caller's engine but not this NonPeriod activity's engine. Asynchronous will make the call back part work in the NonPeriod activity's engine.
Saturday, March 14, 2009
Thursday, March 12, 2009
A way to load module when linux system is booting
If you want load a modules "some.ko" to kernel when system is booting.. You can do this:
$ cd /etc/init.d/
$ sudo gvim "boot.local"
Add follow line in boot.local file:
"insmod /filedirectory/some.ko"
Make the file executable
$ sudo chmod +x boot.local
Make it bootable ..Dont forget the last dot.
$ sudo update-rc.d boot.local start 51 S .
Now If you reboot system ,you will see the that module already was loaded by command "lsmod";
$ cd /etc/init.d/
$ sudo gvim "boot.local"
Add follow line in boot.local file:
"insmod /filedirectory/some.ko"
Make the file executable
$ sudo chmod +x boot.local
Make it bootable ..Dont forget the last dot.
$ sudo update-rc.d boot.local start 51 S .
Now If you reboot system ,you will see the that module already was loaded by command "lsmod";
Monday, March 9, 2009
Combination translation and rotation
The order is very important, so rotation before translation is different translation after rotation.
Of course , rotation matrix also can not change the order ...
Remember that..
Of course , rotation matrix also can not change the order ...
Remember that..
Sunday, March 8, 2009
How to use "eof()" in c++ file operation
Today I find a interesting problem when I read data from text file.
The code like this:
[code]
vector data;
ofstream os;
os.open("filename");
while(!os.eof())
{
int a;
os>>a;
data.push_back(a);
}
[/code]
After I run this simple program, a problem is there :
The size of vector data is longer 1 than the size of data in the filename.
What's wrong with this program?
I find it because eof is to check error information that when you read data from file.
if "os>>a" is wrong, program still will add a to the vector.
So How to fix that:
[code]
vector data;
ofstream os;
os.open("filename");
int a;
while(os>>a)
{
data.push_back(a);
}
[/code]
The code like this:
[code]
vector
ofstream os;
os.open("filename");
while(!os.eof())
{
int a;
os>>a;
data.push_back(a);
}
[/code]
After I run this simple program, a problem is there :
The size of vector data is longer 1 than the size of data in the filename.
What's wrong with this program?
I find it because eof is to check error information that when you read data from file.
if "os>>a" is wrong, program still will add a to the vector.
So How to fix that:
[code]
vector
ofstream os;
os.open("filename");
int a;
while(os>>a)
{
data.push_back(a);
}
[/code]
Tuesday, February 17, 2009
DataPort vs BufferPort in Orocos
Some difference between DataPort and Bufferport in orocos are:
1, DataPort is copy value from sender to receiver that means it can have many receivers. But for Bufferport , it 's cut that means if sender port just has one data, if one receiver get this value ,then the bufferport will become empty and other receivers can not get value anymore.
2, DataPort always ready to be written and just has one data. BufferPort has size, if it's full ,then the action "Push" will return false, and if it's empty , then the action "Pop" will return false.
1, DataPort is copy value from sender to receiver that means it can have many receivers. But for Bufferport , it 's cut that means if sender port just has one data, if one receiver get this value ,then the bufferport will become empty and other receivers can not get value anymore.
2, DataPort always ready to be written and just has one data. BufferPort has size, if it's full ,then the action "Push" will return false, and if it's empty , then the action "Pop" will return false.
Tuesday, January 20, 2009
Multi-threads program
Before I always think Multi-thread program is difficult and a little bit huge !^_^
Today I realize one simple parallelize program by two threads.Although it did not fulfill my idea,but it do I told it..
That's not so difficult to know what's the multi-thread and write a simple example program..
Yes it's still huge because it want to do more work and fulfill more ideas. But for me or some task ,,we just need one pieces of it..So dont fear any more ..
Fear is because you know nothing about it..Just sit down and concentrate to read books and google. Then you will find it's not so difficult to do it like other guys..
Here is a very nice tutorial about pthreads.
http://www.yolinux.com/TUTORIALS/LinuxTutorialPosixThreads.html
Ps:Under linux c++, you can not define function like void* function(). Maybe you can do it in c language under c compiler. But for c++, GCC or G++ will give you wrong information about the function's parameter. I solved it by define function like void* function(void * p);
Here p is no used but you do need it to compile your program...
Today I realize one simple parallelize program by two threads.Although it did not fulfill my idea,but it do I told it..
That's not so difficult to know what's the multi-thread and write a simple example program..
Yes it's still huge because it want to do more work and fulfill more ideas. But for me or some task ,,we just need one pieces of it..So dont fear any more ..
Fear is because you know nothing about it..Just sit down and concentrate to read books and google. Then you will find it's not so difficult to do it like other guys..
Here is a very nice tutorial about pthreads.
http://www.yolinux.com/TUTORIALS/LinuxTutorialPosixThreads.html
Ps:Under linux c++, you can not define function like void* function(). Maybe you can do it in c language under c compiler. But for c++, GCC or G++ will give you wrong information about the function's parameter. I solved it by define function like void* function(void * p);
Here p is no used but you do need it to compile your program...
Monday, January 12, 2009
chat with friends by mobile phone freely
We can chat with our friends on internet and just need pay the net fee. Now we can visit internet by mobile phone, why should not we chat with friends on phone and use internet..Then we dont need pay the fee for every second. We just need pay the wireless fee.
Now google develop the open source system --Android.. May be we can try this.
Building a software like MSN ,QQ or OICQ, then we can chat to friends and see each other on the video .
Now google develop the open source system --Android.. May be we can try this.
Building a software like MSN ,QQ or OICQ, then we can chat to friends and see each other on the video .
Subscribe to:
Posts (Atom)