|
If there is no data coming on the port anymore and if the read timeout of the port is set to infinite, the ReadFile function will wait until data is received (thus it seems to 'hang').
To change this behavior, you can use the SetCommTimeout function.
But I suggest you to read a little more documentation about how serial ports work because you seem to lack some important informations there...
Hope this helps
|
|
|
|
|
Respected Sir,
I read your suggestion and tried setting the timeout to a lower value. I set it to the following values :-
commTimeout.ReadIntervalTimeout = 10;
commTimeout.ReadTotalTimeoutConstant = 10;
commTimeout.ReadTotalTimeoutMultiplier = 1;
commTimeout.WriteTotalTimeoutConstant = 10;
commTimeout.WriteTotalTimeoutMultiplier = 1;
Still no use. The ReadFile function makes the program hang. Please can you suggest some sample values.
Thanking you.
|
|
|
|
|
Still not enough information. It is well known that ReadFile and WriteFile both work. The problem must be in your code. Post some sample code.
It may be simply that you call ReadFile again when there is nothing for it to read; what if you send it another byte from the other computer?
The opinions expressed in this communication do not necessarily represent those of the author (especially if you find them impolite, discourteous or inflammatory).
|
|
|
|
|
In non-overlapping mode, when you call ReadFile, it will wait until it reads a byte at least. It also depends on the input size as I remember.
You really should not call ReadFile or WriteFile in your main thread, you better use another thread to do this, which will keep your program responding, and it is better to use proper time-out values for the port, so that ReadFile will fail after a certain amout of time if nothing is read.
Does that do any help?
this is this.
|
|
|
|
|
Hiii
i have used ADO for linking my database in vc++...
how can i add a function which searcges for a particular value in a field....
please help
manav
|
|
|
|
|
Use an ADO recordset with a query like
"SELECT * FROM [Table] WHERE [FIELD]=value;"
The opinions expressed in this communication do not necessarily represent those of the author (especially if you find them impolite, discourteous or inflammatory).
|
|
|
|
|
i doubt you code this directly in C++...
TOXCCT >>> GEII power [toxcct][VisualCalc]
|
|
|
|
|
No, of course not!
You use a recordset, (coded in C++) which needs a query string like the one I showed.
The opinions expressed in this communication do not necessarily represent those of the author (especially if you find them impolite, discourteous or inflammatory).
|
|
|
|
|
|
Hi
This is again a problem with thread. The thread is affected by programs running on the background. It is affected by the programs showing in the system tray. Is there any way to close all programs and processes other than my application and related processes and threads.
Help Me Soon.
Regards
Sreekanth Muralidharan,
Corporate Systems Consultant [Embedded Systems],
INDIA
|
|
|
|
|
Sreekanth Muralidharan wrote:
Is there any way to close all programs and processes other than my application and related processes and threads.
EnumProcess and then Use WM_QUIT to kill Process other than you!
"Opinions are neither right nor wrong. I cannot change your opinion. I can, however, change what influences your opinion." - David Crow
cheers,
Alok Gupta
|
|
|
|
|
Hi Alok
You are back again!! Glad for me !!
Thanks a lot. Will check that and shoot you a reply.
Shall we now open bottles?
Regards
Sreekanth Muralidharan
Sreekanth Muralidharan,
Corporate Systems Consultant [Embedded Systems],
INDIA
|
|
|
|
|
Sreekanth Muralidharan wrote:
Shall we now open bottles?
Your Wish
"Opinions are neither right nor wrong. I cannot change your opinion. I can, however, change what influences your opinion." - David Crow
cheers,
Alok Gupta
|
|
|
|
|
Hi Alok
See.. If I am setting the priority of the application process as a REALTIME_PRIORITY_CLASS in its OnInitDialog() function (if not in this function, where?) and setting the thread created by that application using SetThreadPriority() (calling in the thread itself) to TIME_CRITICAL_PRIORITY level , what would be the priority of the thread that I have created? Can any process or thread interrupt the thread I have created?
Regards
Sreekanth Muralidharan
Hyderabad
Sreekanth Muralidharan,
Corporate Systems Consultant [Embedded Systems],
INDIA
|
|
|
|
|
Sreekanth Muralidharan wrote:
TIME_CRITICAL_PRIORITY level , what would be the priority of the thread that I have created? Can any process or thread interrupt the thread I have created?
According to MSDN, REALTIME_PRIORITY_CLASS :-" A thread with a base priority level above 11 interferes with the normal operation of the operating system. Using REALTIME_PRIORITY_CLASS may cause disk caches to not flush, hang the mouse, and so on.
"
So i believe no process or thread wil interrupt your high priority thread
"Opinions are neither right nor wrong. I cannot change your opinion. I can, however, change what influences your opinion." - David Crow
cheers,
Alok Gupta
|
|
|
|
|
I think I'll never buy products from your company .
Seriously, I don't think this is a good solution ! Maybe the user doesn't want that your program kills its own applications don't you think ?
A better way would be to solve the problem itself. Maybe this is due to thread priority or something like that.
|
|
|
|
|
Hi Cedric
What you said was perfect. But I am using a thread with a real time priority for that. But still the disturbances happen.
Regards
Sreekanth Muralidharan
Sreekanth Muralidharan,
Corporate Systems Consultant [Embedded Systems],
INDIA
|
|
|
|
|
Hi:
I overload the CToolBar class , and process the default TBN_GETINFOTIP event to dynamicly changge the tips.
( ON_NOTIFY_REFLECT( TBN_GETINFOTIP, OnGetInfoTip)
the way works well. Then I create a toolbar in the statusbar in one of my project, but this way doesn't work at all. I couldn't get the OnGetInfoTip event form the toolbar created in the statusbar now. Why? how could I do?
Thanks
Benben
|
|
|
|
|
Get the tooltip control associated to your toolbar (MFC : GetToolTips()) and call the RelayEvent() function once after the init of the toolbar.
~RaGE();
|
|
|
|
|
|
Hey guys,
I'm absolutely not a experienced programmer but i have a problem, i will be happy someone can help me.
I have a dialog class CSimulator with a number of timers:
//part of the XXXXX.h file ****************************************************
class CSimulator : public CDialog
{
DECLARE_DYNAMIC(CSimulator)
protected:
virtual void DoDataExchange(CDataExchange* pDX); // DDX/DDV support
DECLARE_MESSAGE_MAP()
...
...
...
public:
virtual BOOL OnInitDialog();
void OnTimer(UINT nIDEvent);
//part of the XXXX.cpp file ****************************************************
IMPLEMENT_DYNAMIC(CSimulator , CDialog)
void CSimulator::DoDataExchange(CDataExchange* pDX)
{
CDialog::DoDataExchange(pDX);
}
BEGIN_MESSAGE_MAP(CSimulator, CDialog)
ON_WM_TIMER()
...
...
END_MESSAGE_MAP()
void CSimulator::OnTimer(UINT nIDEvent)
{
...
...
...
CDialog::OnTimer(nIDEvent);
}
When i start the class CSimulator from another class (CWnd) with DoModal() everything is working fine and the function CSimulator::OnTimer(UINT nIDEvent) is called after setting a timer with SetTimer(IDTIMER,50,0);
But when i start the class CSimulator from another class (CWnd) with m_Simulator.Create(IDD_SIMULATION_DIALOG); (m_Simulator is the instance of class CSimulator)
i have a problem. In this situation i don't receive the ON_WM_TIMER message .
Note: At another situation i need the class CSimulator (CDialog) showed in a window, but in this situation i only need the algorithm of the class, only modeless
What i'm doing wrong? I search a lot, but don't see the problem, can anyone help me?
Thanks, Bart
|
|
|
|
|
ON_WM_TIMER requires a message pump to be running, that's why you are not getting the messages.
Regards
Senthil
_____________________________
My Blog | My Articles | WinMacro
|
|
|
|
|
Thanks, but how can i solve the problem? What is it for a message pump?
Greetz, Bart
|
|
|
|
|
Probably a silly question but where are you calling SetTimer() from?
If you are calling it in IntiDialog() in the CSimulator class then
it is never getting called when you instantiate and create the dialog
class from your CWnd class. If not then maybe you have some other code
in InitDialog() that needs to be run.
Steve T
|
|
|
|
|
Hi,
I've trying to create a browser helper object (BHO) for explorer. I've got a main "manager" class that initializes two objects. Each of these uses an simple XML parser (using MSXML). Now, when parsing XML files, I want to store the results to a struct array (not a class). The struct array is in turn comprised of a few other struct arrays. All mem allocation is static, only the topmost parent struct array is dynamically allocated. That's where the problem is: When I allocate (using new) the struct arr in the first object, its ok. Then when I init the second obj, the new fails and crushes the explorer. I did a simple test in the second obj:
int *i = new int[x];
when x is <255 it's ok. if x>=255 then it crashes (and of course, my struct arr is bigger than 255*sizeof(int) bytes). I don't think I have any serious mem leaks in the code before this.
Has anyone seen this before? Is there a memory limit imposed by explorer (unlikely as it sounds)? I would appreciate any comments.
Thanks,
Pete
|
|
|
|