|
actually i m sending sms using com port.
mobile connected with machine ,than if application run more than 1 thread and all wants to access this port to send sms,now the problem occur here.
|
|
|
|
|
You should serialize com port access: i.e. each thread may post a new sms message in a queue and then, the 'transmitter' thread will get messages from the queue and send them on the serial port.
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, it is for writing the port, not reading the port then. In that case, I think it is a bit more easier. Anyway, you still need to same principle: the thread that writes to the port creates a queue in which the other threads can push their messages. The access to the queue is protected by critical sections, so that multiple threads cannot write data at the same time in the queue.
To make things a bit easier, you will first need to wrap the SMS data into a specific class (makes it easier to manipulate). Then, you will need to create the queue class: to make things a bit more simple for now, this queue wraps a std::queue with the type of your SMS class. You'll then need to secure the access to the internal queue by using critical section.
After a bit of googling, I found this implementation[^] of a thread-safe queue. Try to understand the code first, then come here and ask specific questions about which part you didn't understand. Then, once you really understood how the code work, you can implement your own version of the queue.
|
|
|
|
|
Actually, I suppose, you can (different threads of the same process). However I agree with you on the 'design philosophy'.
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]
|
|
|
|
|
in my MFC Dialog based application ,i have a list box which contains list of text files with their full file paths. I also have edit box in my MFC application, now i want to display the contents of the file(selected from the list box)into the EditBox. in short i want to open the file in that edit box.... can n e buddy help me out!!!
modified on Monday, November 15, 2010 1:55 AM
|
|
|
|
|
It looks straightforward to me: what's your trouble about?
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]
|
|
|
|
|
CStdioFile Class
CEdit::SetWindowText
|
|
|
|
|
Hi all,
i am using ReadDirectoryChangesW synchronously to monitor a Drive...when ever any file is copied the same is validated and deleted if the file fails the validation check..and the loop continues its wait for next change on the directory monitored...however, when i copy a folder there is an issue..if the folder is invalid and deleted, then the code exits out of the loop of monitoring the directory....i am using recursive deletion to delete folders which are found invalid......
please could i get some help on how to fix this issue......
|
|
|
|
|
Without seeing your code it is impossible to guess what your program is doing. Please edit your message and add the relevant part(s) of your program, and don't forget to use the code block button to surround the code with <pre></pre> tags, to help readability.
Just say 'NO' to evaluated arguments for diadic functions! Ash
|
|
|
|
|
I am trying to multi-thread my OpenGL code but I have been having trouble. At first, I thought that using opengl inside an alternate thread was impossible, so I just did loading operations and passed the data to opengl in the main thread (I knew once I started passing too much data the main thread would lockup, and noticeably freeze the execution of the program while the data was being moved). I found some forum threads discussing opengl and multi-threading but they don't discuss the details that I'm looking for. namely, how and where do I use wglMakeCurrent() and wglShareLists().
I have been trying to create a display list in the alternate thread with the instructions outlined in the aforementioned forum posts but it crashes every time. I can load the model data, I can even load shaders, but loading a model (of any size) crashes the program.
I will show some code snippets but there is really too much to put in one post:
if (!(app.hDC=GetDC(app.hWnd)) ||
!(PixelFormat=ChoosePixelFormat(app.hDC,&pfd)) ||
!SetPixelFormat(app.hDC,PixelFormat,&pfd) ||
!(app.hRC=wglCreateContext(app.hDC)) ||
!(app.hRC_thd=wglCreateContext(app.hDC)) ||
!(wglShareLists(app.hRC, app.hRC_thd)) ||
!wglMakeCurrent(app.hDC,app.hRC))
{
KillGLWindow();
return false;
}
This next bit is all the initialization and render using opengl
GLuint o;
vector<v3> v,n;
vector<v2> u;
vector<face> f;
bool done = false;
void load_thread(void* null)
{
wglMakeCurrent(app.hDC, app.hRC_thd);
load_rs_shdr();
load_obj("cell.obj", v,n,u,f);
gen_display_list(o, v, n, u, f);
done = true;
return;
}
bool init()
{
init_med(v3(0,0,0));
set_light_const(v3(0,10,0), v3(1,1,1));
_beginthread(load_thread, 0, (void*)0);
return true;
}
bool render()
{
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
glLoadIdentity();
gluLookAt(0,0,5,0,0,0,0,1,0);
if(done)
glCallList(o);
return true;
}
I know for sure that my loading functions work, I've been using them for a while now inside my single threaded apps.
I appreciate any help or suggestions anyone has.
|
|
|
|
|
Hello ,everybody !
I want to get the whole screen shot in the SDI project,then save it to a bitmap file.
usually ,the shot just relative to the Device. I want get the whole view's screen shot ,whether the view is be hide by other window.
Is there anyway ?
Thanks for your reply !
|
|
|
|
|
Bring it to the front before taking the screen shot??
CQ de W5ALT
Walt Fair, Jr., P. E.
Comport Computing
Specializing in Technical Engineering Software
|
|
|
|
|
Thanks !
your mean's than call some funtion to show at first. but I think this isn't the goodness.
Is there other way ?
|
|
|
|
|
As far as I know, when you do a screen shot, you get what is on the screen. If part of your content is hidden by other windows, then you need to bring it to the front to take a screen shot. If it is too large for the screen and is partially hidden because it has scrolled, then you have a different problem.
Perhaps someone else has a better idea.
CQ de W5ALT
Walt Fair, Jr., P. E.
Comport Computing
Specializing in Technical Engineering Software
|
|
|
|
|
|
Koma Wang wrote: Is there anyway ?
Yes, you can send the window the WM_PRINT[^] or WM_PRINTCLIENT[^] message and ask the win32k subsystem to paint into the device context you pass in the wParam. Not all windows support these messages (such as windows using DirectDraw) so your results may vary.
Best Wishes,
-David Delaune
|
|
|
|
|
Thanks !
I have a try soon.
|
|
|
|
|
Hi all,
i m using ListCtrl of Report View Type with checkbox property,
i want to identify when i click on ListCtrl its click on list item or checkbox.
i m using this code on NM_Click function
NMLISTVIEW* pNMListView = (NM_LISTVIEW*)pNMHDR;
LVHITTESTINFO hitinfo;
hitinfo.pt = pNMListView->ptAction;
UINT uFlags;
int item = m_Err_List.HitTest(&hitinfo);
if(item != -1)
{
if (uFlags & LVHT_ONITEMSTATEICON)
{
AfxMessageBox("Click on checkbox");
}
}
here message display in both case whether i click on check box or on list item
please help me how can i do this.
thanks in advance
|
|
|
|
|
You have not initialised uFlags to any value so the test is based on whatever arbitrary value exists there.
Just say 'NO' to evaluated arguments for diadic functions! Ash
|
|
|
|
|
please tell me what value
|
|
|
|
|
Le@rner wrote: please tell me what value
I am not sure, what is it supposed to represent? Take a look at the documentation for the message you are decoding to see what values can be returned, and where they are in the message packet that is received in your code.
Just say 'NO' to evaluated arguments for diadic functions! Ash
|
|
|
|
|
Try CListCtrl::HitTest[^] on for size...
> The problem with computers is that they do what you tell them to do and not what you want them to do. <
> Leela: Fry, you're wasting your life sitting in front of that TV. You need to get out and see the real world.
Fry: But this is HDTV. It's got better resolution than the real world <
|
|
|
|
|
Since the checkbox can only exist in the first column (item 0 ), check for that instead.
"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
"Man who follows car will be exhausted." - Confucius
|
|
|
|
|
|
I am getting fault address error in my program. I am running the program in release mode and error is not coming constantly. When i check stack it shows adress 0x0000 or any other garbage address. I do not find any function name in call stack.
My program read data from a hard drive (asynchronously). After reading i process data. Sometimes error occured at address say 0x10000 or sometimes 0x20000. I can not reproduce error at same address and there is no hint for me how to detect error.
Is there any way to know where is the actual problem in my code.
|
|
|
|