|
But if you give sleep 1 hour, then what happen?
I think it is not possible or we need to interrupt hardware.
|
|
|
|
|
Well, you may use WaitForSingleObject instead.
If the Lord God Almighty had consulted me before embarking upon the Creation, I would have recommended something simpler.
-- Alfonso the Wise, 13th Century King of Castile.
This is going on my arrogant assumptions. You may have a superb reason why I'm completely wrong.
-- Iain Clarke
[My articles]
|
|
|
|
|
OK,but How we stop sleep function? as we already put sleep for 1 hour.
|
|
|
|
|
You cannot stop it (well, without a hammer...).
If the Lord God Almighty had consulted me before embarking upon the Creation, I would have recommended something simpler.
-- Alfonso the Wise, 13th Century King of Castile.
This is going on my arrogant assumptions. You may have a superb reason why I'm completely wrong.
-- Iain Clarke
[My articles]
|
|
|
|
|
|
On the other hand, if you have to use a sleep of 30 minutes, it is likely that your design could be improved. For what reason do you need to sleep so long ?
|
|
|
|
|
What you are looking for is a WakeUp function. Unfortunately it doesn't exist. Since your thread is effectively blocked on Sleep, you need to handle this differently. This article [^] may give you some idea of how to accomplish what you are looking for.
Chris Meech
I am Canadian. [heard in a local bar]
In theory there is no difference between theory and practice. In practice there is. [Yogi Berra]
|
|
|
|
|
You say you want to sleep for 30 minutes but might at a later stage decide to alter the duration. This begs the following question: Who is doing the deciding? If you've called Sleep[^] with the full duration it obviously can't be the calling thread because it's sleeping. Some possible solutions are:
- Sleep for a shorter duration and periodically check on the same thread (do this in a loop).
- Use the WaitForSingleObject[^] function with the
dwMilliseconds parameter set to 30 minutes and for the hHandle parameter use a synchronisation object signalled by another thread (to abort the sleep).
Steve
|
|
|
|
|
Depending on your requirement, you could probably use SleepEx .
|
|
|
|
|
hi,i have written the code as shown below and it's to capture real time temperature but i have a problem to capture the temperature readings which i declare it as
tmpVALUE .I tried to place the readings to the arrays but it gave me an error:(error:
tmpVALUE was not declared in this scope.Please advice.
float tmpVALUE = 0;
int i=0;
void setup()
{
SensorEvent.setBoardMode(SENS_ON);
XBee.setMode(XBEE_ON);
delay(50);
USB.println("Start");
delay(100);
}
void loop()
{
char MSG[10]={tmpVALUE};
char* MSG0=0;
int i=0;
float tmpVALUE=0;
tmpVALUE = SensorEvent.readValue(SENS_SOCKET5);
if(tmpVALUE>0.5)
{
tmpVALUE=((tmpVALUE-0.500)/0.010);
}
else
{
tmpVALUE=tmpVALUE/0.010;
}
delay(100);
XBee.print("Temperature: ");
XBee.println(tmpVALUE);
for (int i=0; i<10; i++)
{
MSG0[i]=tmpValue;
MSG1[i]=tmpValue;
MSG2[i]=tmpValue;
MSG3[i]=tmpValue;
MSG4[i]=tmpValue;
MSG5[i]=tmpValue;
MSG6[i]=tmpValue;
MSG7[i]=tmpValue;
MSG8[i]=tmpValue;
MSG9[i]=tmpValue;
}
xbee.OFF();
delay(5000);
}
|
|
|
|
|
I cannot see how this would even compile. You have declared <pre>tmpVALUE</pre> at the top of your module and also in the function <pre>loop()</pre>. Your initialisation of <pre>char MSG[10]={tmpVALUE};</pre> is allocating a <pre>float</pre> to a <pre>char</pre>, and the variables <pre>MSG1</pre> ... <pre>MSG9</pre> have not been defined.
Just say 'NO' to evaluated arguments for diadic functions! Ash
|
|
|
|
|
Sorry for the trouble,but what i did was actually referred from c++ book.I do not know c++ that well.Do you have any better way of writing the arrays?As the declaration (tmpVALUE) is to capture the real time temperature.
|
|
|
|
|
I don't know what C++ book you are using but it is obviously not a very good one if that is an example of the sort of code it is giving you. I suggest you get hold of a better one and start with some simple programs before trying the more advanced stuff.
Just say 'NO' to evaluated arguments for diadic functions! Ash
|
|
|
|
|
As i understand is that you use the value of tmpVALUE before declaring it.
char MSG[10]={tmpVALUE};
char* MSG0=0;
int i=0;
float tmpVALUE=0;
The code should be like that
float tmpVALUE=0;
char MSG[10]={tmpVALUE};
char* MSG0=0;
int i=0;
Yes U Can ...If U Can ,Dream it , U can do it ...ICAN
|
|
|
|
|
hi,
thanks for the prompt reply.I have change the codes but it gave me an error: re-declaration of
float tmpVALUE=0; .From what i understand from the c++ reference book,somehow or rather
float tmpVALUE=0; at the top my coding is already acting as a global.
|
|
|
|
|
Hi,
I am currently debugging an MDI application created with VC++ 6 which crashes randomly in debug configuration.
Sometimes, I get an assertion when a new document is created which comes from "Objcore.cpp / AfxAssertValidObject() / AfxIsValidAddress()" and says that the "pDocument" pointer is invalid.
I have created a second MDI test application that reproduces the architecture of the first application.
This application only allows one document at a time (a kind of SDI ).
Each time a document is closed, a new one is created automatically via a custom WM_COMMAND message and the new document is closed via ID_FILE_CLOSE.
All messages are sent using PostMessage.
The result is that the closing of the current document and the opening of the new document are not synchronized.
Here is the code added in the MDI test application:
#define ID_FILE_INFINITE 50000
BEGIN_MESSAGE_MAP(CTestMDIApp, CWinApp)
ON_COMMAND(ID_FILE_INFINITE, OnCommandOpenDoc)
END_MESSAGE_MAP()
void CTestMDIApp::InitInstance()
{
m_pDocTemplateInfinite = = new CMultiDocTemplate(...);
}
void CTestMDIApp::OnCommandOpenDoc()
{
CTestMDIDoc* pDoc = static_cast< CTestMDIDoc* >(m_pDocTemplateInfinite->OpenDocumentFile(0));
AfxGetMainWnd()->PostMessage(WM_COMMAND, ID_FILE_CLOSE);
}
CTestMDIDoc::~CTestMDIDoc()
{
TRACE(_T("PostMessage(WM_COMMAND, ID_FILE_INFINITE)\n"));
AfxGetMainWnd()->PostMessage(WM_COMMAND, ID_FILE_INFINITE);
}
When ID_FILE_CLOSE command param is processed, the following code is run:
CFrameWnd::OnClose()
CDocument::OnCloseDocument()
delete this;
~CTestMDIDoc()
AfxGetMainWnd()->PostMessage(WM_COMMAND, ID_FILE_INFINITE);
CDocument::~CDocument()
m_pDocTemplate->RemoveDocument(this);
I know that PostMessage is asynchronous so my opinion is that in my test application,
a new document may be created before the previous one has finished its removing from m_pDocTemplate.
Is it the reason why a new document pointer becomes randomly invalid?
Thanks in advance for your answers.
Thanks and regards
Pascal
|
|
|
|
|
You seem to have reached the answer yourself. You open a new document and then post a message to close the current one, which also deletes the document object. This seems the wrong way round to me; you should close the current document first and then open the new one, preferably by direct calls to your close and open routines or via SendMessage() .
Just say 'NO' to evaluated arguments for diadic functions! Ash
|
|
|
|
|
Hi,
I think I have finally found the reason and the solution to my problem.
1) My test application works perfectly; actually, the debug logs are not written entirely because my test application run too fast.
2) Concerning the CDocument invalid pointer assertion, the reason was that in my application (not the test one but the real one) my document class derived from 3 classes as follows:
(.h)
class CMyDoc : public CMyData, public CDocument
{
DECLARE_DYNCREATE(CMyDoc);
...
};
(.cpp)
IMPLEMENT_DYNCREATE(CMyDoc, CDocument)
And MSDN Technical Note 016 (Using C++ Multiple Inheritance with MFC) says that "The base class you specify in IMPLEMENT_DYNAMIC or IMPLEMENT_SERIAL should be the first (or left-most) base class.".
And in my application, CDocument was not the first!
I have put CDocument in first position and now it seems to work all the time without assertion, see fixed code below:
class CMyDoc : public CDocument, public CMyData
For more information, see MSDN TN016.
Bye
Thanks and regards
Pascal
|
|
|
|
|
Hi,
Does anyone know of a list control class which will allow multi-line text items? I have searched CodeProject topics but I can only find an article by Dave Calkins whch isn't a list control and would need a re-write of my code. It also has some variable scoping issues.
Thanks
Tony 
|
|
|
|
|
You maybe interested in changing the list control for a grid control...
in that cas you get multiline edits as well as embedding other controls in the grid.
Check Chris Maunder MFCGridCtrl.
|
|
|
|
|
|
Hi
In my code I am parsing XML using MSXML .But I am not able to get Node values using MSXML .How to read the node values?
IXMLDOMNode* nodeVal;
CString csXMLValue;
BSTR bsSelectedNodeItemName;
hResult = pChildNodeList->get_item( nIdx, &nodeVal );
hResult = nodeVal->get_nodeName(&bsSelectedNodeItemName);
if ( 0 == _tcscmp( OLE2T( bsSelectedNodeItemName ), L"User" ) )
{
nodeVal->get_nodeValue(&vtNodeValue);
}
but vtNodeValue is NULL .My XML node structure is
<User >2700</User>
<User>3700</User>
I want to read the node values ie,2700 and 3700
thanks in advance
|
|
|
|
|
What you (and common sense) call 'node value' of User is actually just its child, another (text) node.
If the Lord God Almighty had consulted me before embarking upon the Creation, I would have recommended something simpler.
-- Alfonso the Wise, 13th Century King of Castile.
This is going on my arrogant assumptions. You may have a superb reason why I'm completely wrong.
-- Iain Clarke
[My articles]
|
|
|
|
|
click here ->[^]
Yes U Can ...If U Can ,Dream it , U can do it ...ICAN
|
|
|
|
|
Hello Friends
I am working on a MFC based application. and one class is exported like this
class AFX_EXT_CLASS sample : public CObject
{
}
In this way they are exporting to some other classes.But when I tried to change or add some more variables in its header file and then run,It Crashes.
And Its header file is not in ints solution,Its in some other Interfaces.
I have two Questions Now:
1)How Can I add more variables to Header file?
2)How can I use this class variables of this one dll into another dll.I am aware abt linking lib and dll.But main Question is how do i will use this into any other solution?
Thanks In Advance.
Any Help will be Appreciated.
Regards
Yogesh
|
|
|
|