|
textBox1->Text += (Char) cRxBuff1[i];
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
[My articles]
|
|
|
|
|
Thanks a lot, it is working now.
I was sure to have tried this already.
In fact I tried the following just to test if I can display a caracter
textBox1->Text = (Char) cRxBuff1[0];
How come we can do
textBox1->Text += (Char) cRxBuff1[i];
but not
textBox1->Text = (Char) cRxBuff1[i];
??
|
|
|
|
|
Because a string is a sequence of characters.
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
[My articles]
|
|
|
|
|
which header file do I need to include to use CString?
|
|
|
|
|
|
Nah it hasn't. That is why I was wondering how this can work. I saw some examples with stuff like this. At least the compiler accept it. I tried to do some thins like this too :
textBox1->Text = ToString(RxBuffer);
But its not working either.
I am not used to manipulate strings, I do mostly C code, and I have no clue how to do this.
|
|
|
|
|
Hi !!
My application is related with Smart card readers.
I actually use CreateFile() to create a handle to the port to which the reader is connected.
I use WriteFile () to send data to reader & receive response from reader using ReadFile ().
I compare the response sent by a reader, to detect whether it is a valid Reader or not
now my problem is if i donot connect a reader to the port, and use ReadFile (), it executes successfully, although there is no reader connected to the port.
So is there a function to detect whether a reader is connected to the port or not?
|
|
|
|
|
I will suggest you to send some basic command to reader.
If reader responds reader is there. Else you can time out and say no reader is connected.
Regards,
Sandip.
|
|
|
|
|
Presently i am doing that but the reader is responding at different time delays at different times at different computers.
but if i keep the maximum delay, the performance of the application decreases !!
|
|
|
|
|
What is the timeout you are using now??
Regards,
Sandip.
|
|
|
|
|
// Set the time outs for the COM port
COMMTIMEOUTS CommTimeoutsObj;
commTimeoutsObj.ReadIntervalTimeout = 0;
commTimeoutsObj.ReadTotalTimeoutMultiplier = 10;
commTimeoutsObj.ReadTotalTimeoutConstant = 2;
commTimeoutsObj.WriteTotalTimeoutMultiplier = 0;
commTimeoutsObj.WriteTotalTimeoutConstant = 0;
// Set the above settings to the selected COM port.
bStatus = SetCommTimeouts (handle, &commTimeoutsObj);
so the ReadFile () waits for ((No of bytes to be read * 10) + 2) milliseconds
this is the time i wait !!
|
|
|
|
|
kapardhi wrote: so the ReadFile () waits for ((No of bytes to be read * 10) + 2) milliseconds
How many bytes do you expect ??
If the number of bytes is less time out should not be much.
There must be some handshaking commands that reader must be supporting.
Each time you need to do some operation with reader you can send these commands which have less number of bytes in response.
does it help??
Regards,
Sandip.
|
|
|
|
|
Sorry !!
Not yet satisfied!
Presently i send commands and wait for response , but i need some better approach !
Is there any command that gets all the details of the device connected to the serial port ??
|
|
|
|
|
Sounds strange that you are able to open a resource that is not connected to the system...
What "filename" are you providing as argument in the call to ::CreateFile() ?
Is ::CreateFile() actually returning a valid handle, i.e. it doesn't return INVALID_HANDLE_VALUE which is defined as -1?
Is ::ReadFile() really returning TRUE ?
"It's supposed to be hard, otherwise anybody could do it!" - selfquote "High speed never compensates for wrong direction!" - unknown
|
|
|
|
|
Suppose i just connect a Serial port cable to computers Serial port, and at the other end a reader is not connected, now a handle is successfully created.
now if i use ReadFile() it waits infinitely to receive a response !
on the other hand if i set some Time outs using SetCommTimeouts ()
the Readfile () successfully executes as it times out, i.e it doesnot receive response within stipulated time period, but it doesnot give error if the reader is not connected, it reads Zero bytes
|
|
|
|
|
kapardhi wrote: Serial port cable to computers Serial port
Ahh, that explains it.
I assumed it was a USB device, sorry about that.
kapardhi wrote: now if i use ReadFile() it waits infinitely to receive a response !
Don't know if you by this mean that the call blocks, but if that's a problem you can use overlapped mode instead. I would recommend overlapped mode whether this is a problem or not. However, the read request to the driver will not be completed until the timeout set by ::SetCommTimeouts() expires.
If the card reader would set one of the signals, e.g. DSR or CTS, to an active state it would be possible to use ::GetCommModemStatus() to check if the device is present. Have you investigated this possibility?
"It's supposed to be hard, otherwise anybody could do it!" - selfquote "High speed never compensates for wrong direction!" - unknown
|
|
|
|
|
Sorry !!
Not yet satisfied!
Presently i send commands and wait for response , but i need some better approach !
|
|
|
|
|
How about answering my question about hardware signals from the card reader?
If you cannot use the hardware to detect whether the device is present, you have to start communicating with the device.
Even if this is the unfortunate case, the device should respond fairly rapidly without worrying about degrading performance from a user perspective.
Perhaps this article[^] can give you some ideas.
"It's supposed to be hard, otherwise anybody could do it!" - selfquote "High speed never compensates for wrong direction!" - unknown
|
|
|
|
|
As you know, PE files are diveded into parts, each for a certain perpose (e.g. Code, Uninitialaized Data, Initialized Data, ...).
But I want the compiler not to do so! I'd like to put the entire program into a single section.
Thnx in advance . . .
|
|
|
|
|
Hi All,
Now i am trying to plot a graph using MSChart in MFC.i want to plot a Graph whose X-axis is Number of samples(range is 1,2,3,4,5 like that), Y-axis is Time(range is 0.5,1,1.5,2,2.5).While i am trying to change X& Y axis range using the MSChart Properties, The image of the Chart in the Dialog becomes smaller...
I need to adjust the X and Y -axis Range in the Graph?
How can i do this?
|
|
|
|
|
The following code is not compiling in .Net 1.1
[code]
This is the main project file for VC++ application project
// generated using an Application Wizard.
#include "stdafx.h"
#include <stdafx.h>
#include <ocilib.h>
using namespace System;
int _tmain(int argc, char *argv[])
{
OCI_Connection* cn;
OCI_Statement* st;
OCI_Resultset* rs;
int Counter = 0;
int ret;
FILE *TablesFile;
char *Database, *UserName, *UserPassword, *StartDate, *EndDate;
char Message[256] = "";
/* for (i=0; i<argc;> * {
* printf("%d %s\n", i, argv[i]);
* }
*/
Database = argv[1];
UserName = argv[2];
UserPassword = argv[3];
StartDate = argv[4];
EndDate = argv[5];
OCI_Initialize(NULL, NULL, OCI_ENV_DEFAULT);
cn = OCI_ConnectionCreate(Database, UserName, UserPassword, OCI_SESSION_DEFAULT);
st = OCI_StatementCreate(cn);
sprintf(Message, "select MemNumber,Turnover from (select mem_number MemNumber,sum(trans_turnover) Turnover from members join transact on mem_number = trans_code where Trans_date between '%s' and '%s' and mem_barred = 0 group by mem_number order by turnover desc ) where rownum <=200", StartDate, EndDate);
// printf("%s\n",Message);
OCI_ExecuteStmt(st, Message);
// OCI_ExecuteStmt(st,"select MemNumber,Turnover from (select mem_number MemNumber,sum(trans_turnover) Turnover from members join transact on mem_number = trans_code where Trans_date between '01-Jan-2004' and '14-Oct-2008' and mem_barred = 0 group by mem_number order by turnover desc ) where rownum < 201");
rs = OCI_GetResultset(st);
// printf("OCI_GetResultset() returns rs = %x\n", rs);
TablesFile = fopen("Tables.html", "wt");
while (OCI_FetchNext(rs))
{
fprintf(TablesFile, "% 4d - %u\n", ++Counter, OCI_GetDouble(rs, 1));
}
ret = fclose(TablesFile);
OCI_Cleanup();
return EXIT_SUCCESS;
}
[/code]
.Net returns C1004: unexpected end of file found
and as hard as I look I cannot see a missing or additional brace.
|
|
|
|
|
Member 5605240 wrote: using namespace System;
shouldn't this be using namespace std;
Somethings seem HARD to do, until we know how to do them.
_AnShUmAn_
|
|
|
|
|
Just go to the end of the file and press ENTER and save it again. Please inform us if it worked or not.
Thank you masters!
|
|
|
|
|
|
Why can't you do that at design time? Or is this range on the second dialog going to be dynamic?
Many are stubborn in pursuit of the path they have chosen, few in pursuit of the goal - Friedrich Nietzsche
.·´¯`·->Rajesh<-·´¯`·.
[Microsoft MVP - Visual C++]
|
|
|
|