|
The port seems to be setup good enough.
To put it in short terms: I suspect that your MC doesn't do what you think it does.
I tried running the code you've written and it works. It receives the bytes sent to the port and writes them to the console window.
Note that calling ::ReadFile in non-overlapped mode will be a blocking call. You decide for how long it should block and when to timeout and what for by a call to ::SetCommTimeouts after calling ::SetCommState.
Regarding ::CloseHandle() it cannot be called in the code you've written.
The call to ::CloseHandle() is on the other side of an endless loop.
Since you are running the app as a console app it is the responsability of the console to terminate the program running in the console, if it's possible, when you close the console window.
I suspect a call to _endthread() that will end your app and that would let the run-time system reclaim allocated resources such as the port since there is only one thread in your app. As a result of that you will see the cleanup and close statements in PortMon.
HyperTerminal might complain if the MC is malfunctioning or is not setup the same as HT, e.g. uses the wrong baudrate or uses two stopbits instead of one. But this is not unique for HT, your app should react the same way by getting nonsense.
If I were you I would get an oscilloscope or logic analyser to see what's really going on with the RxD and TxD lines.
--
Roger
|
|
|
|
|
Thank you for your reply.. Sorry i'm only getting back now.. I was busy tweaking the code and the MC to see where the problem was.. turns out it was the MC.. there was problems with synchronization when talking to the PC..
Thank you all for your time to help.. I've sure have learnt some pointers from the replies..
|
|
|
|
|
I want to write a program that makes a particular exe run everyday. For this, it should add that exe to Scheduled Tasks. But how to do that programatically?
All I know is, when we add a new Scheduled Task, say MyTask, it creates a file "C:\Windows\Tasks\MyTask.job", but this file contains some binary data and can't be directly created/editad.
Any Standard Ways / Workarounds ?
It's better to know some of the questions than all of the answers.
Pravin.
|
|
|
|
|
You need to use ITaskScheduler interface.
You can easily come to know how to use it, and there are related interfaces.
|
|
|
|
|
Here's a starting point:
HRESULT hr = CoInitialize(NULL);
if (SUCCEEDED(hr))
{
ITaskScheduler *pITaskScheduler = NULL;
hr = CoCreateInstance(CLSID_CTaskScheduler, NULL, CLSCTX_INPROC_SERVER, IID_ITaskScheduler, (void **) &pITaskScheduler);
if (SUCCEEDED(hr))
{
...
pITaskScheduler->Release();
}
CoUninitialize();
}
See here for more.
"One must learn from the bite of the fire to leave it alone." - Native American Proverb
|
|
|
|
|
I don't understand why NT uses a 2-step physical memory locating method. it splits a 32-bit virtual address in 3 parts. two first parts are indexes of page-directory and page-table respectively.
why dosn't it split virtual adress in 2 parts in which the fist part only indexs page table index and the CR3 register points to the first index of page table?
please explain more and more!!
|
|
|
|
|
I have a simple server and client source code that can run. The problem is I type two same IP address in the source code of server and client, the program can connect and send. But when I test the program in two PC and type both IP address in both of the program, the program cannot work. What is the problem of it?
|
|
|
|
|
Hello,
It is said in MSDN for the SDK SelectObject fn that "An application should always replace a new object with the original, default object after it has finished drawing with the new object".
Is it neccessary for MFC CDC object also?
- NS -
|
|
|
|
|
Nishad S wrote:
Is it neccessary for MFC CDC object also?
Why Not??
"Opinions are neither right nor wrong. I cannot change your opinion. I can, however, change what influences your opinion." - David Crow
cheers,
Alok Gupta
VC Forum Q&A :- I/ IV
|
|
|
|
|
Yes!
The CDC object is just a wrapper around a DC handle and it provides minimal support for reading/writing to a DC handle, as it should.
INTP
"The more help VB provides VB programmers, the more miserable your life as a C++ programmer becomes."
Andrew W. Troelsen
|
|
|
|
|
Hi all,
Has any ever encountered this kind of problem when usin VC6:
On the surface of the main dialog, tthere are 129 controls (CStatic's, CEdit's, CButton's).
No other resource can be added on the dialog surface (neither by resource selecting and insertion, nor by copy-paste merthod) ?
Thanks
SkyWalker
|
|
|
|
|
the number of controls that can be added in design mode is limited to 255 due to the resource identifiers.
if you want more, you will have to add your controls dynamically/programmatically.
TOXCCT >>> GEII power [toxcct][VisualCalc]
|
|
|
|
|
I can understand that, but why is it working if I manually add them in the .rc file (using Notepad for that) ?
( I did not have 255 identifiers yet )
SkyWalker
|
|
|
|
|
Mircea Puiu wrote:
using Notepad for that
why doun't you just use the resource editor ??????
check however to resource.h file to verify that the coutrols have consecutive IDs.
TOXCCT >>> GEII power [toxcct][VisualCalc]
|
|
|
|
|
Because the resource editor was not working any longer for some reason.
The IDs were consecutive.
SkyWalker
|
|
|
|
|
|
|
Apparently no one else has tried that before, including the designiners of the resource editor. The limits sound like they are right (I forget what they are). I am suprised (if there is a bug) that you can add 129 controls, because the problem should have showed up at 128 controls.
NEVER MIND THAT!
It is working when you manually add them in the .rc because the RC compiler is doing what it was designed to do. The RC editor (on the other hand) is apparently introducing false limitations.
In any case that is a ridiculous number of controls.
INTP
Every thing is relative...
|
|
|
|
|
http://www.codeproject.com/useritems/WOL.asp
Hello, I just read an article and test on my machines. My two machines was connected through a giga byte LAN wire.
I realize that, if my target machine is shut down through win xp, the target machine can be WOL no problem.
However, if my target machine is shut down by pressing the on/off button, the target machine cannot be WOL
In both cases, the LAN LED still light up.
Seems weird, may I know what is the difference between turn off via on/off button and via winxp shut down? Why WOL problem occur does occur?
Thank you.
|
|
|
|
|
yccheok wrote:
http://www.codeproject.com/useritems/WOL.asp
Why don't you post your question in the Forum present at the bottom of article...
"Opinions are neither right nor wrong. I cannot change your opinion. I can, however, change what influences your opinion." - David Crow
cheers,
Alok Gupta
VC Forum Q&A :- I/ IV
|
|
|
|
|
It depends on the individual hardware, some systems may not maintain all of the standby voltages when switched off by the on/off button.
Elaine
The tigress is here
|
|
|
|
|
I have a winsocket server listening on a given port, say 2000. Is there a way how to find out what service (eg. telnet) is used by a particular client when it connects to the server? I tried getpeername() on a connected socket to get sockaddr_in structure filled and then I called getservbyport() with sin_port parameter from sockaddr_in, but with no success. I've got WSANO_DATA (Valid name, no data record of requested type) error.
I'd really appreciate any insight recommendation
Zdenek
|
|
|
|
|
Here[^] you can find a tool (and source code) which retrieves information about each connection
|
|
|
|
|
Nope. I've downloaded both the source of netstatp and TcpView utility from a recommended site. There's no information there how to find out a service the client is using. Even a TcpView only guesses the service from a well known port number.
Regards,
Zdenek
|
|
|
|
|
You cannot guess!
The only way would be to create a filter to listen to the connection and to check the service that way. But normally it is not possible!
Don't try it, just do it!
|
|
|
|