|
hi ..
Im doing a multithreaded program (in borland c++ builder.. I know that this place is for VC++ but a have no other place to go and I trust the knowladge of the ppl in this site..)that communicate with a modem via serial port.. my program takes characters from Edit1 then writes it to the buffer
strcpy( cp2, Edit1->Text.c_str() );<br />
WriteABuffer(m_hCom,cp2,strlen(cp2));
the problem is that there is something wrong with this ..I use a serial port spy program to monitor the serial port..now when I end an "AT command" like "AT", I send is like this "AT\r" but is show me this
[22/05/2006 10:18:25] - Written data<br />
<br />
41 54 5c 72 AT\\
but when I assign cp2 = "At\r"; it works!!
cp2 = "At\r"; <br />
WriteABuffer(m_hCom,cp2,strlen(cp2));
it shows :
[22/05/2006 10:24:53] - Written data<br />
<br />
41 54 0d AT.
which is right and the modem will respond by sending "ok".
"Edit1->Text" is AnsiString and "Edit1->Text.c_str()" is used to get the string from it..
Im using standerd writeFile ReadFile functions..
how can I solve this problem..I need to type commands in the Edit1 box so I can deal with the port while my program is running ..can you help please??
|
|
|
|
|
Hi
strcpy( cp2, Edit1->Text.c_str() );
WriteABuffer(m_hCom,cp2,strlen(cp2));
In the first case you typing AT\r in the edit box and sending it directly.
as you can see the HEX code of it
A T \ r
41 54 5c 72
and in the second case its different.
So the problem is instead of writting AT\r in the edit box you should just type AT.
and in the coding you change a little. I am writting in C as I don't know borland C++.
strcpy( cp2, Edit1->Text.c_str() ); // AT only.
strcat( cp2, "\r" );
WriteABuffer(m_hCom,cp2,strlen(cp2));
Regards
Anil
|
|
|
|
|
thanks that works.. I totally forgot about the hex value..I did it like this ..
AnsiString tmp;<br />
tmp= Edit1->Text + "\r" ;<br />
WriteABuffer(m_hCom,tmp,strlen(tmp));
thanks again...;)
|
|
|
|
|
I have a CEdit control that pulls in the persons name.
The name has to be exactly 40 characters and if its less
than 40 characters, the remainder has to be blank spaces.
I has this code:
void CWizardPage1::OnKillfocusTr15() <br />
{<br />
CString str;<br />
m_tr_15.GetWindowText(str);
<br />
str.MakeUpper();<br />
<br />
str = str.Left(40);<br />
<br />
if (str.GetLength() < 40)<br />
{<br />
int diff = 40 - str.GetLength();<br />
<br />
for (int i=0; i<diff; i++)<br />
str += " ";<br />
}<br />
<br />
m_tr_15.SetWindowText(str);<br />
}
Anyone have any suggestion or rewriting this so that
I dont use the for loop. Im hoping there is an easier
way to quickly add a variable length of blank spaces.
Please, any response any one can give me will be
greatly appreciated.
Sincerely,
Danielle Brina (an overworked graduate student)
|
|
|
|
|
DanYELL wrote: void CWizardPage1::OnKillfocusTr15()
{
CString str;
m_tr_15.GetWindowText(str); // name
str.MakeUpper();
str = str.Left(40);
if (str.GetLength() < 40)
{
int diff = 40 - str.GetLength();
for (int i=0; i str += " ";
}
m_tr_15.SetWindowText(str);
}
I have not tested, but it should work.
BOOL CWizardPage1::OnInitDialog()<br />
{<br />
m_tr_15.SetLimitText(40); <br />
}
void CWizardPage1::OnKillfocusTr15() <br />
{<br />
CString str;<br />
<br />
m_tr_15.GetWindowText(str);
str.MakeUpper();<br />
<br />
<br />
if (str.GetLength() < 40)<br />
{<br />
<br />
<br />
char sTail[41] = {0};<br />
memset(sTail, ' ' , 40);<br />
str += sTail;<br />
}<br />
<br />
m_tr_15.SetWindowText(str);<br />
}
Maxwell Chen
|
|
|
|
|
Hi I have a situation where I want to performance test an application. I recorded the http request that goes to the server which is using zip compression. That means the request is in a .zip format with 2 files inside it. One file is having all the dynamic data like user id and all the primary keys. other one has some raw data. Because I need to send this request over and over again to the server with different key data I need to manipulate the file that has the userid and replace the userid with different values and send it to the server.
Now the question is are there any available functions that help me ? I heard about 'minizip' package but how to use that ? if anyone of you have used them before please help me.
Thanks
|
|
|
|
|
There are several articles on this site regarding zip files. I would search for them but I am on a very slow connection in an airport right now.
|
|
|
|
|
There are several third party packages available. If just for testing, you could spawn a command line utility from within the program.
Anyone who thinks he has a better idea of what's good for people than people do is a swine.
- P.J. O'Rourke
|
|
|
|
|
Rick and Joe
Please accept my 'Thanks' for your quick replies.
I will detail my requirements as soon as I get to office tomorrow.
I found LiteZip/LiteUnzip on this forum which may help me!
Thanks again
|
|
|
|
|
Please help me!
I use directshow to display a live-kamera in my Application.
Perhaps i have to use Sockets, but how can i transfer the Videostream (directshow) to another Computer and display it in an application?
Can anybody help me, i just don't know what to do!
|
|
|
|
|
Thanks For each one work in the best Site in World
"codeproject"....
can i make my program "Create new Menu or Icon for itself"
When MFC program setup on any pc.
i ask all sites, but ...
Please Idea or Instruction in MFC to work this,as Quickly
because this idea is my Graduation project
please answering must be before week.
thanks in advance
the code project is the best
|
|
|
|
|
Look into the resource editor.
Somethings seem HARD to do, until we know how to do them.
_AnShUmAn_
|
|
|
|
|
I need to store and access a lot of small separate files. Whats the best way to group them together in an archive like single file (not compressed for fast access reason) and not to waste disk space. are there source codes?
9ine
|
|
|
|
|
What kind of data do your files contain?
|
|
|
|
|
just text formated signal:
3.21
2.22
4.44
5.55
... etc
9ine
|
|
|
|
|
So I would try it with XML. If you use SAX to read and write the file, the performance should be acceptable. There are several easy to use implementations to do this.
|
|
|
|
|
If you don't need to search the file data (just file names) then you may want to look at putting them in a database (e.g. MSDE aka MS SQL Srv lite).
...cmk
Save the whales - collect the whole set
|
|
|
|
|
Probably the easiest is to use sturctured storage. See here[^] for documentation.
Steve
|
|
|
|
|
I need somthing simple for console app, like TAR archive
9ine
|
|
|
|
|
Dear everyone;
i am trying to write some data to a file. now thats not a problem, what i also would like to do is to open a pre-existing file and append more data on it everytime my application is used.
thats what i have done, but for some reason it does not work ??
FILE* trial = fopen("Trial.txt","a+");
// a user event function which processes user clicks
BOOL CExample::PreTranslateMessage(MSG* pMsg){
if(WM_LBUTTONDOWN == pMsg->message){
fprintf(trial, "\nAppend Data");
fflush(trial);
}
}
The file however appears to be not changing at all !!!
any help will be very much appreciated
llp00na
|
|
|
|
|
Have you checked the return values of the fopen, fprintf and fflush functions? Check the return values to se if an error occured.
You may be right
I may be crazy
-- Billy Joel --
Within you lies the power for good - Use it!
|
|
|
|
|
well fprintf returns an integer (38). How wud i check for errors ???
llp00na
|
|
|
|
|
llp00na wrote: How wud i check for errors ???
Look up fprintf in MSDN. The documentation tells you what the return values mean or how to find out what the errors are.
You may be right
I may be crazy
-- Billy Joel --
Within you lies the power for good - Use it!
|
|
|
|
|
Hi to all,
1) How to Play any Audio File i.e. MPEG,WAVE,MIDI,wma,etc.. (with functionalities such as pause, stop, start from any position)?
2) How to Set Volume of System?
Best Regards,
Aniket
|
|
|
|
|
Maybe you can find what you are looking for at http://www.codeproject.com/audio/[^].
You may be right
I may be crazy
-- Billy Joel --
Within you lies the power for good - Use it!
|
|
|
|