Tuesday, April 15, 2014
Tuesday, September 24, 2013
Create jar file using all files in bin folder of eclipse
1.Open Command prompt
2. Go to C:\Eclipse projectworkspace\project\bin\ > jar -cvf YourJarFilename.jar *
2. Go to C:\Eclipse projectworkspace\project\bin\ > jar -cvf YourJarFilename.jar *
Thursday, February 14, 2013
Why malloc not recommended in Nesc
Just summarizing my google search. Can malloc be used in Nesc programs?
THANKS TO TINYOS FORUM MEMBERS
Ans : Yes, program will run. But not at all recommended.
Ref: 1. http://mail.millennium.berkeley.edu/pipermail/tinyos-help/2005-February/007712.html
2. http://www.mail-archive.com/
From Ref:1
> When i used malloc, it sometimes gives me a pointer at the > adress:0x29DB, > which is , i think, not normal because this pointer goes to the > external SRAM > (which is not present on my cricket platform). So any write at this > adresse > has no effect on further read...
The TinyOS programming methodology frowns on malloc, for several reasons: 1) No memory protection so you can smash your stack 2) Unforeseen rate mismatches can cause you to do 1 (you start receiving packets faster than you can forward them) 3) Event-driven execution models can make free()ing a hard thing to do right (hence pool allocations, etc.)
If you want dynamic allocation, look at TinyAlloc . It allows you to allocate a static chunk of RAM which you then parcel out dynamically. But using it in the presence of conflicting components is a recipe for disaster. Systems such as TinyDB
get away with it because all their parts are designed to work together.
Wednesday, December 26, 2012
java.util.ConcurrentModificationException False belief
Dear all,
I faced the exception
I faced the exception
java.util.ConcurrentModificationException
Immediately I started thinking ..., since two different functions{A() and B()} are executing parallel, some critical section variable might be accessed at the same time by both functions A() and B().
So to solve the issue, I used java function 'synchronized() { } ' blocks inside both the functions A() and B(). But surprisingly the error was not solved.
Thanks to the link
http://stackoverflow.com/questions/8189466/java-util-concurrentmodificationexception
which told me that, the concurrent exception happens because of the Iterator I used in one of the function A().
Consider the program
------------------------------------------------------------------------------
set= myhashmap.entrySet();
i=set.Iterator();
while (i.hasNext())
{
myhashmap.remove(datanode);//This causes problem
}
--------------------------------------------------------------------------------------------------
'i' has already Iterator set values and pointers/ memory locations assigned to it. But when you remove an item from hashmap, the 'i' is not getting updated(i =set.Iterator() is not called inside while). So when while(i.hasNext () ) is checking for datanode location, it finds that somebody else has already removed/modified the data in that location. So it thinks that Some body(some other program) is accessing the memory(critical section) alloted to it. Hence shouts ConcurrentModificationException
Tuesday, June 26, 2012
Simple DLL for visual basic 2010 calculator
Steps to make a DLL Calculator
CREATING A DLL
Prerequist: Visual Studio 2010.
1. Open Visual Studio 2010
2. New Project---> VC++---->MFC DLL
3. Give name to your dll project say "dllsampleadd"
4. OK creates new project
5. Delete all contents in dllsampleadd.cpp
6. Add the following contents:
#include "stdafx.h"
int _stdcall sum(int x , int y)
{
return x+y;
}
7. Open file dllsampleadd.def
8. Update the contents of dllsampleadd.def to
LIBRARY DLLSAMPLEADD
EXPORTS
sum @1
9. Build ---> Build Solution
10. You can see the DLL file 'dllsampleadd.dll' getting created at the Debug folder of your project
VISUAL BASIC APPLICATION
1. File ---> NewProject ---> Other languages---> Visual Basic--->Windows Forms Application
2. Give name to your dll project say "add"
3. Drag and drop buttons and labels as shown in screenshot
4. Double click on add button.
5. Make necessary changes to the code associated with add button as given below:
Private Declare Function sum Lib "C:\Users\hari\Documents\Visual Studio 2010\Projects\dllsampleadd\Debug\dllsampleadd.dll" (ByVal x As Int32, ByVal y As Int32) As Int32
Private Sub Button1_Click() Handles Button1.Click
Label4.Text = Str(sum(CInt(TextBox1.Text), CInt(TextBox2.Text)))
End Sub
6. Run your program( Debug---->Start Debugging)
7. Make necessary changes to your dll program and VB program for adding subract, divide, multiply functions to the calculator.
CREATING A DLL
Prerequist: Visual Studio 2010.
1. Open Visual Studio 2010
2. New Project---> VC++---->MFC DLL
3. Give name to your dll project say "dllsampleadd"
4. OK creates new project
5. Delete all contents in dllsampleadd.cpp
6. Add the following contents:
#include "stdafx.h"
int _stdcall sum(int x , int y)
{
return x+y;
}
7. Open file dllsampleadd.def
8. Update the contents of dllsampleadd.def to
LIBRARY DLLSAMPLEADD
EXPORTS
sum @1
9. Build ---> Build Solution
10. You can see the DLL file 'dllsampleadd.dll' getting created at the Debug folder of your project
VISUAL BASIC APPLICATION
1. File ---> NewProject ---> Other languages---> Visual Basic--->Windows Forms Application
2. Give name to your dll project say "add"
3. Drag and drop buttons and labels as shown in screenshot
4. Double click on add button.
5. Make necessary changes to the code associated with add button as given below:
Private Declare Function sum Lib "C:\Users\hari\Documents\Visual Studio 2010\Projects\dllsampleadd\Debug\dllsampleadd.dll" (ByVal x As Int32, ByVal y As Int32) As Int32
Private Sub Button1_Click() Handles Button1.Click
Label4.Text = Str(sum(CInt(TextBox1.Text), CInt(TextBox2.Text)))
End Sub
6. Run your program( Debug---->Start Debugging)
7. Make necessary changes to your dll program and VB program for adding subract, divide, multiply functions to the calculator.
Tuesday, May 15, 2012
TinyOS : problem in installing cygwin
SITUTATION :Running following command in Cygwin
rpm -Uvh --ignoreos nesc-1.2.8a-1.cygwin.i386.rpm
Error :" unpacking of archive failed on file usr cpio: chmod failed permission denied"
SOLUTION: Right click Cywin start up file---> Run as administrator
Tuesday, December 20, 2011
Printing Malayalam as C program output at dos prompt, win32
Hai all,
I think we cannot print Malayalam letters in dos prompt. If any body gets a solution, please let me know.
I was just trying to print the malayalam letters using a C Program in windows. I used Visual Studio 2010 to run my C++ program. Following is program:
Use header files like windows.h, conio.h, tchar.h etc
int _tmain(int argc, _TCHAR* argv[])
{
TCHAR c;
SetConsoleOutputCP(863);
printf("\nHello SDL User!\n");
printf ("The codepage is %d\n", GetConsoleOutputCP());
for(c= 3333;c<3455;c++)
{
_tprintf(TEXT("%lc\n"),c);
}
getch();
return 0;
}
c= 3333 is the decimal value of UNICODE for first malayalam letter 'അ' (0x0D05-hex value).
Ref: http://www.malayalamunicode.com/malayalam-unicode-fonts
But the output was
?
?
?
.
.
.
Why this is because the DOS supports only a few languages whose list can be seen by checking the codepages supported by DOS in following link.
Ref 1: http://en.wikipedia.org/wiki/Category:DOS_code_pages
For Malayalam to be displayed DOS must support code page
This code page is not supported by DOS as listed in above reference.
Ref 2:http://msdn.microsoft.com/en-us/library/windows/desktop/dd317756%28v=vs.85%29.aspx
So Sad that unless DOS provides a support for this, we cannot print a malayalam letter in DOS
WIN32 program to print my name in Malayalam --MessageBox
-------------------------------------------------------------
This works for windows 7, but not working in XP
Create new project in visual studio 2010.
File-->New-->Project-->Win32 Project
Name the project
click OK
Finish
include header files stdafx.h, tchar.h.
int WINAPI WinMain(HINSTANCE hInstance,HINSTANCE hPrevInstance, PSTR szCommandline,int iCmdshow)
{
TCHAR c[4];
c[0]=3385;
c[1]=3376;
c[2]=3391;
c[3]='\0';
TCHAR szbuffer[100];
_stprintf(szbuffer,_T("%ls"),c);
MessageBox(NULL,szbuffer,TEXT("HELLO ALL"),0);
return 0;
}
Please ensure that , Configuration Properties--->Character set---> Use Unicode Character Set option is selected.
I think we cannot print Malayalam letters in dos prompt. If any body gets a solution, please let me know.
I was just trying to print the malayalam letters using a C Program in windows. I used Visual Studio 2010 to run my C++ program. Following is program:
Use header files like windows.h, conio.h, tchar.h etc
int _tmain(int argc, _TCHAR* argv[])
{
TCHAR c;
SetConsoleOutputCP(863);
printf("\nHello SDL User!\n");
printf ("The codepage is %d\n", GetConsoleOutputCP());
for(c= 3333;c<3455;c++)
{
_tprintf(TEXT("%lc\n"),c);
}
getch();
return 0;
}
c= 3333 is the decimal value of UNICODE for first malayalam letter 'അ' (0x0D05-hex value).
Ref: http://www.malayalamunicode.com/malayalam-unicode-fonts
But the output was
?
?
?
.
.
.
Why this is because the DOS supports only a few languages whose list can be seen by checking the codepages supported by DOS in following link.
Ref 1: http://en.wikipedia.org/wiki/Category:DOS_code_pages
For Malayalam to be displayed DOS must support code page
57009 | x-iscii-ma | ISCII Malayalam |
Ref 2:http://msdn.microsoft.com/en-us/library/windows/desktop/dd317756%28v=vs.85%29.aspx
So Sad that unless DOS provides a support for this, we cannot print a malayalam letter in DOS
WIN32 program to print my name in Malayalam --MessageBox
-------------------------------------------------------------
This works for windows 7, but not working in XP
Create new project in visual studio 2010.
File-->New-->Project-->Win32 Project
Name the project
click OK
Finish
include header files stdafx.h, tchar.h.
{
TCHAR c[4];
c[0]=3385;
c[1]=3376;
c[2]=3391;
c[3]='\0';
TCHAR szbuffer[100];
_stprintf(szbuffer,_T("%ls"),c);
MessageBox(NULL,szbuffer,TEXT("HELLO ALL"),0);
return 0;
}
Please ensure that , Configuration Properties--->Character set---> Use Unicode Character Set option is selected.
Subscribe to:
Posts (Atom)