|
Hello,
i like to read in a data string from my serial port. The string has the format like:
[123.233, -4.344, 45.678].
I want to readout this string and transfer the three values into float x,y,z variables for further processing.
The code below is a part of my old code which works with only a "1" character input. What i have to change?
char cReceivedChar[1];
cReceivedChar[0] = '\0';
DWORD dwBytesRead;
if (port.Read(cReceivedChar, 1 , overlapped, &dwBytesRead)) // 1 is number of bytes read from port, how to make this variable?
{
CString nx = cReceivedChar[1];
SetDlgItemText(IDC_SHIFT_X,("%c", nx));
}
Thanks, Mark
|
|
|
|
|
why not simply
CString nx ;
while (port.Read(cReceivedChar, 1 , overlapped, &dwBytesRead)) // 1 is number of bytes read from port, how to make this variable?
{
nx += cReceivedChar[1];
}
AfxMessageBox(nx);
Papa
while (TRUE)
Papa.WillLove ( Bebe ) ;
|
|
|
|
|
Hmm, the output now is like: |||||||||
and how can i extract the three values?
Thanks, Mark
|
|
|
|
|
Check the string tokenizer classes on CP
The main idea, let the comma be your separator and take the values between and convert them to float or double using atof
Remeber to clean the string on each new triplet received, i mean each time you receive (x, y, z) clean your string, of course after doing the processing
Papa
while (TRUE)
Papa.WillLove ( Bebe ) ;
|
|
|
|
|
Hi,
I am new to programing . I often come across the word "Wrapper class" in some books. What is it?.
What is a type library? When I open a *.tlb, I see a whole chunk of hexadecimal display.
Thanks.
Deepak Samuel
|
|
|
|
|
wraper class as a short example.
win32 programming
HWND hWnd;
hWnd = createwindow(...);
ShowWindow(hWnd,...);
Wrapper to window (HWND)
class Window
{
HWND hWnd;
int CreateWindow(...)
{
hWnd = CreateWindow(....);
}
int ShowWindow(...)
{
ShowWindow(hWnd,...);
}
}
As you see i wrapped HWND with a class, hence its a wrapper class.
|
|
|
|
|
As for tlb files you can view them with the Visual C++ tool OLE/COM object viewer
Papa
while (TRUE)
Papa.WillLove ( Bebe ) ;
|
|
|
|
|
Deepak Samuel wrote:
What is a type library? When I open a *.tlb, I see a whole chunk of hexadecimal display.
A .tlb is used to describe the methods and properties of a COM object.
You can use #import to create a C++ wrapper class for the type library or you can view the details of the type library using the OLEView too that comes with Visual Studio.
Michael
But you know when the truth is told,
That you can get what you want or you can just get old,
Your're going to kick off before you even get halfway through.
When will you realise... Vienna waits for you? - "The Stranger," Billy Joel
|
|
|
|
|
I use this :
CFile FileName(m_csTemp,CFile::modeCreate | CFile::modeWrite);
to create a file. This expression erase all of the existing files which have the same name. Is there a function which allow to see if a file with the same name already exists ?
Thank's for advance.
|
|
|
|
|
|
Try to open it for read, if it fails means it doesnt exist
Papa
while (TRUE)
Papa.WillLove ( Bebe ) ;
|
|
|
|
|
use
BOOL PathFileExists(LPCTSTR pszPath);
or to open without deleting
if(!file.Open(strFileName,CFile::modeReadWrite|CFile::modeCreate|CFile::modeNoTruncate,&exF))
return 0;
suhredayan@omniquad.com
messenger :suhredayan@hotmail.com
|
|
|
|
|
Anonymous wrote:
Is there a function which allow to see if a file with the same name already exists ?
_access() is but one method of doing that.
"The pointy end goes in the other man." - Antonio Banderas (Zorro, 1998)
|
|
|
|
|
Hi guys
I have a class called CListCtrlEx and inside I want to have a pointer to a CMyDialog
Inside CMyDialog I have a CListCtrlEx member.
I tried many solutions but always receive an error message due to the cross refreneces of ine class to the other. What is the right procedure (#includes in .h or .cpp) to have a pointer of CMyDialog in CListCtrlEx.h and a CListCtrlEx member in CMydialog.h
I'm going crazy with this silly mistake.
Simplifying
In CListCtrlEx.h : CMyDialog *m_pMyDialog;
In CMyDialog.h : CListCtrlEx m_lstMyList;
Thanks
Doc
|
|
|
|
|
you can put either #include s into .cpp or .h (depends on how you create your headers also/ what are needed in your headers).
ben careful you have exclusive preprocessor directives in your header to avoid that sort of recursive definitions :
CMydialog.h
<font style="color:blue;">#if</font> !<font style="color:blue;">defined</font>(__CMYDIALOG_H_INCLUDED__)
<font style="color:blue;">#define</font> __CMYDIALOG_H_INCLUDED__
<font style="color:green;">
<font style="color:blue;">#endif</font> <font style="color:green;">//__CMYDIALOG_H_INCLUDED__</font>
TOXCCT >>> GEII power
|
|
|
|
|
I've got the following
In ListCtrlEx.h
class CMyDialog;
CMyDialog *m_pMyDialog;
In ListCtrlEx.cpp
#include "MyDialog.h"
----------
In CMyDialog.h
#include "ListCtrlEx.h"
CListCtrlEx m_lstMyList;
I always receive this error
error C2065: 'IDD_CE_GENERAL' : undeclared identifier
C:\Whatever...\MyDialog.h(25) : error C2057: expected constant expression
Do you see the problem? I can't ((
Thanks again
Doc
|
|
|
|
|
perhaps you also need an extern keyword, to tell the compiler that you use a variable in a file, but that variable is defined in another file.
what is IDD_CE_GENERAL ??
TOXCCT >>> GEII power
|
|
|
|
|
Is the general dialog IDD.
// Dialog Data
//{{AFX_DATA(CStatsGenCE)
enum { IDD = IDD_ESTAD_CE_GENERAL };
//}}AFX_DATA
|
|
|
|
|
haven't you modified some lines dangerously ?
IDD_ESTAD_CE_GENERAL != IDD_CE_GENERAL
TOXCCT >>> GEII power
|
|
|
|
|
Not at all, sorry my fault, It has only modified in the posts.
IDD_ESTAD_CE_GENERAL is the good one.
All is coherent in the code.
I'm lost (((
Thanks
Doc
|
|
|
|
|
sorry, i'm lost too...
maybe with more explanation, but nop, can't help you man
TOXCCT >>> GEII power
|
|
|
|
|
I've found it!!!
The problem is that IDD_ESTAD_CE_GENERAL value cannot be accesed by my class (I don't know why)
Maybe is not a good solution but I've substituted IDD_ESTAD_CE_GENERAL for his value and all is working correctly.
This value is always the same,isn't it?
Thanks pal for your time.
Doc
|
|
|
|
|
as you say, not a very good solution !
try to find out why this was nos accessible....
TOXCCT >>> GEII power
|
|
|
|
|
doctorpi wrote:
error C2065: 'IDD_CE_GENERAL' : undeclared identifier
C:\Whatever...\MyDialog.h(25) : error C2057: expected constant expression
IDD_CE_GENERAL will be defined in your resource.h file. Make sure that you #include "resource.h" in your include tree. You can place it in your MyDialog.h header.
Michael
But you know when the truth is told,
That you can get what you want or you can just get old,
Your're going to kick off before you even get halfway through.
When will you realise... Vienna waits for you? - "The Stranger," Billy Joel
|
|
|
|
|
Thanks Michael
Just tried and... working
|
|
|
|