Re: rs232 - [A]
Hello Frank!
It compiles without any errors!
I am sorry, its been approximately 1 month and a half that I have been
working to set up a Microcontroller and I forgot that we shouldn't include
other cpp files in a cpp file!
Although in PIC mocrocontrollers which are programmed in C, this type of
inclusion is quite common... so its all about getting used to what should be
done and where!
So, it compiles, I am very excited to see how I can actually read a byte
form this port, I would like to know if the next few lines of code will be a
step in the right direction! I am just following the sample!
==============================================
LRESULT CALLBACK WndProc_CW1 (HWND hwnd, UINT mMsg,
WPARAM wParam, LPARAM lParam)
{
CSerialWnd MySerial;
MySerial.Open(TEXT("COM1"),hwnd,WM_NULL,lParam,0,0);
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;
}
===================================================
and if I have to change the default comm parameters, I would use the
following right!
=================================================
Setup(CSerial::EBaud9600,CSerial::EData8,CSerial::EParNone,CSerial::EStop1);
Setup(CSerial::EBaudrate(9600),
CSerial::EDataBits(8),
CSerial::EParity(NOPARITY),
CSerial::EStopBits(ONESTOPBIT));
=================================================
As for the actual reading data from the port, I guess I would have to use:
MySerial.Read()
However where can I get help for the parameters descriptions for this and
every othe available methods of MySerial?
Ex: like, What would the last parameter of Read mean:
dwTimeout = INFINITE
I would need some sort of reference manual thsat would breifly explain stuff
like that!
Also one more thing Frank! off the subject....
The following animal:
const CSerialWnd::EEvent eEvent = CSerialWnd::EEvent(LOWORD(wParam));
Shouldn't there be an EEvent method in the SerialWnd class in one of the
Serial.x files?
Unless I am blind!!!!! I didn't see one? :-)
I know some C++, like classes and inheritance, but at the basic level, so I
never saw a line like this.... I guess I would have to get a more effective
book in C++!!!!
Anyhow, I will be back tommorrow and let you know if this -rs232- works.
I will post a message with the following title: "rs232"-[B]" and I will let
you know if there are any other complications!
Thankyou again Frank! Much appreciated!
--
King regards
Roberto
"Frank Hickman [MVP]" wrote:
"Robby" <Robby@discussions.microsoft.com> wrote in message
news:3AA47AB9-4603-49F8-B9C2-0E402D17A359@microsoft.com...
Hello,
As per reference to my prvious post "rs232", (I have continued it here for
a
fresh start on my prblem) Thanks!
I have added 6 serial cpp files and their headers to my project. Please
see
errors at bottom of this post!
Please consider the following code:
==================================================
#include <windows.h>
#include "WndProc_CW1.h"
//#define STRICT
#include <tchar.h>
#include "Serial.h"
#include "Serial.cpp"
#include "SerialEx.h"
#include "SerialEx.cpp"
#include "SerialWnd.h"
#include "SerialWnd.cpp"
<snip>
--
Best regards
Robert
Take these lines out...
#include "Serial.cpp"
#include "SerialEx.cpp"
#include "SerialWnd.cpp"
These files should be added to the project workspace, not inclueded within
the source...
--
============
Frank Hickman
Microsoft MVP
NobleSoft, Inc.
============
Replace the _nosp@m_ with @ to reply.