|
Wow, do you really want to write white box tests for Visual Studio?
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]
|
|
|
|
|
whitebox testing is my clients requirement. I am deseprately looking for tutorials and tools. I am very confused to write test stubs/drivers for vc++ code. It would be very helpful if you can provide me some info about whitebox testing in vc++.
|
|
|
|
|
Super Hornet wrote: Can anyone provide me information about whitebox testing tools for Visual C++?
better would be function testing using you demo project!
"Opinions are neither right nor wrong. I cannot change your opinion. I can, however, change what influences your opinion." - David Crow Never mind - my own stupidity is the source of every "problem" - Mixture
cheers,
Alok Gupta
VC Forum Q&A :- I/ IV
Support CRY- Child Relief and You
|
|
|
|
|
Does function testing require communication between demo project and main project?
|
|
|
|
|
Hi.. I am writing a RS-232 application with one worker thread. Please tell me what is the best method for invoking the AfxBeginThread. My ideas are,
1. Using SetTimer() method handle it in OnTimer
2. While(1) which is infinite loop
I thought both these methods are not efficient enough. Please tell me any other method for invoking AfxBeginThread.
Thanks in advance
msr_codeproject
|
|
|
|
|
Why do you need multiple AfxBeginThread calls (maybe I haven't got you?)?
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]
|
|
|
|
|
I have a file to be sent over serial port. So every time I am reading that file using a structure and sending. For this I need to call AfxBegingThread till end of the file.
Thank u..
msr_codeproject
|
|
|
|
|
msr_codeproject wrote: For this I need to call AfxBegingThread till end of the file.
Are you sure you really understood the concept of threads ? You need to call AfxBeginThread only once. Then in your thread function, that's where you will send the file over the serial port.
|
|
|
|
|
Cedric Moonen wrote: You need to call AfxBeginThread only once
you need to call AfxBeginThread for each thread you want to create ? no ?
if I want to create 50 threads, I should call it 50 times ?
Watched code never compiles.
|
|
|
|
|
I just can see your 47 th thread handling the 47 th character to be sent over the serial line...
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]
|
|
|
|
|
I only have 42 threads.
Watched code never compiles.
|
|
|
|
|
But your process is still alive so you are going to reach soon 47.
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]
|
|
|
|
|
The answer to life, the universe, number of threads and everything...
> The problem with computers is that they do what you tell them to do and not what you want them to do. <
> Sometimes you just have to hate coding to do it well. <
|
|
|
|
|
making a RS 232 stabil is a hard job.
Consider writing a write and a read thread in your App. So you a 3 Threads.
The best way is with events like
while( ::WaitForSingleObject( hAbort, 0 ) )
{
}
there is also WaitForMultpleObject()
Win32 SDK Serial Comm Made Easy[^]
this one looks more plain but often it is better to adapt:
Non Overlapped Serial Port Communication using Win32[^]
Press F1 for help or google it.
Greetings from Germany
|
|
|
|
|
msr_codeproject wrote: Please tell me what is the best method for invoking the AfxBeginThread.
You call (i.e., invoke) it at the moment you are ready for a secondary thread to exist. Instead of polling the serial port for data, you could let it tell your process when something is ready to be read, like:
HANDLE hCom = CreateFile("\\\\.\\COM1", ...);
...
AfxBeginThread(ReadThread, this);
...
UINT ReadThread( LPVOID p )
{
OVERLAPPED ov = {0};
ov.hEvent = CreateEvent();
while (! bDone)
{
if (! ReadFile(hCom, ..., &ov))
{
if (WaitForSingleObject(ov.hEvent, INFINITE) == WAIT_OBJECT_0)
{
GetOverlappedResult(hCom, &ov, ...);
}
}
}
} This is very simplistic and I've omitted a lot of details, but hopefully you get the general idea.
"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 not able to understand your design, do you want to have worker thread active all the time and do you want to create workerthread everytime request came
"Opinions are neither right nor wrong. I cannot change your opinion. I can, however, change what influences your opinion." - David Crow Never mind - my own stupidity is the source of every "problem" - Mixture
cheers,
Alok Gupta
VC Forum Q&A :- I/ IV
Support CRY- Child Relief and You
|
|
|
|
|
I am fully confused.. Again I am explaining you...This is my problem.
I have a file(let us say 5MB size). I need to send this file over serial port to a client.
As I can't send whole file at a time, I am reading the file into a structure(let us say 50 bytes), and sending.
After receiving 50 bytes of data the client will send back some acknowledgment. If acknowledgment is proper, I will send the next 50 bytes of data. Otherwise I will send the previous 50 bytes of data.
So this cycle repeats until the end of the file.
Now tell me how can I proceed. Am I going in a right path.
Thanks in advance
msr_codeproject
|
|
|
|
|
msr_codeproject wrote: Am I going in a right path.
Sounds like it. I would opt for synchronous communication so that the "send" and "receive" packets match up. Asynchronous communication would allow them to happen concurrently.
"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
|
|
|
|
|
#include <iostream.h>
I want to print the "helloworld" but it print "hell" ,why??
void show( char str[])
{
for (int i=0; i < sizeof(str)/sizeof(str[0]); ++i)
cout << str[i];
}
int main()
{
char str[]="helloworld!";
show(str);
return 0;
}
|
|
|
|
|
wbgxx wrote: I want to print the "helloworld" but it print "hell" ,why??
Because the size of a pointer is 4. Try strlen() 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
|
|
|
|
|
'str' is a pointer.
sizeof a pointer is 4 (on Win32). so you get four characters: h,e,l,l.
if you want to get the length of a character string, use strlen .
|
|
|
|
|
wbgxx wrote: void show( char str[])
{
for (int i=0; i < sizeof(str)/sizeof(str[0]); ++i)
cout << str[i];
}
This code is the same as this:
void show(char *str)
{
for (int i=0; i < sizeof(str)/sizeof(str[0]); ++i)
cout << str[i];
}
The array decays to a pointer. The size of a pointer is 4 bytes and the size of a char is 1.
Steve
|
|
|
|
|
It's worth noting this way it would work:
void show( char str[], int size)
{
for (int i=0; i < size; ++i)
cout << str[i];
}
int main()
{
char str[]="helloworld!";
show(str, sizeof(str)/sizeof(str[0]));
return 0;
}
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]
|
|
|
|
|
Yeah, thanks for advantage!
|
|
|
|
|
Here's another alternative (MSVC6 can't handle it):
void show(const char *pStr, int size)
{
for (int i=0; i<size; ++i)
{
cout << pStr[i];
}
}
template <int N>
inline
void show(const char (&a)[N])
{
show(a, N-1);
}
int _tmain(int argc, _TCHAR* argv[])
{
char str[] = "Hello world!";
show(str);
cout << endl;
return 0;
}
Steve
|
|
|
|