|
pra84veen wrote: iResult = ReadFile(m_comPortHandle,
x_pcBuffer[0],
x_usLengthExpected,
ulLengthReceived,
NULL );
That's completely wrong (compiler doesn't complain, does it?). Should be:
ReadFile(m_comPortHandle,
x_pcBuffer,
x_usLengthExpected,
&ulLengthReceived,
NULL );
Please note the ampersand in front of ulLengthReceived .
BTW: How did you set serial port timeouts?
If the Lord God Almighty had consulted me before embarking upon the Creation, I would have recommended something simpler.
-- Alfonso the Wise, 13th Century King of Castile.
This is going on my arrogant assumptions. You may have a superb reason why I'm completely wrong.
-- Iain Clarke
|
|
|
|
|
Even after modification also, iam not able to collect the data
The serial port timeouts are
GetCommTimeouts(m_comPortHandle, &sCommTimeOuts);
sCommTimeOuts.ReadIntervalTimeout = 5;
sCommTimeOuts.ReadTotalTimeoutMultiplier = 1;
sCommTimeOuts.ReadTotalTimeoutConstant = 1;
sCommTimeOuts.WriteTotalTimeoutMultiplier = 1;
sCommTimeOuts.WriteTotalTimeoutConstant = 1;
SetCommTimeouts(m_comPortHandle, &sCommTimeOuts);
Thanks & Regards,
Praveen
|
|
|
|
|
Why don't you widen them (you can also set them for a blocking call, just to make a test)?
If the Lord God Almighty had consulted me before embarking upon the Creation, I would have recommended something simpler.
-- Alfonso the Wise, 13th Century King of Castile.
This is going on my arrogant assumptions. You may have a superb reason why I'm completely wrong.
-- Iain Clarke
|
|
|
|
|
|
even if i change the values of commtimeouts to
GetCommTimeouts(m_comPortHandle, &sCommTimeOuts);
sCommTimeOuts.ReadIntervalTimeout = 100;
sCommTimeOuts.ReadTotalTimeoutMultiplier = 10;
sCommTimeOuts.ReadTotalTimeoutConstant = 500;
sCommTimeOuts.WriteTotalTimeoutMultiplier = 10;
sCommTimeOuts.WriteTotalTimeoutConstant = 100;
SetCommTimeouts(m_comPortHandle, &sCommTimeOuts);
i dint observe any change.
|
|
|
|
|
how can i multiply two numbers without using * operator, rather by doing bits manopulation??? plz help me out!
|
|
|
|
|
multiply/divide by how many ?
there's a hack if you multiply/divide integers by 2.
shifting the bits to one position left will multiply by 2.
shifting the bits to one position right will divide by 2.
however, if you're handling floats, this is a useless pain buddy.
modified on Monday, June 9, 2008 7:31 AM
|
|
|
|
|
Google "Bit shifting" and how base-2 number systems (uh, dat be called binary ) sometime...
Peace!
-=- James Please rate this message - let me know if I helped or not!<hr></hr> If you think it costs a lot to do it right, just wait until you find out how much it costs to do it wrong! Remember that Professional Driver on Closed Course does not mean your Dumb Ass on a Public Road! See DeleteFXPFiles
|
|
|
|
|
If you are trying to multiply integers you can use addition in a loop, but without knowing more about what you want to acheive I do not think anyone here can really help.
Try to explaion why you need to do this and what you are trying to acheive.
Good Luck,
Ali
|
|
|
|
|
Hint: operators + and <<
If the Lord God Almighty had consulted me before embarking upon the Creation, I would have recommended something simpler.
-- Alfonso the Wise, 13th Century King of Castile.
This is going on my arrogant assumptions. You may have a superb reason why I'm completely wrong.
-- Iain Clarke
|
|
|
|
|
I thought building ALUs in circuits class was really fun
|
|
|
|
|
do we get a share of your grade ?
|
|
|
|
|
Try something like this, it's just the same as you do it on paper:
#include "stdafx.h"
#include <iostream>
using namespace std;
unsigned int Multiply(unsigned int l, unsigned int r)
{
unsigned res = 0;
while (l!=0 && r!=0)
{
if (r&1)
{
res += l;
}
l <<= 1;
r >>= 1;
}
return res;
}
int main()
{
cout << "1234 * 2:" << endl;
cout << "\t* = " << 1234*2 << endl;
cout << "\tMultiply = " << Multiply(1234, 2) << endl << endl;
cout << "314159 * 33:" << endl;
cout << "\t* = " << 314159*33 << endl;
cout << "\tMultiply = " << Multiply(314159, 33) << endl << endl;
return 0;
}
Steve
|
|
|
|
|
i have added the following code to create status bar in a dialog.
But its not getting created.
what could be the problem
....
m_StatusBar.Create(this);
m_StatusBar.SetIndicators(indicators, sizeof(indicators)/ sizeof(UINT));
....
|
|
|
|
|
Check this article[^].
BTW, I searched for "dialog status bar" on the codeproject search and that was the first result
|
|
|
|
|
Yes. its good sample.
Meanwhile i am getting the following error.
error C2664: 'void ATL::CStringT<BaseType,StringTraits>::Format(const wchar_t *,...)' : cannot convert parameter 1 from 'const char [10]' to 'const wchar_t *'
How to resove this.
|
|
|
|
|
It is because UNICODE is defined for your project. I suggest this excellent article[^] if you want to understand what is happening. If you don't care, just disable UNICODE in your project settings (but you'll miss a chance to learn something usefull).
|
|
|
|
|
Thanks.i gone thru the article.
Look below decl. of unicode.
wchar_t wch = L'1'; // 2 bytes, 0x0031
wchar_t* wsz = L"Hello"; // 12 bytes, 6 wide characters
First stmt one char -> 2Byte.
Second stme five char -> 12 byte. How?
|
|
|
|
|
RSAK wrote: .i gone thru the article.
It seems that you didn't really understand the article . wchar is a wide character, which means each character is coded on two bytes. So, the string "Hello" (with the terminating character) is 6 wide characters so 12 bytes.
BTW, don't use wide characters directly but use TCHAR instead. In this way, your code will support both unicode and non-unicode builds.
|
|
|
|
|
i actually confused with the first stmt as it has one char and another(termin char). so total would come 4 bytes.
|
|
|
|
|
No: it is not a string. It is a single wchar, so its size is 2 bytes.
|
|
|
|
|
Again and again i am struck with unicode and multibyte char convesions.
int iValue = m_iValue1;
CString str;
str.Format("%d", m_iValue);
.....
.....
m_ListBox.AddString(str);
.....
How to do that using TCHAR? like format used in CString..
|
|
|
|
|
|
|
Did you get this resolved? (I just implemented it in about 5 minutes w/ that article)
|
|
|
|