|
Btw, Joe. In your first post, you said "Unfortunately, all my attempts at doing this have failed."
If you could give some examples of how it failed, others might be able to give you suggestions on fixing them.
|
|
|
|
|
hi
i have to connect com2 to send,recive commands from a machine i have.
i success to send commands but not to listen to commands.
it run under linux(with c++).
the Parameters should be:
port :RS232
baud rate : 19200
data bits 8
parity none
stop bits 1
flow control none
the way i did it is :
fd = open("/dev/ttyS1", O_RDWR | O_NOCTTY | O_NONBLOCK);
if (fd == -1) //Could not open the port.
return false;
fcntl(fd, F_SETFL, FASYNC);
struct termios options;
//Get the current options for the port...
tcgetattr(fd, &options);
//Set the baud rates to 19200...
cfsetispeed(&options, B19200);
cfsetospeed(&options, B19200);
//Enable the receiver and set local mode...
options.c_cflag |= (CLOCAL | CREAD);
//Set the new options for the port...
options.c_cflag &= ~CSIZE; /* Mask the character size bits */
options.c_cflag |= CS8; /* Select 8 data bits */
options.c_cflag &= ~PARENB;
options.c_cflag &= ~CSTOPB;
options.c_cflag &= ~CRTSCTS;
options.c_lflag |= (ICANON | ECHO | ECHOE);
options.c_iflag &= ~(IXON | IXOFF | IXANY);
tcsetattr(fd, TCSANOW, &options);
and to write something like
write(fd, "abcdefg\r", 8);
and it works
but to read i tried and cant do it
what the problem?
may be i gave wrong flags to the parameters i need ?
how should i read data.
thanks.
|
|
|
|
|
This is the C++/CLI forum. You could try the Visual C++ forum, though since your question may be Linux-specific, even that might not be appropriate. In any case, this is not the right forum.
|
|
|
|
|
Hi,
I am using a vector of BSTR in one of the function
Fn()
{
vector <bstr> vbstrTest;
...
vbstrTest.push_back(bstrSomeBSTR)
}
Does the vector automatically cleans the BSTR string inside it? What is the best way to cleanup the vector, if it holds the custom\user defined types.
Thanks in advance,
Yash
|
|
|
|
|
Yash Purohit wrote: Does the vector automatically cleans the BSTR string inside it?
No. It won't.
Yash Purohit wrote: What is the best way to cleanup the vector, if it holds the custom\user defined types.
Use a CComBSTR instead of a BSTR? CComBSTR does its own cleanup in the destructor.
|
|
|
|
|
Hi, I am trying to perform a BitBlt operation, but I'm getting linking errors. Any help would be greatly appreciated.
I'm currently using Visual C++ 2005 Express, and I have a Windows Forms application. The Express version does not have MFC support. I've also installed the Platform SDK and followed the post-installation instructions as indicated on the page: http://msdn.microsoft.com/vstudio/express/visualc/usingpsdk/
I am trying to BitBlt an image from a device context (located within an unmanaged library) to the device context of a PictureBox control on the Form. Making calls to GetDC() and BitBlt() result in linking errors (the unresolved token/symbol types):
~~~~~~~~~~~~~
Linking...
MainWinMapView.obj : error LNK2028: unresolved token (0A0001E4) "extern "C" int __stdcall BitBlt(struct HDC__ *,int,int,int,int,struct HDC__ *,int,int,unsigned long)" (?BitBlt@@$$J236YGHPAUHDC__@@HHHH0HHK@Z) referenced in function "private: void __clrcall MainWinMapView::UpdateRefresh(void)" (?UpdateRefresh@MainWinMapView@@$$FA$AAMXXZ)
MainWinMapView.obj : error LNK2028: unresolved token (0A0001E5) "extern "C" struct HDC__ * __stdcall GetDC(struct HWND__ *)" (?GetDC@@$$J14YGPAUHDC__@@PAUHWND__@@@Z) referenced in function "private: void __clrcall MainWinMapView::UpdateRefresh(void)" (?UpdateRefresh@MainWinMapView@@$$FA$AAMXXZ)
MainWinMapView.obj : error LNK2019: unresolved external symbol "extern "C" int __stdcall BitBlt(struct HDC__ *,int,int,int,int,struct HDC__ *,int,int,unsigned long)" (?BitBlt@@$$J236YGHPAUHDC__@@HHHH0HHK@Z) referenced in function "private: void __clrcall MainWinMapView::UpdateRefresh(void)" (?UpdateRefresh@MainWinMapView@@$$FA$AAMXXZ)
MainWinMapView.obj : error LNK2019: unresolved external symbol "extern "C" struct HDC__ * __stdcall GetDC(struct HWND__ *)" (?GetDC@@$$J14YGPAUHDC__@@PAUHWND__@@@Z) referenced in function "private: void __clrcall MainWinMapView::UpdateRefresh(void)" (?UpdateRefresh@MainWinMapView@@$$FA$AAMXXZ)
D:\snapshot\dev_leeh_snapmmf_i4_RouteComparisonTool\snapmmf\utilityapps\RouteDiffer\Debug\RouteDiffer.exe : fatal error LNK1120: 4 unresolved externals
~~~~~~~~~~~~~
I've copied my code snippet below. The canvasSize and m_pOsCanvas variables have types which are part of my unmanaged library, but I don't that matters in the scope of this problem. m_MapPictureBox is a System::Windows::Forms::PictureBox control.
~~~~~~~~~~~~~
// Get the handle to the MapPictureBox
HWND hScreenWnd = (HWND) m_MapCtrlCollection->m_MapPictureBox->Handle.ToPointer();
// Get the device context of the screen
HDC hScreenDC = GetDC(hScreenWnd);
// BitBlt the image to the device context
BitBlt(hScreenDC, 0, 0, canvasSize.getWidth(), canvasSize.getHeight(), m_pOsCanvas->getDeviceContext(), 0, 0, SRCCOPY);
~~~~~~~~~~~~~
I'm guessing the problem is some sort of setting that I am unaware of. I am assuming that I can make GDI calls in the Express edition.
If you what's going on, please provide help.
Thanx,
Lee H.
-- modified at 17:38 Friday 16th December, 2005
|
|
|
|
|
You need to input the required lib files to the linker - such as Gdi32.lib, user32.lib etc.
|
|
|
|
|
Thanx, that helped solved the problem.
The "Inherit from parent or project defaults" option was unchecked; once I checked that, it worked.
Thanx,
Lee H.
|
|
|
|
|
Is there available NET dll's for capturing video from usb device to some memory location, which is not to much complicated to use?
9ine
|
|
|
|
|
I made an application in opengl with glui libraries and i call it from a VB.NET form,well my problem is how can i redisplay my shape in opengl window without creating a new window and change his values at a run time mode!!!is there any statement in opengl i can do that with?I think that i must reset my buffers and reaload it!Any ideas?
Thanks....
giotis
|
|
|
|
|
Hi
Can anyone tell me the mathimatical explanation of converting a floating point to a hexadecimal?
Thanks..
|
|
|
|
|
It depends on the range of the number you want to represent. I put some basic macros at the end of this message, but the concept that you need to understand is the range of the floating point number and the number of bits in your integer representation (HEX or DECIMAL is really not relevant, they are just ways of viewing the integer). So for example if you are trying to represent PI as a integer number using a 16 bit word, you need at two integer bits for the 3 and the rest could be fractional bits. Assuming an signed 16-bit word, gives you 1 sign bit, 2 integer bits and 13 fractional bits. So multiply PI * 2^13 = 25735.9270. Since this is an integer, your loss of precision is the .9270.... So you are left with 25735 (0x6487).
My original PI was 3.1415926535897932384626433832795
If I convert my integer PI back to a floating point number (by dividing by 2^13) we get 3.1414794921875.
The important thing to remember when using these converted numbers is to keep track of the decimal location in all of your mathematical operations using that number.
If you send me an email address I can send you a couple articles that describe fixed point math operations can concepts.
typedef long fixed; // Our new fixed point type.
#define itofx(x) ((x) << 8) // Integer to fixed point
#define ftofx(x) ((x) * 256) // Float to fixed point
#define dtofx(x) ((x) * 256) // Double to fixed point
#define fxtoi(x) ((x) >> 8) // Fixed point to integer
#define fxtof(x) ((float) (x) / 256) // Fixed point to float
#define fxtod(x) ((double)(x) / 256) // Fixed point to double
#define Mulfx(x,y) (((y) * (x)) >> 8) // Multiply a fixed by a fixed
#define Divfx(x,y) ((y << 8) / (x)) // Divide a fixed by a fixed
#define Printfx(x) printf("%ld.%ld", x >> 8, 100 * (unsigned long) ((x) & 0x00ff) >> 8)
// Print fixed point.
#define NDPrintfx(x) printf("%ld", x >> 8)
// Print fixed point without a decimal point.
|
|
|
|
|
if you can get the binary array of the float, you can easily get its hexadecimal representation...
group the bits by groups of 4 bits. then use the following :
binary <--> hexa
------------------------
0000 0x0
0001 0x1
...
1010 0xA
...
1111 0xF
then, you have it.
see this example :
0b 0010 0101 1101 0110
0x 2 5 D 6
so, the hexadecimal representation of the bits shown is 0x25d6 ...
understand ?
[edit]
ok, i'm quite sure it won't be that ease for you to get the bit array, so here is a sample for that :
<font color=blue>float</font> floatToAnalyse = 3.45; <font color=green>
<font color=blue>char</font> floatBits[32] = <font color=gray>""</font>;
<font color=green>
<font color=blue>unsigned int</font> uiBitsArray = *((<font color=blue>char</font>*)(<font color=blue>void</font>*)floatToAnalyse);
<font color=blue>for</font> (<font color=blue>int</font> i = 0; i < 32; i++) {
floatBits[0] = (((uiBitsArray >> (31-i)) & 0x00000001) == 1)
? <font color=gray>'1'</font>
: <font color=gray>'0'</font>;
} [/edit]
TOXCCT >>> GEII power [toxcct][VisualCalc 2.20][VisualCalc 3.0]
-- modified at 8:54 Friday 16th December, 2005
|
|
|
|
|
Dear Members,
I need to color a button using ATL, WTL or WIN 32 API..
I can easily do it using MFC but because of the Application requirement
I have to do it by using the above mentioned technologies only.
Kindly help me out by sending tips and useful codes.
Regards,
Mayank Srivastava
|
|
|
|
|
you are on the managed C++ forum, which .NET related. what you need (ATL, WTL, MFC, Win32) is all except MC++.
try the ATL/WTL/STL forum[^]...
ps: asking your question once is sufficient...
TOXCCT >>> GEII power [toxcct][VisualCalc 2.20][VisualCalc 3.0]
-- modified at 9:41 Wednesday 14th December, 2005
|
|
|
|
|
thanks a lots,
My meaning is web service client how to access web service endpoint?
|
|
|
|
|
If I have a dll created by Managed C++ and receiving array. How do I pass the array from application in C# to the generated DLL?
Any help is appreciated.
|
|
|
|
|
C++/CLI
public: void MyClass::myDllFunction(cli::array<String^>^ stringList)
{
...
}
C#
using MyClass;
string[] list = new string[]{"one", "two", "three"};
myClassInstance.myDllFunction(list);
-- modified at 16:05 Tuesday 13th December, 2005
|
|
|
|
|
Thanks a lot. So it is pretty natural on both sides.
|
|
|
|
|
Hi All,
This might be a really silly question but,...
I have a class A defined as:
<br />
class A<br />
{<br />
protected:<br />
float data[4][4];<br />
};<br />
And I need to get the data out so I created a function:
float **GetData (void) { return (float **) data }
However this causes an 3f800000 exception in VS 2005 Express when I try to use the float returned. Do I need to physically copy the data into a tempory buffer?
regards,
Rich
"Programming today is a race between software engineers striving to build bigger and
better idiot-proof programs, and the Universe trying to produce bigger and better idiots.
So far the Universe is winning." -- Rich Cook
|
|
|
|
|
is the array well initialized (in the constructor tor instance)
before using it, test if it is different from NULL .
and at last, if your class exist only for such things, prefer using a struct instead...
TOXCCT >>> GEII power [toxcct][VisualCalc 2.20] | soon : [VisualCalc 3.0]
|
|
|
|
|
Hi,
The array is initialised to have all elements 0. It is not pointer, so it is not dynamically allocated, and it is not a NULL pointer exception. Also I need to overload the arithmetic operators so the best is to use a class. There are also other data members not meantioned here.
BTW, I tried this in normal code (i.e. in the main function) calling another function that took a float ** and it did the same thing.
regards,
Rich
"Programming today is a race between software engineers striving to build bigger and
better idiot-proof programs, and the Universe trying to produce bigger and better idiots.
So far the Universe is winning." -- Rich Cook
|
|
|
|
|
toxcct wrote: and at last, if your class exist only for such things, prefer using a struct instead...
Just curious - why ?
Christian Graus - Microsoft MVP - C++
|
|
|
|
|
The problem is probably elsewhere because it looks correct. Did you try to use the debugger and see where EXACTLY the code crashes ? (Press F5 to start the debugger and F9 to set or remove breakpoints).
|
|
|
|
|
Cedric, how can you be so sure that his code is correct ?
nowhere he says that he initialized the array, so if he doesn't test for a NULL pointer, i may use a wrong array !!!
moreover :
float **GetData (void) { return (float **) data }
is missing a ; after the return statement...
TOXCCT >>> GEII power [toxcct][VisualCalc 2.20] | soon : [VisualCalc 3.0]
|
|
|
|
|