|
I replaced the BEGIN_MESSAGE_MAP macro with its expanded form and stepped through the population of the message map array. It was then easy to compare the (apparent) size of the AFX_MESSAGE_ENTRY structure with the amount of info being poked in at the memory location.
|
|
|
|
|
When we upgraded to VC10 from VC6 we did this exact same thing and everythng broke also.
If you vote me down, my score will only get lower
|
|
|
|
|
Hello Friends
I am reading a xml file(suppose A.xml) using MSXML::IXMLDOMDocumentPtr and all related classes of MSXML.
Now,I want to create another xml file with new data and want to replace with A.xml.
Both xml will be having same Nodes but their child nodes can be different.
Now,My question is
Is there any way that I can store all the data in DomDocumentPtr object and then replace with it existing xml file Dom Pointer?
Or do i need to create another xml on disc and then i have to replace one file with another file.
Which way i can achieve this?
Thanks and Regards
Yogesh sikri
|
|
|
|
|
XmlDocument::ImportNode does the job, It states and i quote:
"The ImportNode method is the mechanism by which a node or entire node subtree is copied from one XmlDocument to another. The node returned from the call is a copy of the node from the source document, including attribute values, the node name, node type, and all namespace-related attributes such as the prefix, local name, and namespace Uniform Resource Identifier (URI). The source document is not changed. "
more from MSDN..
Code from MSDN:
#using <System.Xml.dll>
using namespace System;
using namespace System::IO;
using namespace System::Xml;
int main()
{
XmlDocument^ doc = gcnew XmlDocument;
doc->LoadXml( "<bookstore><book genre='novel' ISBN='1-861001-57-5'><title>Pride And Prejudice</title></book></bookstore>" );
XmlDocument^ doc2 = gcnew XmlDocument;
doc2->Load( "books.xml" );
XmlNode^ newBook = doc->ImportNode( doc2->DocumentElement->LastChild, true );
doc->DocumentElement->AppendChild( newBook );
Console::WriteLine( "Display the modified XML..." );
doc->Save( Console::Out );
}
|
|
|
|
|
Hi all,
I want to learn embedded systems, and looking some reading materials which explain from the basic concepts. About PIC programming, designing simple circuit and so on.
I appreciate your help all the time...
CodingLover
|
|
|
|
|
This is the same guy who said "debugging is the oposite of programming".
My advice is to stop wasting our time with silly questions like this. If you had ANY intention of actually becoming an embedded programmer than you would already have books on the various processors used, ARM, Siemens etc and commonly used hardware such as PICs and FPGAs.
==============================
Nothing to say.
|
|
|
|
|
Erudite__Eric wrote: This is the same guy who said "debugging is the oposite of programming".
Yes I am.
Erudite__Eric wrote: My advice is to stop wasting our time with silly questions like this.
I wonder that this is the way experienced members in code project helping others. It may be silly question to you, but not for me. I have an interesting to learn embedded systems, and that is why I ask it openly. Since I have experienced in C/C++ a lot, I decide to plan something beyond that, yet relevant. That is why I ask my question in C/C++ forum too.
If you have any solution please let know. If not don't say anything to discourage others. If you really want to do that, show me the pros and cons I have.
I appreciate your help all the time...
CodingLover
|
|
|
|
|
Your question is too broad, too unfocused, not specific.
Your previous question about assembler, trying to turn a led on and off, what hardware were you running it on? Was it a test board, or some real bit of hardware you got hold of? How were you loading your code onto the hardware?
See what I mean?
If you want to learn embedded programming then get yourself some test/development hardware that you can practice on. Look on google. OSR used to do one I seem to recall.
==============================
Nothing to say.
|
|
|
|
|
Now I see your point. Sorry for the confusion.
May be that is because of I haven't much knowledge related with Embedded systems, pic and so on. So I have no clear picture in my mind about the stuff. You guys can guide me on to the relevant track. Basically I want to use my knowledge of C/C++ in hardware stuff, like PIC and so on. I have only my own interest, nothing to do with my job.
I appreciate your help all the time...
CodingLover
|
|
|
|
|
CodingLover wrote: If you have any solution please let know.
Solution to what? You say you want to learn programming on embedded systesms, PIC etc., have you tried the obvious starting point[^]?
Unrequited desire is character building. OriginalGriff
I'm sitting here giving you a standing ovation - Len Goodman
|
|
|
|
|
Of course I tried mate. Already collect some stuff. But most of them are too complex to understand at once, because of the lack of knowledge on the basis.
I appreciate your help all the time...
CodingLover
|
|
|
|
|
This looks good:
http://www.quasarelectronics.com/3081-pic16f84a-introduction-to-pic-programming-tutorial.htm[^]
Now, if you dont order that straight away and start learning, we will never answer another question of yours.
--edit--
Actually, at £17 thats damn cheap, I might get one myself, always fancied doing a bit more embedded!
(I have been working in the Windows kernel for 13 years, mostly hardware related, but it could be fun to get right into the hardware. I also ought to learn the Linux kernel some time...)
|
|
|
|
|
That make sense to me too.
I already bought simple electronic components too, to familiarize with them. At the time I'll put an order on this too. Download a simple simulator and working on it too.
I appreciate your help all the time...
CodingLover
|
|
|
|
|
CodingLover wrote: But most of them are too complex to understand at once
So how do you think posting questions here will change that? The only way to learn is to study hard and practice. These forums are for technical questions not for "How can I learn X?".
Unrequited desire is character building. OriginalGriff
I'm sitting here giving you a standing ovation - Len Goodman
|
|
|
|
|
Don't misinterpret the original question mate. I am asking about some reading materials where I can learn the basis on embedded systems and all. Not expecting any code or anything. So far I haven't make such a request on CP too.
I ask about the materials because people who has already refer them have a better understanding about the stuff.
I appreciate your help all the time...
CodingLover
|
|
|
|
|
CodingLover wrote: Don't misinterpret the original question mate.
I'm not (yet) your mate; that is a term of endearment reserved for my close friends only.
Unrequited desire is character building. OriginalGriff
I'm sitting here giving you a standing ovation - Len Goodman
|
|
|
|
|
If you would like to learn about embedded programming and hardware development, start small.
1. Purchase a student kit from Microchip.
http://www.microchip.com/stellent/idcplg?IdcService=SS_GET_PAGE&nodeId=1406&dDocName=en539716&redirects=picdemlab
2. Read ALL of the information provided.
3. Familiarize yourself with the datasheet for the micro-controller you are using. It is your best friend.
4. Follow the examples closely.
5. Visit the forums to search for answers to your questions.
6. If after step 5 you are still unable to find the answers to your questions, ask for help online. People prefer to only help those that are willing to try to help themselves first.
|
|
|
|
|
UINT_PTR timer = SetTimer(1 , 1000 , NULL);
m_timeOut = FALSE;
while(!m_rxBufferRecivied && !m_timeOut)
{
}
KillTimer(timer);
.
.
.
void CMainFrame::OnTimer(UINT_PTR nIDEvent)
{
m_timeOut = TRUE;
}
In this code i wait in a while loop unil input buffer recieved.
Before the loop i set a timer to wait maximum 1 second so the program wont stack in a loop(in case there is error receving buffer).
If i remove the while loop timer callback function ONTimer works fine every second but with the loop the program stacks in a endless loop.
What am i doing wrong?
Thanks.
|
|
|
|
|
Your while() loop is not relinquishing control of the CPU. Inside of that loop, you're going to need to poll for messages.
"One man's wage rise is another man's price increase." - Harold Wilson
"Fireproof doesn't mean the fire will never come. It means when the fire comes that you will be able to withstand it." - Michael Simmons
"Show me a community that obeys the Ten Commandments and I'll show you a less crowded prison system." - Anonymous
|
|
|
|
|
Hi,
1. first a general note: empty loops that spin the CPU until some condition is met are a bad idea as they waste CPU cycles. You should look first for an event-based approach, where the system tells you something happened rather than you permanently polling for it. If no event-based solution exists, your loop should relinquish the CPU by including a "sleep" of a couple of milliseconds at least, so other things can happen while you wait.
2. I don't know on which thread your while loop is executing; if it is on the main thread (the same one that would execute your OnTimer code), then there is no way the app can do both things at the same time: the OnTimer event will only get handled when the while has finished, causing a deadlock. Now read again my #1. If OTOH the while loop is running on another thread, then I don't know why your setup is failing.
3. If all you need is waiting for some input with a time-out, and still assuming there isn't an easy event-based approach, then I'd recommend this (pseudo-code!):
Time limit = now() + maximumWaitTime;
for(;;) {
try getting the input
if (success) break;
sleep(someDelay);
if (now() > limit) break;
}
|
|
|
|
|
Ahh, you have them in the same thread. Your while () loop is taking up all the thread time and the WM_TIMER messange cant get through.
You can multi thread this, or do a loop that checks for received data, then does a sleep(200), then checking again, for a max of 5 attempts.
Or an event, do a waitforsingleobject() then in a the code that sets m_rxbufferrcvd signals the event. (If you can get to that code).
==============================
Nothing to say.
|
|
|
|
|
If you have a long running loop, chewing up cycles waiting for something to happen, to keep the GUI responsive (and to let things like timer events happen), you should periodically let Windows process messages. Stick this somewhere in your 'while' loop. At the top or bottom are the usual places.
while (PeekMessage(&msg, NULL, 0, 0, PM_REMOVE))
{
TranslateMessage(&msg);
DispatchMessage(&msg);
}
And it is true that keeping the GUI and application functions separate in a thread is a good idea, sometimes it's just too much work to re-do an application's logic to introduce threading when none existed before. In those cases, this should do the trick and not be too "architecturally impure".
|
|
|
|
|
No, dont do this, you are reinventing the wheel and possibly introducing instability.
The message pump, which is what this is, is invisible in MFC apps (which I assume this guy is writing). Ansd in a C++ app having messages removed form the apps message queue and translated is at best ugly, and at worst dangerous, unless you KNOW that access to the apps message queue is multithread safe.
The quick solution here is a sleep() call inside the loop. It is sidely used, and isnt going to cause any problems.
==============================
Nothing to say.
|
|
|
|
|
Nonsense. Microsoft even documents this for dealing with exactly the kind of application.
Occasionally, an application needs to examine the contents of a thread's message queue from outside the thread's message loop. For example, if an application's window procedure performs a lengthy drawing operation, you may want the user to be able to interrupt the operation. Unless your application periodically examines the message queue during the operation for mouse and keyboard messages, it will not respond to user input until after the operation has completed.
Plus the user's loop is already preventing message processing, adding a Sleep() call will only *lengthen* the amount of time he's chewing up (real time, not cpu cycles obviously).
This is well documented and long standing solution to *some* (not all) unresponsive GUI / Timer queue issues. Even threaded applications can do this, only not from multiple threads at the same time, obviously.
|
|
|
|
|
Chuck O'Toole wrote: Plus the user's loop is already preventing message processing, adding a Sleep()
call will only *lengthen* the amount of time he's chewing up
No, quite the opposite. A sleep() surrenders the rest of that threads timeslice, it doesnt chew up cycles, it frees them. This function causes a thread to relinquish the remainder of its time slice [^]
And if Microsoft recomends that then I am surprised. I can just imagine the code. DispatchMessage() is locked, because WM_DRAW hasnt come back from your message handler, so in that handler you call another DispatchMessage(). Perhaps you have some other handlers that are slow, so you do the same there. What a mess.
Work intensive code should go in a seperate thread to the UI. Period, properly synchronised with the UI so the user has control.
Chuck O'Toole wrote: not from multiple threads at the same time, obviously.
And why, because the PeekMessage()/TranslateMessage()/DispatchMessage() is not thread safe?
Like I said, you risk instability.
==============================
Nothing to say.
|
|
|
|