|
Good point, as you say pretty easy to check for, I'll make sure I do.
Thanks,
Ali
|
|
|
|
|
as i know, serial port needs a thread (call it thread A) to read data.
u say "delay", delay what? for what?
i assume that u want "delay" (by Sleep) main thread (parent thread of thread A) to active Thread A. this is not correct in concept, the 70ms must be got from Thread A, the time is meaningless, just forget it.
only choice i think is to set a timer (few ms) in main thread for delay, then kill the timer.
includeh10
|
|
|
|
|
includeh10 wrote:
u say "delay", delay what? for what?
What I need is a delay between sending bytes because the receiving device is too slow and cannot buffer data coming in. If I send bytes too quickly they get ignored. But if I have really big delays then it takes ages to set up.
It looks like this is not possible, not sure what I am going to do.
Thanks for the advice,
Ali
|
|
|
|
|
i used communication port for years, do u use a event to check if sending buffer is empty?
includeh10
|
|
|
|
|
includeh10 wrote:
do u use a event to check if sending buffer is empty?
Yes, I send a block of data. I can see that the sending buffer is empty. Then I want to leave a gap of 1 or 2 ms to let the receiving device process the data before I send the next block of data.
If I do not leave a gap at all, then the receiving device ignores the first block of data and it is lost.
If I leave a big gap like 70ms to 100ms, I can't send the data quickly enough, because most of the time is used up by the gaps.
I think I may be able to use GetTickCount to create a basic timer, (see above reply). I think I will try that.
Thanks for your help,
Ali
|
|
|
|
|
communication port is not an easy job, u need to generate a good process in one app then for forevere (next apps).
i suggest u use 2 threads (sibling threads). one thread keeps all sending data in a buffer, another one is used for receiving data and deals with events.
u can use sleep between sibling threads to control working process.
if use many threads, make sure they are terminated properly (i used over 100 threads in one app). do not use CloseHandle() etc to interrupt threads, especially buffering threads. let threads exit natually, otherwise u may see exceptions often.
includeh10
|
|
|
|
|
includeh10 wrote:
communication port is not an easy job
Yes, thats true, and to be honest I have only one thread at the moment so that is obviously not helping. Looks like its time to look at threads!
Thanks for the advice,
Ali
|
|
|
|
|
I did something similar for a data collection thread that has to get spectra from a Diode array detector on set intervals. The way I did it was to the set thread priority very high (TIME_CRITICAL), so when the Sleep() completed, that thread was given control again. As it spent most of its time in a sleep() state it did not have any adverse effect of system performance.
Some of the oce envolved was:
RunThread->SetThreadPriority(THREAD_PRIORITY_TIME_CRITICAL) ;
FILETIME time1;
FILETIME time2;
::GetSystemTimeAsFileTime(&time1) ;
while (...)
{
::GetSystemTimeAsFileTime(&time2) ;
delay = (m_spectra_frequency * spectra_collected) - CalculateElapsedTime(&time1, &time2) ;
if (delay >= 0.001)
Sleep((unsigned long)(delay * 1000.0)) ;
}
double CalculateElapsedTime(FILETIME *start, FILETIME *current)
{
double elapsed_time ;
__int64 st ;
__int64 ct ;
__int32 *p ;
p = (__int32*)&st ;
*p++ = start->dwLowDateTime ;
*p = start->dwHighDateTime ;
p = (__int32*)&ct ;
*p++ = current->dwLowDateTime ;
*p = current->dwHighDateTime ;
elapsed_time = (double)(ct - st) ;
elapsed_time /= 10000000.0 ;
return elapsed_time ;
}
It may be of use
Roger Allen
Sonork 100.10016
I have a terminal disease. Its called life!
|
|
|
|
|
Thanks for the advice. Believe it or not I've got away with just one thread in all my apps up to now! But it looks like I cannot run away any longer, now is the time to look at threads.
I think I can see what you are explaining, its nice to have the code snippet to look at - I'll give it a go.
If you see some more questions about threads from me in the coming days you'll know it hasn't gone well!
Thanks again,
Ali
|
|
|
|
|
If I have this below CString data and I want to change it format to int.
Example:
CString data_str = "1487";
int data_int;
I want
data_int = 1487
Do you know how to do that?
|
|
|
|
|
Sometimes the C runtime comes in handy: atoi()[^]
|
|
|
|
|
use:
data_int = atoi( (LPCTSTR)data_str );
or even better use:
data_int = _ttoi( (LPCTSTR)data_str ); // unicode safe
|
|
|
|
|
I have used Visual Studio Installer to produce some MSI files
to install my applications.
I some PCs, where only WINNT or WIN2K OS is installed (MS office
not installed)the MSI file cannot be executed.
Does someone knows which application or DLL must be installed in
the target machine in order to allow the MSI file execution ???
Thank a lot !!!
|
|
|
|
|
|
I believe in your properties area for your project you can say to compile into a msi or setup.exe with installer support.. then it will output a .msi plus a setup.exe etc... then you have to distribute all the files in your output dir..
|
|
|
|
|
Hello all
according to ms features list, I have checked out the comparison table and it seems to me that vc++.net standard is missing the following features:
1) Enhanced professional C++ Optimizing Compiler
Build and deploy professional-quality applications with the industry's leading C++ Optimizing Compiler, which generates the smallest and highest performing executables. Now with Whole Program Optimization technology.
2 Enhanced advanced application wizards
Easily generate advanced C++ projects with professional-level application wizards for MFC ISAPI dynamic-link libraries (DLLs), Custom Visual Studio Wizards, and more.
3 Built-in support for additional programming languages
With support for multiple programming languages, you can easily program in the language of your choice and integrate the code from any other language.
4 Remote Debugging
Extend your debugging capabilities by stepping seamlessly into remote processes, including XML Web services.
5 SQL Debugging
With the Visual Studio .NET debugger, you can debug Microsoft SQL™ Server stored procedures, functions, and triggers in much the same way that you debug other kinds of scripts or programs.
6 Crystal Reports
Build rich interactive reports for Windows-based, Web-based, and mobile applications, as well as XML Web services.
7 Visual Database Tools
Design stored procedures, indexes, tables, triggers, user-defined functions, and other database elements visually. In the Visual Studio .NET Professional Edition, these design capabilities are limited to the SQL Server Desktop Engine.
8 Extended Stored Procedure DLLs
Create SQL Server extended stored procedures (XPROC) in C++ with the Extended Stored Procedure DLL project template.
Now, as I am planning basically to write freeware/shareware applications it seems to me that the Vc++.net standard fits my needs. In particular 2) to 8) seem to me options i reasonably will use very little.
As far as the 1) is concerned vc++.net standard offers a
Non-optimizing C++ Compiler to
Build and deploy C++ applications with performance and size characteristics appropriate, as MS tells, for hobbyist, student, and beginning programmers.
Now i have tested some siple projects (ie: wizard generated for MDI/SDI and dialog applications) and reported (working on windows XP HE) EXE sizes like the folllwing (release versions):
-SDI: close to 300 Kb
-MDI: close to 370 Kb
-DLG based appl.: close to 156 Kb
Which are the typical EXE sizes for similar projects generated and, i guess, optimized/tweaked by the VS.NET compiler?
Besides that, although the MS features comparison list pointing out the Non-optimizing C++ Compiler of this edition, i can find:
a) an 'optimize the whole program' option under the general projects settings page
b) an 'optimizazion page' under c/c++ with: 'enable independent optimizazions', 'processor optimizazions' and 'optimize for windows applications'
c) Linker/optimizazion
enable COMDAT reduction
optimize for win 98
functions order
I wonder if working on all and/or some of the above parameters i could get better EXE sizes and/or other useful optimizations, of course without troubles (otherwise i will leave those options like they are automatically set up by the IDE)
any help/tip/info will be greatly appreciated
thanks in advance
|
|
|
|
|
Hello all
with reference to VC++.NET
i'd like to figure out a little more deeply the following options (under project settings/c/c++ code generation options page):
runtime library:
/MD[d]
/ML[d]
/MT[d]
/LD[d]
I don't know much about 'threads', i have just noticed that when i select an 'MFC statically linked application', the compiler puts for me /MT[d for debug version] and puts /MD for an 'MFC linked as a shared DLL' project.
I have read the compiler help about these parameters but it isnt' actually much clear, so any tip/info will be greatly appreciated
I especially wonder if, say, i can 'forget' almost everything about these options as long as i will be just selecting 'statically linked MFC projects' (ending in /MT) or 'dynamically linked ones (ending in /MD) or, even if the wizard inserts, as pointed out below, them automatically, there are particular situation needing a further tweaking.
thanks in advance
|
|
|
|
|
Here is a short insight :
Is your application single-threaded or multi-threaded ?
If you answer single-threaded, then you use the single-threaded C/C++ run-time with the /ML switch. Of course, if you are compiling in debug mode, you use /MLd instead.
(The single-threaded run-time is libc.lib, libcd.lib in debug mode).
Now if you are multi-threaded, you need a multi-threaded C/C++ run-time, that is a run-time which is thread-safe (slower but safe). Do you want this run-time be statically linked (no distribution), or do you want it be loaded as a separate dll ?
If you answer statically linked, then use /MT. Of course, if you are in debug mode, use /MTd instead.
(The multi-threaded run-time is msvcrt.lib, msvcrtd.lib in debug mode).
If you answer as a separate dll instead, then use /ML. Of course, if you are in debug mode, use /MLd instead.
(The multi-threaded run-time is msvcrt.dll, msvcrtd.dll in debug mode).
Last note about the relation with the MFC : by design, the MFC uses the multi-threaded C/C++ run-time. You can use it statically linked, or use it as a separate dll.
I hope this clarifies the situation.
Back to real work : D-25.
|
|
|
|
|
Hi
I need some help regarding invoking Address book look from my application.
I have created an application and has added an addin .
Now i want to invoke address book of outlook and get its contents.
can any body help me in this regard.
Thanx and regards
Sufiyan Sana
|
|
|
|
|
|
I just want to invoke the address book and retrieve the entries.
but the link you provide me doesnt explain that.
regards
|
|
|
|
|
Yes it does. It tells you the Office HELP file where you'd find the information (at the bottom of the page.)
|
|
|
|
|
Do you mean Outlook Express Address Book?
Do you mean the Exchange Address book ?
Or do you mean Outlook Contacts?
Each has it's own way of being accessed depending on how Outlook is configured.
The most flexible way is via MAPI but this is the most complicated route. Do a search for MAPI and the IAdrBook interface.
CDO is probably an easy method but there are limited C++ samples. Have a read on MSDN about CDO and you should have a starting point.
Michael
Life’s not a song.
Life isn’t bliss.
Life is just this.
It’s living. -- Buffy the Vampire Slayer: Once more, with feeling
|
|
|
|
|
Hi guys, I've been using the VS .NET IDE for some time now to do regukar C++ programming and so far so good.
But this weekend I wanted to explore GDI+ and wrote the following little app.
#include <windows.h><br />
#include <gdiplus.h><br />
<br />
using namespace Gdiplus;<br />
<br />
int main()<br />
{<br />
Bitmap b(L"a.bmp");<br />
<br />
return 0;<br />
}
I compiled and got 6 LNK2019 (unresolved external symbol) errors.
They are all along the lines of
gdistuff error LNK2019: unresolved external symbol _GdipFree@4 referenced in function "public: static void __cdecl Gdiplus::GdiplusBase::operator delete(void *)" (??3GdiplusBase@Gdiplus@@SAXPAX@Z)
gdistuff error LNK2019: unresolved external symbol _GdipCloneImage@8 referenced in function "public: virtual class Gdiplus::Image * __thiscall Gdiplus::Image::Clone(void)" (?Clone@Image@Gdiplus@@UAEPAV12@XZ)
etc etc
And I don't really see why there is a problem. Compiling with the /VERBOSE linker option tells me that all the needed file paths are being searched during compilation and linking. And I have all the required header on my machine courtesy of VS. NET. What step did I miss? Could someone either verify this or at least point me to a setting I missed?
Thanks
Senkwe
ASP.NET can never fail as working with it is like fitting bras to supermodels - it's one pleasure after the next - David Wulff
|
|
|
|
|
Go into Project Properties, Linker, Input, Additional Dependancies, and ensure gdiplus.lib is among the libraries listed there.
Shog9
------
to the revelations of fresh faced youth
no one will come to save you
so speak your peace in the murmurs drawn
but youth is wasted on the young - Smashing Pumpkins, Thru the Eyes of Ruby
|
|
|
|