Re: rs232!
Boy oh boy, I never thought this would be so hard!
I feel like I need your support everyt step of the way!
Shame on me!
Frank:
I have to include "CSerialWnd" right? and so I did!
Now I have to create a serial object right? and so I did! and it gives me
the following errors:
XPPLC error LNK2019: unresolved external symbol "public: virtual __thiscall
CSerialWnd::~CSerialWnd(void)" (??1CSerialWnd@@UAE@XZ) referenced in function
"long __stdcall WndProc_CW1(struct HWND__ *,unsigned int,unsigned int,long)"
(?WndProc_CW1@@YGJPAUHWND__@@IIJ@Z)
XPPLC error LNK2019: unresolved external symbol "public: __thiscall
CSerialWnd::CSerialWnd(void)" (??0CSerialWnd@@QAE@XZ) referenced in function
"long __stdcall WndProc_CW1(struct HWND__ *,unsigned int,unsigned int,long)"
(?WndProc_CW1@@YGJPAUHWND__@@IIJ@Z)
XPPLC fatal error LNK1120: 2 unresolved externals
Its like as if I am missing some kind of declaration in the serial
files....???
Here is my code:
===============================================
#include <windows.h>
#include <tchar.h>
#include "SerialWnd.h"
LRESULT CALLBACK WndProc_CW1 (HWND hwnd, UINT message,
WPARAM wParam, LPARAM lParam)
{
CSerialWnd MySerial;
//long MySetrial.open(
// TEXT("COM1"),
// hwnd, WM_NULL,
// lParam,0,0
// );
.....other code ...
}
===================================================
Sorry for all the failures I am involving you in, I appreciated... Thank god
I caught you on a good day :-)
P.S. I can't wait to read a byte through this computer port I tell ya!
--
Best regards
Robert
"Frank Hickman [MVP]" wrote:
Answers inline...
"Robby" <Robby@discussions.microsoft.com> wrote in message
news:34CE94A0-7FE8-4E81-888F-9ED582AD8B97@microsoft.com...
Hello Frank!
I downloaded the serial sample as you told me to. I took a long and hard
look at the source code... I don't really understand how everything
works....
However I copied all the files under the "serial" folder in my project
folder. I don't think I need all of them.... Do I?
No you should only need the Serial.cpp/Serial.h, SerialEx.cpp/SerialEx.h,
SerialWnd.cpp/SerialWnd.h files from the Serial subfolder.
Anyhow at the top of my cpp file I included the "CSerialWnd.h" header file
but this gave me the same error, so I changed it to "SerialWnd.h" which is
one of the header files that I copied into my project folder, and it
compiled
without errors!
So why is it that in the web documentation they say to include
"CSerialWnd.h" as opposed to "SerialWnd.h"?
Probably just a typo.
Okay, so this is step #1, I will now try to add the following code in my
winproc and see what gives!
===================================================
LONG Open (
LPCTSTR lpszDevice,
HWND hwndDest,
UINT nComMsg = WM_NULL,
LPARAM lParam = 0,
DWORD dwInQueue = 0,
DWORD dwOutQueue = 0
)
[and]
LRESULT CALLBACK MyWndProc (HWND hwnd, UINT nMsg, WPARAM wParam, LPARAM
lParam)
{
if (nMsg == CSerialWnd::mg_nDefaultComMsg)
{
// A serial message occurred
const CSerialWnd::EEvent eEvent =
CSerialWnd::EEvent(LOWORD(wParam));
const CSerialWnd::EError eError =
CSerialWnd::EError(HIWORD(wParam));
switch (eEvent)
{
case CSerialWnd::EEventRecv:
// TODO: Read data from the port
break;
...
}
// Return successful
return 0;
}
You probably already have a window proceedure already defined. Just use the
code within the proceedure, not the whole proceedure itself.
==================================================
Just one thing though, where can I find the explanations to the function
parameters of:
LONG Open (
LPCTSTR lpszDevice,
HWND hwndDest,
UINT nComMsg = WM_NULL,
LPARAM lParam = 0,
DWORD dwInQueue = 0,
DWORD dwOutQueue = 0
)
I have looked in help and I find different variations.... I know the web
documentation explains it but here is what I don't get from their
explanation:
================================================
"The lpszDevice, dwInQueue and dwOutQueue are used as in CSerial."
***I don't get it, where is it used in CSerial, all I saw was a simple:
long open(_T("COM1")) call?
This is for the standard CSerial use, not the windows message based one.
And what is the "LPCTSTR lpszDevice"? , I know this is a long pointer to a
constant string, but where does it come from,.... is it a HDC?
====================================================
No. This is the communications port you want to talk to. It can be
something from the user, registry or where ever you deside it should come
from. It just happens to be hard coded in the samples.
"The hwndDest argument specifies the window, where the message should be
sent to."
Okay so this is the window handle!
====================================================
Yep.
"The library registers a default message during startup, which can be used
in most cases. Simply pass WM_NULL to use this message. The value of this
message is stored in the CSerialWnd::mg_nDefaultComMsg variable, which is
a
static member variable of CSerialWnd. If you prefer one of your own
messages,
then you can use that instead. "
Okay I can stay with their default message for now!
===================================================
"The optional lParam argument is sent as the second parameter (lParam) in
each message that is being sent by CSerial. The serial library doesn't do
anything with this value, so be free to use it as you like. "
So I just need to pass lParam.... Okay that's fine!
===================================================
Im just worried to try all of this, that's all!
Anyways, Frank, Thankyou very much, you have been very resourcefull and it
is much appreciated.
Your welcome.
*you don't go away now... you hear!*
I have sperts, you caught me on a good day :)
You have brought me through a long way, but I ain't out of the woods yet!
I hope to hear from you on my next probable imminent snag! :-)
If you have any suggestions on my questions above, please get back!
Thanks
--
Kind regards
Robert
--
============
Frank Hickman
Microsoft MVP
NobleSoft, Inc.
============
Replace the _nosp@m_ with @ to reply.