|
Mark Salsbery wrote: Waiting on I/O should be done on separate thread(s)
I agree, UI and IO should be kept apart.
==============================
Nothing to say.
|
|
|
|
|
Thanks you all for the replies it was very usefull i learned alot!!!
|
|
|
|
|
A Universal TCP Socket Class for Non-blocking Server/Clients
Single Threaded
The function PumpMessages() processes all Windows messages which arrive in the application so the GUI stays responsive although the code runs an endless loop:
mi_Socket.Listen(0, ms32_Port, 50);
while (...)
{
PumpMessages();
DWORD u32_Event;
SOCKET h_Socket;
DWORD u32_Error = mi_Socket.ProcessEvents(&u32_Event, &h_Socket, ....);
if (u32_Error == ERROR_TIMEOUT)
continue;
if (u32_Event & FD_ACCEPT) { }
if (u32_Event & FD_READ) { }
if (u32_Event & FD_CLOSE) { }
if (u32_Error) { }
};
|
|
|
|
|
Hi all,
Is there any alternate of MCIWndCreate API.
I want to play video in my application, and for doing it i have used MCIWnd functions. But my application is crashing due to these functions.
i have written this line
<pre>
m_myPlayer = MCIWndCreate(m_WndPreview->m_hWnd,AfxGetInstanceHandle(),WS_CHILD | WS_VISIBLE |MCIWNDF_NOMENU,File_Path);</pre>
Can anybody help me in this???
|
|
|
|
|
Your question is a bit vague. Are you looking for an alternate way to play AVI files? Are you looking for an alternate way to create the same MCI window? Aside of this, if it makes your application crash you are probably doing something wrong.
Anyways, to play all kinds of media, i'd try DirectShow[^] rather than MCI. I hope this can help you.
> The problem with computers is that they do what you tell them to do and not what you want them to do. <
> If it doesn't matter, it's antimatter.<
|
|
|
|
|
Hi all,
I start to do a simple application to control the P2LTCH(to blink a LED). So the toggle function as follow,
void toggleLed(unsigned char ledMask)
{
asm
(
mov dx, P2LTCH
);
}
However, it returns the following error.
Error [318] D:\Profiles\PC\WorkOnProjects\PIC\Demo\led_blink.c; 41.1 string expected
Error [194] D:\Profiles\PC\WorkOnProjects\PIC\Demo\led_blink.c; 41.1 ")" expected
Error [312] D:\Profiles\PC\WorkOnProjects\PIC\Demo\led_blink.c; 41.1 ";" expected
I do the coding on MPLAB IDE. Any comments really appreciate.
I appreciate your help all the time...
CodingLover
modified 1-Nov-11 5:54am.
|
|
|
|
|
The inline assembler block starts with "{".
|
|
|
|
|
I already tried that. But it doesn't work for me.
I appreciate your help all the time...
CodingLover
|
|
|
|
|
See here[^], and yes you must use curly braces around your code block.
Unrequited desire is character building. OriginalGriff
I'm sitting here giving you a standing ovation - Len Goodman
|
|
|
|
|
Thanks for the comment.
I tried a same example code segment from that page.
void toggleLed(unsigned char ledMask)
{
__asm {
mov al, 2
mov dx, 0xD007
out dx, al
}
}
Once I compile the code it gives the following error. It wired to me from what the documentations explain (the link you gave, book I refer, etc..)
Error [192] D:\Profiles\PC\WorkOnProjects\PIC\Demo\led_blink.c; 39.1 undefined identifier "__asm"
Error [312] D:\Profiles\PC\WorkOnProjects\PIC\Demo\led_blink.c; 39.7 ";" expected
Error [285] D:\Profiles\PC\WorkOnProjects\PIC\Demo\led_blink.c; 44.1 no identifier in declaration
Warning [374] D:\Profiles\PC\WorkOnProjects\PIC\Demo\led_blink.c; 44.1 missing basic type; int assumed
Error [314] D:\Profiles\OC\WorkOnProjects\PIC\Demo\led_blink.c; 44.1 ";" expected
I appreciate your help all the time...
CodingLover
|
|
|
|
|
I just tried a search for P2LTCH with google, finding the following block of code here.
void
toggleLed(unsigned char ledMask)
{
#define P2LTCH 0xFF5E /* The address of the I/O register. */
asm {
mov dx, P2LTCH
in al, dx
mov ah, ledMask
xor al, ah
out dx, al
};
}
Reading through this, I thought of your asm statement - In the code you showed using round braces, you used the asm keyword. Later you showed some code with curly braces, however I see that in the seconds code snippet you have used the __asm keyword, instead.
If you haven't already, I'd try the syntax used in the above snippet. I've a very hazy memory that somewhere I read that the __asm keyword is a MS thing. Dunno, too lazy to check.
Though I do note that in Code::Blocks, asm gets syntax-highlighted, while __asm doesn't..
|
|
|
|
|
Actually that is the same I am referring, O'Reillys' book. But it doesn't work for me. Seems to me that my compiler is not support this.
I appreciate your help all the time...
CodingLover
|
|
|
|
|
Woooooah! Hold on just a minute. Did you say you're trying this code in mplab?
That code is obviously x86 inline assembly, yet I though MPLab was for embedded devices - i.e mainly PICs.
Looking at your compile log, it seems remarkably similar to the exerpt I just gotfor the HiTech C compiler, as shown below:
Executing: "C:\Program Files (x86)\HI-TECH Software\PICC\9.80\bin\picc.exe" --pass1 C:\Users\enhzflep\Documents\mplab\proj1\..\main.c -q --chip=16F84A -P --runtime=default --opt=default -D__DEBUG=1 -g --asmlist "--errformat=Error [%n] %f; %l.%c %s" "--msgformat=Advisory[%n] %s" "--warnformat=Warning [%n] %f; %l.%c %s"
Error [317] C:\Users\enhzflep\Documents\mplab\proj1\..\main.c; 5.5 "(" expected
Error [318] C:\Users\enhzflep\Documents\mplab\proj1\..\main.c; 5.5 string expected
Error [194] C:\Users\enhzflep\Documents\mplab\proj1\..\main.c; 5.5 ")" expected
Error [312] C:\Users\enhzflep\Documents\mplab\proj1\..\main.c; 5.5 ";" expected
Error [285] C:\Users\enhzflep\Documents\mplab\proj1\..\main.c; 15.1 no identifier in declaration
Warning [374] C:\Users\enhzflep\Documents\mplab\proj1\..\main.c; 15.1 missing basic type; int assumed
Error [314] C:\Users\enhzflep\Documents\mplab\proj1\..\main.c; 15.1 ";" expected
********** Build failed! **********
In that case, I think the problem is something else - i.e No, this compiler
(a) won't accept the asm keyword (but you can easily make functions in asm files then link them together into your program)
and more importantly (just now)
(b) won't build programs that you can run on your PC - I'd have expected to see the code snippet in concern built using VS or GCC.
Though, perhaps I'm just missing something?
|
|
|
|
|
enhzflep wrote: I've a very hazy memory that somewhere I read that the __asm keyword is a MS thing.
This is true (about the double underscore, not your memory).
"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
|
|
|
|
|
Touchè!
|
|
|
|
|
I reread your original message and it seems you are using MPLAB to build this code. I suggest you check the documentation for your compiler to find out exactly why it complains about this. Are you sure this compiler supports the __asm or asm keywords? You may also be better using the MPLAB forum to get an answer to your question.
Unrequited desire is character building. OriginalGriff
I'm sitting here giving you a standing ovation - Len Goodman
|
|
|
|
|
Yeah, seems to me that the compiler I am using with the MPLAB is not supporting the syntax. I am searching on the documentation at the min.
I appreciate your help all the time...
CodingLover
|
|
|
|
|
You need to terminate the __asm block with a ';'
e.g.
__asm
{
mov eax,0
mov ebx,10
};
Also note that you MUST preserve (push/pop) any registers you use within an __asm block.
Another thing to note when using 'out' instruction - you may trigger an exception because the Windows OS allows only a few 'out' addresses accesses directly like that from user mode programs (ring 3).
If I remember correctly only tho old LPT ports are accessible.
|
|
|
|
|
I tried the same too, but no luck.
Snorri wrote: Another thing to note when using 'out' instruction - you may trigger an exception because the Windows OS allows only a few 'out' addresses accesses directly like that from user mode programs (ring 3).
I don't have a big picture about this in my mind, since I am new to embedded systems yet. However, that information could be a value added. Thanks a lot.
I appreciate your help all the time...
CodingLover
|
|
|
|
|
I found the solution my self by referring the MPLAB documentation. Inline assembly need to be wrapped as follows.
#asm
#endasm
I appreciate your help all the time...
CodingLover
|
|
|
|
|
CodingLover wrote: ...by referring the MPLAB documentation.
Keep that under your hat.
"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
|
|
|
|
|
Currently I am notifying all the open documents like below.
for(POSITION pos = pDocMgr->GetFirstDocTemplatePosition();pos;)
{
pDocTemp = pDocMgr->GetNextDocTemplate(pos);
for(POSITION postemp = pDocTemp->GetFirstDocPosition();postemp;)
{
pDoc = (CMDITabsDemoDoc*)pDocTemp->GetNextDoc(postemp);
pDoc->Notify(somedata);
}
}
But now I only want to notify to the active document. Which function is available to get the active document?
Note : If there are 4 tabs and tab2 is open and I am having focus on some other dialog then also it should return tab2 as active tab. However if application is minimized then it should return NULL or some other indicator.
|
|
|
|
|
You can use CFrameWnd::GetActiveDocument .
This returns the document attached to the currently active view.
|
|
|
|
|
I'm still having trouble writing a Mime list to the Metadata file for IIS on 5.5 and 6.0. My Default Documents was working, but stopped, not sure when I broke it.
I can write the Virtual Path, the asp.net Script Maps, Read write permissions.
The default Docs is the LPWSTR pszDefaultDocs[], and the Mime is pszMimes[].
If anybody with Metadata experience can just take a look at it, perhaps it just something real small I missed.
The last time I worked on it, the Mime array write said I did not submit a safe array. The metedata element type for Mimes is a string array. The element type for default docs is just a string.
LPWSTR pszMimes[] = {
L".application, application/x-ms-application",
L".deploy, application/octet-stream",
L".flv, video/x-flv",
L".manifest, application/x-ms-manifest",
L".msp, application/octet-stream",
L".msu, application/octet-stream",
};
dwNumber = sizeof(pszMimes)/sizeof(LPWSTR);
VariantInit(&var);
hr = ADsBuildVarArrayStr(pszMimes, dwNumber, &var);
if (FAILED(hr)) goto CLEANUP;
if ( SUCCEEDED (hr )) {
hr = pADs->PutEx(ADS_PROPERTY_UPDATE, bstr_MimeMap, CComVariant(var) );
}
VariantClear(&var);
LPSAFEARRAY psaMimes;
psaMimes = _create_W3SVC_MimeMap_Array();
VariantInit(&var);
LPWSTR pszDefaultDocs[] = {
L"index.aspx",
L"Default.aspx",
};
dwNumber = sizeof(pszDefaultDocs)/sizeof(LPWSTR);
VariantInit(&var);
hr = ADsBuildVarArrayStr(pszDefaultDocs, dwNumber, &var);
if (SUCCEEDED(hr)) {
hr = pADs->PutEx(ADS_PROPERTY_UPDATE, bstr_DefaultDoc, var);
}
VariantClear(&var);
|
|
|
|
|
Well I fixed the DefaultDocs, had the keyname wrong, and I reformatted the pszDefaultDocs
So thanks Fixed.
LPWSTR pszDefaultDocs[] = {
L"index.aspx, default.aspx"
};
dwNumber = sizeof(pszDefaultDocs)/sizeof(LPWSTR);
VariantInit(&var);
hr = ADsBuildVarArrayStr(pszDefaultDocs, dwNumber, &var);
if (SUCCEEDED(hr)) {
hr = pADs->PutEx(ADS_PROPERTY_UPDATE, bstr_DefaultDoc, var);
}
VariantClear(&var);
|
|
|
|